diff --git a/SaxoniteCoreUnitTests/UnitTests/Web/Admin/App/SaxApplication_Admin_Tester.cs b/SaxoniteCoreUnitTests/UnitTests/Web/Admin/App/SaxApplication_Admin_Tester.cs index e3eb4f3..6f0dbc9 100644 --- a/SaxoniteCoreUnitTests/UnitTests/Web/Admin/App/SaxApplication_Admin_Tester.cs +++ b/SaxoniteCoreUnitTests/UnitTests/Web/Admin/App/SaxApplication_Admin_Tester.cs @@ -36,7 +36,7 @@ namespace Saxonite.Net.Core.UnitTests.Web.Admin.App var mockEnvironment = new Mock(); mockEnvironment.Setup(m => m.EnvironmentName).Returns(Environments.Development); - mockEnvironment.Setup(m => m.ContentRootPath).Returns(@"D:\Sarand\Projects\Users\AHoward\VS2019\Saxonite\Workspace\SaxoniteCoreWebAdmin"); + mockEnvironment.Setup(m => m.ContentRootPath).Returns(@"D:\Sarand\Projects\Users\AHoward\VS2022\Saxonite\Workspace\SaxoniteCoreWebAdmin"); app = new SaxApplication_Admin_Test(mockConfiguration.Object, mockEnvironment.Object); } diff --git a/SaxoniteCoreUnitTestsOnline/UnitTests/Online/App/SaxApplication_Online_Tester.cs b/SaxoniteCoreUnitTestsOnline/UnitTests/Online/App/SaxApplication_Online_Tester.cs index e565f8c..3284901 100644 --- a/SaxoniteCoreUnitTestsOnline/UnitTests/Online/App/SaxApplication_Online_Tester.cs +++ b/SaxoniteCoreUnitTestsOnline/UnitTests/Online/App/SaxApplication_Online_Tester.cs @@ -3,6 +3,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; +using Saxonite.Net.Core.Web.Base.App; using Saxonite.Net.Core.Web.Online.App; using Saxonite.Net.Standard.Base.App; using System; @@ -11,45 +12,59 @@ using System.Text; namespace Saxonite.Net.Core.UnitTests.Web.Online.App { - //======================================================================= - [TestClass] - public class SaxApplication_Online_Tester - { - //------------------------------------------------------------------- - // Application. - private class SaxApplication_Online_Test : SaxApplication_Online - { - public SaxApplication_Online_Test(IConfiguration configuration, IWebHostEnvironment env) : - base(configuration) - { - InitEnvironment(env); - } - } - private static SaxApplication_Online_Test app; - public static SaxApplication_Online App - { - get - { - if (app == null) - { - var mockConfiguration = new Mock(); + //======================================================================= + [TestClass] + public class SaxApplication_Online_Tester + { + //------------------------------------------------------------------- + // Application. + private class SaxApplication_Online_Test : SaxApplication_Online + { + public SaxApplication_Online_Test(IConfiguration configuration, IWebHostEnvironment env) : + base(configuration) + { + InitEnvironment(env); - var mockEnvironment = new Mock(); - mockEnvironment.Setup(m => m.EnvironmentName).Returns(Environments.Development); - mockEnvironment.Setup(m => m.ContentRootPath).Returns(@"D:\Sarand\Projects\Users\AHoward\VS2019\Saxonite\Workspace\SaxoniteCoreWebOnline"); + // Application initialisation currently fails reading configuration. + if (SessionContext == null) + SessionContext = new SessionContextData(new SaxSessionContext_Web(100, Sax.Application.Online)).SessionContext; + } + } + private static SaxApplication_Online_Test app; + public static SaxApplication_Online App + { + get + { + if (app == null) + { + var mockConfiguration = new Mock(); - app = new SaxApplication_Online_Test(mockConfiguration.Object, mockEnvironment.Object); - } - return app; - } - } + var mockEnvironment = new Mock(); + mockEnvironment.Setup(m => m.EnvironmentName).Returns(Environments.Development); + mockEnvironment.Setup(m => m.ContentRootPath).Returns(@"D:\Sarand\Projects\Users\AHoward\VS2022\Saxonite\Workspace\SaxoniteCoreWebOnline"); - //------------------------------------------------------------------- - // Internals - component managers etc. - private static SaxInternals internals; - public static SaxInternals Internals { get { if (internals == null) internals = new SaxInternals(App.SessionContext); return internals; } } + app = new SaxApplication_Online_Test(mockConfiguration.Object, mockEnvironment.Object); + } + return app; + } + } - //------------------------------------------------------------------- - } - //======================================================================= + //------------------------------------------------------------------- + // Internals - component managers etc. + private static SaxInternals internals; + public static SaxInternals Internals + { + get + { + if (internals == null) + { + internals = new SaxInternals(App.SessionContext); + } + return internals; + } + } + + //------------------------------------------------------------------- + } + //======================================================================= } diff --git a/SaxoniteCoreUnitTestsOnline/UnitTests/Online/App/SaxSessionData_Online_Tester.cs b/SaxoniteCoreUnitTestsOnline/UnitTests/Online/App/SaxSessionData_Online_Tester.cs index 2505d00..9c75bf8 100644 --- a/SaxoniteCoreUnitTestsOnline/UnitTests/Online/App/SaxSessionData_Online_Tester.cs +++ b/SaxoniteCoreUnitTestsOnline/UnitTests/Online/App/SaxSessionData_Online_Tester.cs @@ -63,6 +63,9 @@ namespace Saxonite.Net.Core.UnitTests.Web.Online.App Assert.IsTrue(sessionData.ValidUserSession); Assert.AreNotEqual("", sessionData.User.DisplayName); + // User configuration. + sessionData.UserConfig.Profile.Eligibility.HideInfo = true; + // Profile sports. foreach (SaxSessionData_Online.UserProfileData.SportData sport in sports) sessionData.Profile.AddSport(sport.SportId, sport.Status); @@ -121,8 +124,11 @@ namespace Saxonite.Net.Core.UnitTests.Web.Online.App Assert.AreNotEqual(0, userRoleDeserialised.Role); } - // Profile sports. - Assert.AreEqual(sports.Count, sessionDataDeserialised.Profile.Sports.Count); + // User configuration. + Assert.AreEqual(sessionData.UserConfig.Profile.Eligibility.HideInfo, sessionDataDeserialised.UserConfig.Profile.Eligibility.HideInfo); + + // Profile sports. + Assert.AreEqual(sports.Count, sessionDataDeserialised.Profile.Sports.Count); foreach (SaxSessionData_Online.UserProfileData.SportData sport in sports) { SaxSessionData_Online.UserProfileData.SportData sportDeserialised = sessionDataDeserialised.Profile.Sports.Find(item => item.SportId.Equals(sport.SportId)); diff --git a/SaxoniteCoreWeb/Base/App/SaxLocaliser.cs b/SaxoniteCoreWeb/Base/App/SaxLocaliser.cs index 168736a..392f340 100644 --- a/SaxoniteCoreWeb/Base/App/SaxLocaliser.cs +++ b/SaxoniteCoreWeb/Base/App/SaxLocaliser.cs @@ -214,9 +214,15 @@ namespace Saxonite.Net.Core.Web.Base.App } // Sport Speciality label. - public String GetSportSpecialityLabelCaption(Sax.SportSpecialityLabel specialityLabel) + public String GetSportSpecialityLabelCaption(Sax.SportSpecialityLabel sportSpecialityLabel) { - return GetCodeTypeCaption(Sax.CodeType.SportSpecialityLabel, specialityLabel); + return GetCodeTypeCaption(Sax.CodeType.SportSpecialityLabel, sportSpecialityLabel); + } + + // Sport Contact Type. + public String GetSportContactTypeCaption(Sax.SportContactType sportContactType) + { + return GetCodeTypeCaption(Sax.CodeType.SportContactType, sportContactType); } // Sport Participation. diff --git a/SaxoniteCoreWeb/Base/Controllers/SaxController_Base.cs b/SaxoniteCoreWeb/Base/Controllers/SaxController_Base.cs index bb63793..82b38bd 100644 --- a/SaxoniteCoreWeb/Base/Controllers/SaxController_Base.cs +++ b/SaxoniteCoreWeb/Base/Controllers/SaxController_Base.cs @@ -114,6 +114,7 @@ namespace Saxonite.Net.Core.Web.Base.Controllers // System codes. public List DataItemTypeCodes { get { return Internals.DataItemTypeCodes; } } public List SportSpecialityLabelCodes { get { return Internals.SportSpecialityLabelCodes; } } + public List SportContactTypeCodes { get { return Internals.SportContactTypeCodes; } } public List SportParticipationCodes { get { return Internals.SportParticipationCodes; } } public List SportOfficiatingCodes { get { return Internals.SportOfficiatingCodes; } } public List RegionTypeCodes { get { return Internals.RegionTypeCodes; } } diff --git a/SaxoniteCoreWeb/Base/Models/SaxModel_Base.cs b/SaxoniteCoreWeb/Base/Models/SaxModel_Base.cs index e2b5b26..a70cabf 100644 --- a/SaxoniteCoreWeb/Base/Models/SaxModel_Base.cs +++ b/SaxoniteCoreWeb/Base/Models/SaxModel_Base.cs @@ -91,6 +91,7 @@ namespace Saxonite.Net.Core.Web.Base.Models public List DataItemTypeCodes { get { return Internals.DataItemTypeCodes; } } public List YesNoCodes { get { return Internals.YesNoCodes; } } public List SportSpecialityLabelCodes { get { return Internals.SportSpecialityLabelCodes; } } + public List SportContactTypeCodes { get { return Internals.SportContactTypeCodes; } } public List SportParticipationCodes { get { return Internals.SportParticipationCodes; } } public List SportOfficiatingCodes { get { return Internals.SportOfficiatingCodes; } } public List RegionTypeCodes { get { return Internals.RegionTypeCodes; } } diff --git a/SaxoniteCoreWebAdmin/appsettings.Machine.Sarand107.json b/SaxoniteCoreWebAdmin/appsettings.Machine.Sarand107.json index 990c2e6..8c44c27 100644 --- a/SaxoniteCoreWebAdmin/appsettings.Machine.Sarand107.json +++ b/SaxoniteCoreWebAdmin/appsettings.Machine.Sarand107.json @@ -20,10 +20,10 @@ } }, "Documents": { - "RootFolder": "D:\\Sarand\\Projects\\Users\\AHoward\\VS2019\\Saxonite\\Docs" + "RootFolder": "D:\\Sarand\\Projects\\Users\\AHoward\\VS2022\\Saxonite\\Docs" }, "Logging": { - "RootFolder": "D:\\Sarand\\Projects\\Users\\AHoward\\VS2019\\Saxonite\\Logs\\Admin" + "RootFolder": "D:\\Sarand\\Projects\\Users\\AHoward\\VS2022\\Saxonite\\Logs\\Admin" } }, "Saxonite-Test": { @@ -43,17 +43,17 @@ } }, "Documents": { - "RootFolder": "D:\\Sarand\\Projects\\Users\\AHoward\\VS2019\\Saxonite\\Docs" + "RootFolder": "D:\\Sarand\\Projects\\Users\\AHoward\\VS2022\\Saxonite\\Docs" }, "Logging": { - "RootFolder": "D:\\Sarand\\Projects\\Users\\AHoward\\VS2019\\Saxonite\\QC\\Logs\\Admin" + "RootFolder": "D:\\Sarand\\Projects\\Users\\AHoward\\VS2022\\Saxonite\\QC\\Logs\\Admin" }, "Variants": [ { - "ApplicationRootFolder": "D:\\Sarand\\Projects\\Users\\AHoward\\VS2019\\Saxonite\\QC2\\App", + "ApplicationRootFolder": "D:\\Sarand\\Projects\\Users\\AHoward\\VS2022\\Saxonite\\QC2\\App", "Instance": "QC", "Logging": { - "RootFolder": "D:\\Sarand\\Projects\\Users\\AHoward\\VS2019\\Saxonite\\QC2\\Logs\\Admin" + "RootFolder": "D:\\Sarand\\Projects\\Users\\AHoward\\VS2022\\Saxonite\\QC2\\Logs\\Admin" } } ] diff --git a/SaxoniteCoreWebAdmin/appsettings.Machine.Sarand110.json b/SaxoniteCoreWebAdmin/appsettings.Machine.Sarand110.json index 4bbf686..ac57b47 100644 --- a/SaxoniteCoreWebAdmin/appsettings.Machine.Sarand110.json +++ b/SaxoniteCoreWebAdmin/appsettings.Machine.Sarand110.json @@ -30,7 +30,7 @@ "Environments": [ "Production" ], "Instance": "QC", "CoreDatabase": { - "Location": "MsSql:Sarand106\\SQL2014.Saxonite_Dev", + "Location": "MsSql:Sarand110\\SQL2016.Saxonite_Dev", "User": "saxonite", "Password": "sax-dev-2021" }, diff --git a/SaxoniteCoreWebAdmin/wwwroot/css/sax-data.css b/SaxoniteCoreWebAdmin/wwwroot/css/sax-data.css index 8c47e77..0e3f4ce 100644 --- a/SaxoniteCoreWebAdmin/wwwroot/css/sax-data.css +++ b/SaxoniteCoreWebAdmin/wwwroot/css/sax-data.css @@ -132,6 +132,11 @@ background-image: url('../img/action/refresh24.png'); } +.sax-header ul.nav.sax-burger ul.sax-dropdown-menu li.sax-action.sax-dropdown-item.sax-info +{ + background-image: url('../img/action/info24.png'); +} + .sax-header ul.nav.sax-burger ul.sax-dropdown-menu li.sax-action.sax-dropdown-item.sax-add { background-image: url('../img/action/add24.png'); diff --git a/SaxoniteCoreWebOnline/Localisation/SaxOnlineProperties.resx b/SaxoniteCoreWebOnline/Localisation/SaxOnlineProperties.resx index 6a46d71..3ef0f09 100644 --- a/SaxoniteCoreWebOnline/Localisation/SaxOnlineProperties.resx +++ b/SaxoniteCoreWebOnline/Localisation/SaxOnlineProperties.resx @@ -198,6 +198,12 @@ My Eligibility + + Show info + + + User Configuration + Solum Forti @@ -243,6 +249,9 @@ [{0} chars available] + + You can identify the countries that you are eligible to participate for by adding references to your parentage and passport/visas. + Registered @@ -282,6 +291,9 @@ Awards + + Bio + Calendar @@ -678,6 +690,9 @@ Item deletion failed + + A duplicate item already exists. + Item not found for specified Id diff --git a/SaxoniteCoreWebOnline/Online/App/SaxApplication_Online.cs b/SaxoniteCoreWebOnline/Online/App/SaxApplication_Online.cs index 175b517..9ad182e 100644 --- a/SaxoniteCoreWebOnline/Online/App/SaxApplication_Online.cs +++ b/SaxoniteCoreWebOnline/Online/App/SaxApplication_Online.cs @@ -30,7 +30,7 @@ namespace Saxonite.Net.Core.Web.Online.App private Dictionary appConfigs = new Dictionary(); private Dictionary emailConfigs = new Dictionary(); // Session contexts. - private class SessionContextData + protected class SessionContextData { public SessionContextData(SaxSessionContext_Web sessionContext) { diff --git a/SaxoniteCoreWebOnline/Online/App/SaxSessionData_Online.cs b/SaxoniteCoreWebOnline/Online/App/SaxSessionData_Online.cs index b8a8ba6..8e81e63 100644 --- a/SaxoniteCoreWebOnline/Online/App/SaxSessionData_Online.cs +++ b/SaxoniteCoreWebOnline/Online/App/SaxSessionData_Online.cs @@ -8,6 +8,7 @@ using Saxonite.Net.Core.Web.Base.App; using Saxonite.Net.Core.Web.Online.Controllers; using Saxonite.Net.Standard.Base.App; using Saxonite.Net.Standard.Base.Bus; +using Saxonite.Net.Standard.Base.Data; using System; using System.Collections.Generic; using System.Linq; @@ -49,16 +50,16 @@ namespace Saxonite.Net.Core.Web.Online.App { return base.RefreshUserData(userAccount); } - } + } protected override UserData CreateUserData(SaxSessionContext sessionContext, SaxUserAccount userAccount, List userRoles) { return new UserData_Online(sessionContext, userAccount, userRoles); } /// User - JSON deserialisation route. public new UserData User { get { return base.User; } set { SetUser(new UserData_Online(value)); } } - /// - /// Update the user's contect details against the session. - /// - User Account must match that already against the session. - /// - public bool RefreshUser(SaxUserAccount userAccount) + /// + /// Update the user's contect details against the session. + /// - User Account must match that already against the session. + /// + public bool RefreshUser(SaxUserAccount userAccount) { UserData_Online user = User as UserData_Online; if (user != null) @@ -67,9 +68,19 @@ namespace Saxonite.Net.Core.Web.Online.App } //------------------------------------------------------------------- - // User Profile. - // Protected constructors & setters for JSON deserialisation. - public class UserProfileData + // User Config - user's application settings. + public class UserConfigData + { + /// Online Profile Config data. + public SaxConfigData.ProfileData Profile{ get; set; } = new SaxConfigData.ProfileData(); + } + /// User Configuration. + public UserConfigData UserConfig { get; set; } = new UserConfigData(); + + //------------------------------------------------------------------- + // User Profile. + // Protected constructors & setters for JSON deserialisation. + public class UserProfileData { public UserProfileData() { } // Sports. diff --git a/SaxoniteCoreWebOnline/Online/Controllers/AccountController-Ajax-Contact.cs b/SaxoniteCoreWebOnline/Online/Controllers/AccountController-Ajax-Contact.cs index 44ae0eb..912b655 100644 --- a/SaxoniteCoreWebOnline/Online/Controllers/AccountController-Ajax-Contact.cs +++ b/SaxoniteCoreWebOnline/Online/Controllers/AccountController-Ajax-Contact.cs @@ -18,6 +18,8 @@ using Sarand.Net.Standard.Base.Helpers; using System.IO; using System.Drawing; using Sarand.Net.Standard.Base.Core; +using Saxonite.Net.Standard.Base.Data; +using static Saxonite.Net.Standard.Base.App.Sax.Config; namespace Saxonite.Net.Core.Web.Online.Controllers { @@ -41,6 +43,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers public byte DobDay { get; set; } public byte DobMonth { get; set; } public short DobYear { get; set; } + public bool? HasImage { get; set; } = null; // Regions. public String RegionIdCountry { get; set; } public String RegionCaptionCountry { get; set; } @@ -61,6 +64,8 @@ namespace Saxonite.Net.Core.Web.Online.Controllers data.DobDay = (byte)userAccount.DateOfBirthDay; data.DobMonth = (byte)userAccount.DateOfBirthMonth; data.DobYear = (short)userAccount.DateOfBirthYear; + if (ItemDataMgr.ItemHasActiveImage(userAccount.GetItemId(), Sax.ImageType.Avatar)) + data.HasImage = true; // Regions. data.RegionIdCountry = model.GetEncryptedRegionId(userAccount.RegionIdCountry); data.RegionIdProvince = model.GetEncryptedRegionId(userAccount.RegionIdProvince); diff --git a/SaxoniteCoreWebOnline/Online/Controllers/AccountController-Ajax-Eligibility.cs b/SaxoniteCoreWebOnline/Online/Controllers/AccountController-Ajax-Eligibility.cs index 85a5cba..e61cc94 100644 --- a/SaxoniteCoreWebOnline/Online/Controllers/AccountController-Ajax-Eligibility.cs +++ b/SaxoniteCoreWebOnline/Online/Controllers/AccountController-Ajax-Eligibility.cs @@ -79,6 +79,12 @@ namespace Saxonite.Net.Core.Web.Online.Controllers public List Eligibilities { get; } = new List(); // Eligibility types. public List Types { get; } = new List(); + // User configuration. + public class ConfigData + { + public bool? hideInfo { get; set; } = null; + } + public ConfigData Config { get; } = new ConfigData(); } // Ajax request. [HttpPost] @@ -112,6 +118,10 @@ namespace Saxonite.Net.Core.Web.Online.Controllers if (!SysId.IsValid(userAccountId)) userAccountId = SessionUserAccountId; + // User configuration. + if (SessionData_Online.UserConfig.Profile.Eligibility.HideInfo) + responseData.Config.hideInfo = true; + // Item filter. SaxUserEligibility.Params prmUserEligibility = new SaxUserEligibility.Params(); prmUserEligibility.UserAccountIdsIncluded.Add(userAccountId); @@ -300,7 +310,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers SaxRegion.Data region = Internals.GetRegion(regionId); // Eligibility type. - Sax.EligibilityType eligibilityType = userEligibility != null ? userEligibility.EligibilityType : model.Eligibility.getEligibilityType(); + Sax.EligibilityType eligibilityType = model.Eligibility.Type != null ? model.Eligibility.getEligibilityType() : userEligibility != null ? userEligibility.EligibilityType : 0; if (eligibilityType <= 0) { // Shouldn't get here. @@ -309,7 +319,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers } // Check for duplicate data. - // ToDo Should include date range in checking for duplicate eligibility? + // ToDo Include date range in checking for duplicate eligibility? { // First check without region. SaxUserEligibility.Params prmUserEligibility = new SaxUserEligibility.Params(); @@ -321,33 +331,82 @@ namespace Saxonite.Net.Core.Web.Online.Controllers long eligibilityCount = AccountMgr.GetUserEligibilityCount(prmUserEligibility); // Selected Eligibility types have a limit on the number of instances allowed. if (eligibilityCount >= SaxUserEligibility.GetMaxInstances(eligibilityType)) - return Json(responseData.SetMessage(messageTitle, Localiser["msg.validation.duplicate.value"])); + { + SaLogger.Warn(fn + " Eligibility type instance limit reached. Type: " + eligibilityType.ToString() + ". Instances: " + eligibilityCount + ". " + GetLogSuffix()); + return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.duplicate"])); + } // Now include region - only allow one eligibility of each type. prmUserEligibility.RegionIdsIncluded.Add(regionId); eligibilityCount = AccountMgr.GetUserEligibilityCount(prmUserEligibility); if (eligibilityCount >= 1) - return Json(responseData.SetMessage(messageTitle, Localiser["msg.validation.duplicate.value"])); + { + SaLogger.Warn(fn + " Duplicate Eligibility exists. RegionId: " + SysId.ToString(regionId) + ". Type: " + eligibilityType.ToString() + ". " + GetLogSuffix()); + return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.duplicate"])); + } + } + + // If region or eligibility have changed, check whether an equivalent deleted eligibility exists. + // NB Can't modify the current eligibility with the modified values as it would conflict with the + // deleted item - unique on user, region and eligibility. + if (userEligibility != null && (!userEligibility.RegionId.Equals(regionId) || userEligibility.EligibilityType != eligibilityType)) + { + SaxUserEligibility.Params prmUserEligibility = new SaxUserEligibility.Params(); + prmUserEligibility.IdsExcluded.Add(userEligibility.Id); + prmUserEligibility.UserAccountIdsIncluded.Add(userAccountId); + prmUserEligibility.RegionIdsIncluded.Add(regionId); + prmUserEligibility.EligibilityTypesIncluded.Add(eligibilityType); + prmUserEligibility.StatusCat = SaxUserEligibility.StatusCat.DeletedOnly; + SaxUserEligibility userEligibilityDeleted = AccountMgr.GetUserEligibility(prmUserEligibility); + if (userEligibilityDeleted != null) + { + disposableItems.Add(userEligibilityDeleted); + SaLogger.Info(fn + " Resurrecting User Eligibility with status: " + userEligibilityDeleted.StatusDesc + ". Id: " + SysId.ToString(userEligibilityDeleted.Id) + ". " + GetLogSuffix()); + userEligibilityDeleted.Status = SaxUserEligibility.DefaultStatus; + // Delete current item and replace with previously deleted item. + if (!AccountMgr.DeleteUserEligibility(userEligibility, DbUpdateInfo)) + { + SaLogger.Warn(fn + " Failed to delete user eligibility: " + AccountMgr.ErrorStateMessage); + return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.update.failed"])); + } + userEligibility = userEligibilityDeleted; + } } // If eligibility doesn't exist for the user, it may have been previously deleted. if (userEligibility == null) { + // See if there is an existing item that matches user, region and eligibility. SaxUserEligibility.Params prmUserEligibility = new SaxUserEligibility.Params(); prmUserEligibility.UserAccountIdsIncluded.Add(userAccountId); prmUserEligibility.RegionIdsIncluded.Add(regionId); prmUserEligibility.EligibilityTypesIncluded.Add(eligibilityType); - prmUserEligibility.StatusCat = SaxUserEligibility.StatusCat.Any; + prmUserEligibility.StatusCat = SaxUserEligibility.StatusCat.DeletedOnly; userEligibility = AccountMgr.GetUserEligibility(prmUserEligibility); + if (userEligibility == null) + { + // Try again for the user & region without the eligibility type. + prmUserEligibility.EligibilityTypesIncluded.Clear(); + userEligibility = AccountMgr.GetUserEligibility(prmUserEligibility); + } + if (userEligibility == null) + { + // Try again for the user & eligibility type without the region. + prmUserEligibility.RegionIdsIncluded.Clear(); + prmUserEligibility.EligibilityTypesIncluded.Add(eligibilityType); + userEligibility = AccountMgr.GetUserEligibility(prmUserEligibility); + } + if (userEligibility == null) + { + // Try again just for the user. + prmUserEligibility.RegionIdsIncluded.Clear(); + prmUserEligibility.EligibilityTypesIncluded.Clear(); + userEligibility = AccountMgr.GetUserEligibility(prmUserEligibility); + } if (userEligibility != null) { disposableItems.Add(userEligibility); - if (userEligibility.Status == SaStatus.Deleted) - { - SaLogger.Info(fn + " Resurrecting User Eligibility with status: " + userEligibility.StatusDesc + ". Id: " + SysId.ToString(userEligibility.Id)); - userEligibility.Status = SaxUserEligibility.DefaultStatus; - } - else - return Json(responseData.SetMessage(messageTitle, Localiser["msg.validation.duplicate.value"])); + SaLogger.Info(fn + " Resurrecting User Eligibility with status: " + userEligibility.StatusDesc + ". Id: " + SysId.ToString(userEligibility.Id) + ". " + GetLogSuffix()); + userEligibility.Status = SaxUserEligibility.DefaultStatus; } else { @@ -357,6 +416,8 @@ namespace Saxonite.Net.Core.Web.Online.Controllers } // Populate item properties. + userEligibility.RegionId = regionId; + userEligibility.EligibilityType = eligibilityType; if (model.Eligibility.Info != null) userEligibility.Info = model.Eligibility.Info; if (model.Eligibility.ExpiresOn != null) diff --git a/SaxoniteCoreWebOnline/Online/Controllers/AjaxController-UserConfig.cs b/SaxoniteCoreWebOnline/Online/Controllers/AjaxController-UserConfig.cs new file mode 100644 index 0000000..8369237 --- /dev/null +++ b/SaxoniteCoreWebOnline/Online/Controllers/AjaxController-UserConfig.cs @@ -0,0 +1,135 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using Saxonite.Net.Core.Web.Online.Models; +using Saxonite.Net.Core.Web.Base.App; +using Saxonite.Net.Core.Web.Base.Controllers; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using Saxonite.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Base.App; +using Sarand.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Base.Utils; +using Sarand.Net.Standard.Base.Core; +using Sarand.Net.Standard.Base.Dbas; +using Saxonite.Net.Standard.Base.App; +using MailKit; +using Org.BouncyCastle.Asn1.Mozilla; +using Microsoft.Extensions.Primitives; +using Saxonite.Net.Standard.Base.Data; + +namespace Saxonite.Net.Core.Web.Online.Controllers +{ + //======================================================================= + // Online Ajax Controller - User Config. + //======================================================================= + partial class AccountController + { + //------------------------------------------------------------------- + // Data definitions. + + //------------------------------------------------------------------- + // Update User Config. + //------------------------------------------------------------------- + private class AjaxResponse_UserConfigData : AjaxResponse_Data + { + // Construction. + public AjaxResponse_UserConfigData(SaxModel_Online model) : base(model) { } + } + // Ajax request. + [HttpPost] + [Route("UserConfig/Ajax/Update")] + public IActionResult UpdateUserConfig(SaxModel_Online model) + { + String fn = GetType().Name + ".UpdateUserConfig"; + AjaxResponse_UserConfigData responseData = new AjaxResponse_UserConfigData(model); + String messageTitle = Localiser["caption.user.config"]; + + // Validate session and referrer. + if (!ValidReferer) return Forbid(); + if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData); + RefreshModel(model); + + // Record disposable items as they are created so all can be disposed when needed. + using (DisposableCollection disposableItems = new DisposableCollection()) + { + // Retrieve User Config. + Dictionary userConfigs = new Dictionary(); + + // Update user's configuration. + foreach (String key in Request.Form.Keys) + { + StringValues formValue = ""; + Request.Form.TryGetValue(key, out formValue); + SaLogger.Debug(fn + " Form data. Key: " + key + ". Value: " + formValue); + if (key.EqualsCI("HideProfileEligibilityInfo")) + { + SaxUserConfig userConfig = RefreshUserConfig(Sax.UserConfigType.Online_Profile, userConfigs); + if (userConfig != null) + { + disposableItems.Add(userConfig); + SessionData_Online.UserConfig.Profile.Eligibility.HideInfo = StringUtil.ToBool(formValue); + userConfig.ConfigData = SaxConfigData.ProfileData.ToXml(SessionData_Online.UserConfig.Profile); + } + } + } + + // Store configuration. + foreach (SaxUserConfig userConfig in userConfigs.Values) + { + if (!SysId.IsValid(userConfig.Id)) + { + // Add new configuration. + if (!AccountMgr.InsertUserConfig(userConfig, DbUpdateInfo)) + SaLogger.Warn(fn + " Failed to insert User Config: " + AccountMgr.ErrorStateMessage); + } + else + { + // Update existing configuration. + if (!AccountMgr.UpdateUserConfig(userConfig, DbUpdateInfo)) + SaLogger.Warn(fn + " Failed to update User Config: " + AccountMgr.ErrorStateMessage); + } + } + } + + // Complete response. + responseData.Success = true; + return Json(responseData); + } + + //------------------------------------------------------------------- + /// + /// Retrieve the corresponding User Config if previously stored, otherwise create. + /// + private SaxUserConfig RefreshUserConfig(Sax.UserConfigType configType, Dictionary userConfigs) + { + // Check if Config is already in cache. + if (userConfigs.ContainsKey(configType)) return userConfigs.GetValueOrDefault(configType, null); + // Retrieve user config. + SaxUserConfig userConfig = AccountMgr.GetUserConfig(SessionUserAccountId, configType); + if (userConfig == null) + { + // Configuration doesn't currently exist. + userConfig = AccountMgr.CreateUserConfig(SessionUserAccountId, configType); + } + else + { + // User Configuration already exists. + // Refresh configuration in case updated elsewhere. + switch (configType) + { + case Sax.UserConfigType.Online_Profile: + SessionData_Online.UserConfig.Profile = SaxConfigData.ProfileData.FromXml(userConfig.ConfigData); + break; + } + } + userConfigs.Add(userConfig.ConfigType, userConfig); + return userConfig; + } + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaxoniteCoreWebOnline/Online/Controllers/HomeController.cs b/SaxoniteCoreWebOnline/Online/Controllers/HomeController.cs index 58aa4cd..a6da067 100644 --- a/SaxoniteCoreWebOnline/Online/Controllers/HomeController.cs +++ b/SaxoniteCoreWebOnline/Online/Controllers/HomeController.cs @@ -12,6 +12,7 @@ using Sarand.Net.Standard.Base.Bus; using Saxonite.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.App; using Sarand.Net.Standard.Base.Utils; +using Sarand.Net.Standard.Base.Core; namespace Saxonite.Net.Core.Web.Online.Controllers { @@ -43,19 +44,28 @@ namespace Saxonite.Net.Core.Web.Online.Controllers String logSuffix = keepLoggedInParams.GetValidParams().Concat("", " ", "."); if (SysId.IsValid(keepLoggedInParams.UserAccountId)) { - SaxUserAccount userAccount = AccountMgr.GetUserAccountById(keepLoggedInParams.UserAccountId); - if (userAccount != null) + // Record disposable items as they are created so all can be disposed when needed. + using (DisposableCollection disposableItems = new DisposableCollection()) { - if (userAccount.IsStatusActive) + SaxUserAccount userAccount = AccountMgr.GetUserAccountById(keepLoggedInParams.UserAccountId); + if (userAccount != null) { - String errorMessage = ""; - if (SignUserIn(userAccount, AccountMgr.GetRolesForUser(userAccount.Id), true, ref errorMessage)) - SaLogger.Info(fn + " Keep Logged In cookie found." + logSuffix); - else SaLogger.Warn(fn + " Keep Logged In cookie found but failed to sign user in: " + errorMessage + "." + logSuffix); + disposableItems.Add(userAccount); + if (userAccount.IsStatusActive) + { + List userRoles = AccountMgr.GetRolesForUser(userAccount.Id); + disposableItems.AddRange(userRoles); + List userConfigs = AccountMgr.GetConfigsForUser(userAccount.Id); + disposableItems.AddRange(userConfigs); + String errorMessage = ""; + if (SignUserIn(userAccount, userRoles, userConfigs, true, ref errorMessage)) + SaLogger.Info(fn + " Keep Logged In cookie found." + logSuffix); + else SaLogger.Warn(fn + " Keep Logged In cookie found but failed to sign user in: " + errorMessage + "." + logSuffix); + } + else SaLogger.Warn(fn + " Keep Logged In cookie found but UserAccount is not active." + logSuffix); } - else SaLogger.Warn(fn + " Keep Logged In cookie found but UserAccount is not active." + logSuffix); + else SaLogger.Warn(fn + " Keep Logged In cookie found but UserAccount not found." + logSuffix); } - else SaLogger.Warn(fn + " Keep Logged In cookie found but UserAccount not found." + logSuffix); } } diff --git a/SaxoniteCoreWebOnline/Online/Controllers/SaxController_Online.cs b/SaxoniteCoreWebOnline/Online/Controllers/SaxController_Online.cs index f658a93..510b515 100644 --- a/SaxoniteCoreWebOnline/Online/Controllers/SaxController_Online.cs +++ b/SaxoniteCoreWebOnline/Online/Controllers/SaxController_Online.cs @@ -10,6 +10,7 @@ using Saxonite.Net.Core.Web.Base.Controllers; using Saxonite.Net.Core.Web.Online.App; using Saxonite.Net.Standard.Base.App; using Saxonite.Net.Standard.Base.Bus; +using Saxonite.Net.Standard.Base.Data; using System; using System.Collections.Generic; using System.Collections.Specialized; @@ -52,7 +53,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers /// - Open user session - store details against Sesion Data. /// - Set 'Keep logged in' cookie if required. /// - protected bool SignUserIn(SaxUserAccount userAccount, List userRoles, bool keepLoggedIn, ref String errorMessage) + protected bool SignUserIn(SaxUserAccount userAccount, List userRoles, List userConfigs, bool keepLoggedIn, ref String errorMessage) { String fn = GetType().Name + ".SignUserIn"; @@ -90,6 +91,17 @@ namespace Saxonite.Net.Core.Web.Online.Controllers OpenUserSession(SessionContext, userAccount, userRoles); RefreshSessionProfileSports(); + // Refresh User configuration. + foreach (SaxUserConfig userConfig in userConfigs) + { + switch (userConfig.ConfigType) + { + case Sax.UserConfigType.Online_Profile: + SessionData_Online.UserConfig.Profile = SaxConfigData.ProfileData.FromXml(userConfig.ConfigData); + break; + } + } + // Send the 'Keep Logged In' cookie if requested. if (userAccount.KeepLoggedIn) SetKeepLoggedInCookie(); diff --git a/SaxoniteCoreWebOnline/Online/Controllers/SecurityController-Ajax.cs b/SaxoniteCoreWebOnline/Online/Controllers/SecurityController-Ajax.cs index de829c6..72c1d04 100644 --- a/SaxoniteCoreWebOnline/Online/Controllers/SecurityController-Ajax.cs +++ b/SaxoniteCoreWebOnline/Online/Controllers/SecurityController-Ajax.cs @@ -49,19 +49,26 @@ namespace Saxonite.Net.Core.Web.Online.Controllers model.ValidateSignInData(responseData); if (responseData.HasControlErrors()) return Json(responseData); + // Record disposable items as they are created so all can be disposed when needed. + using (DisposableCollection disposableItems = new DisposableCollection()) + { - // Get user account. - SaxUserAccount userAccount = GetUserAccountForSignin(model, responseData); - if (responseData.HasControlErrors()) - return Json(responseData); + // Get user account. + SaxUserAccount userAccount = GetUserAccountForSignin(model, responseData); + disposableItems.Add(userAccount); + if (responseData.HasControlErrors()) + return Json(responseData); - String errorMessage = ""; - if (!SignUserIn(userAccount, AccountMgr.GetRolesForUser(userAccount.Id), model.KeepMeSignedIn, ref errorMessage)) - return Json(responseData.SetControlError(nameof(model.EmailAddress), errorMessage)); - - // Construct response. + List userRoles = AccountMgr.GetRolesForUser(userAccount.Id); + disposableItems.AddRange(userRoles); + List userConfigs = AccountMgr.GetConfigsForUser(userAccount.Id); + disposableItems.AddRange(userConfigs); + String errorMessage = ""; + if (!SignUserIn(userAccount, userRoles, userConfigs, model.KeepMeSignedIn, ref errorMessage)) + return Json(responseData.SetControlError(nameof(model.EmailAddress), errorMessage)); + } + // Complete response. responseData.Success = SessionData_Online?.ValidUserSession ?? false; - return Json(responseData); } diff --git a/SaxoniteCoreWebOnline/Online/Models/Model_Account.cs b/SaxoniteCoreWebOnline/Online/Models/Model_Account.cs index 433d0aa..03db51f 100644 --- a/SaxoniteCoreWebOnline/Online/Models/Model_Account.cs +++ b/SaxoniteCoreWebOnline/Online/Models/Model_Account.cs @@ -30,6 +30,7 @@ namespace Saxonite.Net.Core.Web.Online.Models AdditionalFiles_CSS.Add("css/sax-account.css"); AdditionalFiles_JS.Add("js/sax-account.js"); AdditionalFiles_JS.Add("js/sax-pro-usr.js"); + AdditionalFiles_JS.Add("js/sax-pro-cfg.js"); } //------------------------------------------------------------------- diff --git a/SaxoniteCoreWebOnline/SaxoniteCoreWebOnline.csproj b/SaxoniteCoreWebOnline/SaxoniteCoreWebOnline.csproj index 68de272..080d053 100644 --- a/SaxoniteCoreWebOnline/SaxoniteCoreWebOnline.csproj +++ b/SaxoniteCoreWebOnline/SaxoniteCoreWebOnline.csproj @@ -25,6 +25,7 @@ + diff --git a/SaxoniteCoreWebOnline/Views/Account/Profile-Contact.cshtml b/SaxoniteCoreWebOnline/Views/Account/Profile-Contact.cshtml index 5d9608c..6902f97 100644 --- a/SaxoniteCoreWebOnline/Views/Account/Profile-Contact.cshtml +++ b/SaxoniteCoreWebOnline/Views/Account/Profile-Contact.cshtml @@ -163,7 +163,7 @@
- +
diff --git a/SaxoniteCoreWebOnline/Views/Account/Profile-Eligibility.cshtml b/SaxoniteCoreWebOnline/Views/Account/Profile-Eligibility.cshtml index 6fa4acf..5544b19 100644 --- a/SaxoniteCoreWebOnline/Views/Account/Profile-Eligibility.cshtml +++ b/SaxoniteCoreWebOnline/Views/Account/Profile-Eligibility.cshtml @@ -3,166 +3,172 @@
-
+
-
-
-
@Localiser["caption.my.eligibility"]
-
- @* Burger menu *@ - - @* Filter item templates *@ -
- @* Burger dropdown item template - ul is ignored *@ -
    -
  • ...
  • -
-
-
-
-
+
+
+
@Localiser["caption.my.eligibility"]
+
+ @* Burger menu *@ + + @* Filter item templates *@ +
+ @* Burger dropdown item template - ul is ignored *@ +
    +
  • ...
  • +
+
+
+
+
-
- @* User Eligibility list. *@ -
-
+
+
+ +
+ @* User Eligibility list. *@ +
+
+
- @* Item templates *@ -
- @* User Eligibility template *@ -
-
-
-
- @* Burger menu *@ - -
-
-
-
-
-
@Localiser["label.expires"]: 
-
-
-
- @* User Eligibility Burger dropdown template - ul is ignored *@ -
    -
  • ...
  • -
-
+ @* Item templates *@ +
+ @* User Eligibility template *@ +
+
+
+
+ @* Burger menu *@ + +
+
+
+
+
+
@Localiser["label.expires"]: 
+
+
+
+ @* User Eligibility Burger dropdown template - ul is ignored *@ +
    +
  • ...
  • +
+
- @* User Eligibility Id form. *@ - @using (Html.BeginForm(FormMethod.Post, new { @id = "frmUserEligibilityId", @class = "sax-form", @onSubmit = "return false;" })) - { - @Html.Hidden("Eligibility.Id", "", new { @id = "", @class = "UserEligibilityId sax-hidden" }) - } + @* User Eligibility Id form. *@ + @using (Html.BeginForm(FormMethod.Post, new { @id = "frmUserEligibilityId", @class = "sax-form", @onSubmit = "return false;" })) + { + @Html.Hidden("Eligibility.Id", "", new { @id = "", @class = "UserEligibilityId sax-hidden" }) + } -
+
- @* User Eligibility dialog *@ -
+ @* User Eligibility dialog *@ +
-
- @using (Html.BeginForm(FormMethod.Post, new { @id = "frmUserEligibility", @class = "sax-form", @onSubmit = "return false;" })) - { - - +
+ @using (Html.BeginForm(FormMethod.Post, new { @id = "frmUserEligibility", @class = "sax-form", @onSubmit = "return false;" })) + { + + - @* Region *@ -
-
-
-
- -
-
-
-
- @Html.Hidden("Eligibility.RegionId", "", new { @id = "ifEligibilityRegionId", @class = "EligibilityRegionId" }) -
-
-
-
-
-
-
+ @* Region *@ +
+
+
+
+ +
+
+
+
+ @Html.Hidden("Eligibility.RegionId", "", new { @id = "ifEligibilityRegionId", @class = "EligibilityRegionId" }) +
+
+
+
+
+
+
- @* Eligibility Type *@ -
-
-
-
- -
-
-
-
- @Html.DropDownList("Eligibility.Type", Model.EligibilityTypesForSelect, "", new { @id = "ifEligibilityType", @class = "EligibilityType sax-select", @readonly = "readonly", @maxlength = @Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.UserAccount_EmailAddress) }) -
-
-
-
-
+ @* Eligibility Type *@ +
+
+
+
+ +
+
+
+
+ @Html.DropDownList("Eligibility.Type", Model.EligibilityTypesForSelect, "", new { @id = "ifEligibilityType", @class = "EligibilityType sax-select", @readonly = "readonly", @maxlength = @Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.UserAccount_EmailAddress) }) +
+
+
+
+
- @* Info *@ -
-
-
-
- -
-
-
-
- @Html.TextArea("Eligibility.Info", "", new { @id = "ifEligibilityInfo", @class = "EligibilityInfo sax-textarea", @rows = 4, @maxlength = @Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.UserEligibility_Info) }) -
-
-
-
-
+ @* Info *@ +
+
+
+
+ +
+
+
+
+ @Html.TextArea("Eligibility.Info", "", new { @id = "ifEligibilityInfo", @class = "EligibilityInfo sax-textarea", @rows = 4, @maxlength = @Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.UserEligibility_Info) }) +
+
+
+
+
- @* Expiry *@ -
-
-
-
- -
-
-
-
-
-
 @Localiser["label.expires.on"]
-
@Html.TextBox("Eligibility.ExpiresOn", "", new { @id = "ifEligibilityExpiresOn", @class = "sax-input sax-calendar EligibilityExpiresOn", @readonly = "readonly" })
-
-
-
-
-
-
+ @* Expiry *@ +
+
+
+
+ +
+
+
+
+
+
 @Localiser["label.expires.on"]
+
@Html.TextBox("Eligibility.ExpiresOn", "", new { @id = "ifEligibilityExpiresOn", @class = "sax-input sax-calendar EligibilityExpiresOn", @readonly = "readonly" })
+
+
+
+
+
+
- } -
-
+ } +
+
diff --git a/SaxoniteCoreWebOnline/Views/Common/SportContact.cshtml b/SaxoniteCoreWebOnline/Views/Common/SportContact.cshtml new file mode 100644 index 0000000..d376cda --- /dev/null +++ b/SaxoniteCoreWebOnline/Views/Common/SportContact.cshtml @@ -0,0 +1,58 @@ +@model SaxModel_Online +@inject SaxLocaliser Localiser + +@if (!Model.RegisterView("Views/Common/SportSelect")) return; + + + + + +
+ + @* Filter *@ +
+ +
+ + @* Available codes *@ +
+ +
+ +
+ + @* Code selection *@ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + @* Selected codes *@ +
+ +
+ +
+
+ +
+ +
+
+
+
+
+ +
diff --git a/SaxoniteCoreWebOnline/wwwroot/css/sax-data.css b/SaxoniteCoreWebOnline/wwwroot/css/sax-data.css index 1619bf9..33d78f0 100644 --- a/SaxoniteCoreWebOnline/wwwroot/css/sax-data.css +++ b/SaxoniteCoreWebOnline/wwwroot/css/sax-data.css @@ -124,6 +124,11 @@ background-image: url('../img/action/refresh24.png'); } +.sax-header ul.nav.sax-burger ul.sax-dropdown-menu li.sax-action.sax-dropdown-item.sax-info +{ + background-image: url('../img/action/info24.png'); +} + .sax-header ul.nav.sax-burger ul.sax-dropdown-menu li.sax-action.sax-dropdown-item.sax-add { background-image: url('../img/action/add24.png'); @@ -203,6 +208,31 @@ { } +/* Information tip*/ + +.sax-panel-results .sax-panel-infotip +{ + width: 100%; + margin-top: 4px; + padding: 4px 4px 4px 8px; + font-size: 14px; + color: #606060; + background-color: #fff; + border: 1px solid #989898; + border-bottom-right-radius: 8px; + overflow: auto; +} + +.sax-panel-results .sax-panel-infotip .sax-close +{ + float: right; + width: 16px; + height: 16px; + margin-left: 8px; + background: url("../img/action/delete16.png"); + cursor:pointer; +} + /* Messages */ .sax-panel-results .sax-panel-messages .sax-message @@ -346,7 +376,7 @@ { max-width: 48px; max-height: 48px; - margin:4px 4px 2px 0; + margin: 4px 4px 2px 0; border-radius: 2px; } diff --git a/SaxoniteCoreWebOnline/wwwroot/css/sax-main.css b/SaxoniteCoreWebOnline/wwwroot/css/sax-main.css index 7c2bcbc..ba2cab3 100644 --- a/SaxoniteCoreWebOnline/wwwroot/css/sax-main.css +++ b/SaxoniteCoreWebOnline/wwwroot/css/sax-main.css @@ -362,10 +362,17 @@ a:focus text-align: right; } +div.ui-dialog.center-buttons .ui-dialog-buttonpane .ui-dialog-buttonset +{ + float: none; + margin: 0 auto; + display: table; +} + .ui-dialog .ui-dialog-buttonpane button { min-width: 60px; - margin:4px; + margin: 4px; padding: 6px 16px 4px 16px; color: #fff; background-color: #606060; diff --git a/SaxoniteCoreWebOnline/wwwroot/css/sax-spt-cnt.css b/SaxoniteCoreWebOnline/wwwroot/css/sax-spt-cnt.css new file mode 100644 index 0000000..e0ec9f2 --- /dev/null +++ b/SaxoniteCoreWebOnline/wwwroot/css/sax-spt-cnt.css @@ -0,0 +1,5 @@ +/* + Sport Contact stylesheet. +*/ + +/* The End */ diff --git a/SaxoniteCoreWebOnline/wwwroot/js/sax-pro-cfg.js b/SaxoniteCoreWebOnline/wwwroot/js/sax-pro-cfg.js new file mode 100644 index 0000000..abce39c --- /dev/null +++ b/SaxoniteCoreWebOnline/wwwroot/js/sax-pro-cfg.js @@ -0,0 +1,20 @@ +/* + * User Config scripts. + */ +(function (win, doc, undef) +{ + //-------------------------------------------------------------- + "use strict"; + let uc = sax.UserConfig = { fn: {}, ajax: {}, data: {}, $pnl: {}, $frm: {}, $dlg: {} }; + //-------------------------------------------------------------- + sax.updateUserConfigOption = uc.fn.updateConfigItem = function (key, val) + { + let formData = new FormData(); + formData.append("__RequestVerificationToken", $('#frmNavigate input[name="__RequestVerificationToken"]').val()); + formData.append(key, val); + sax.doAjaxRequest({ url: sax.url.base + 'UserConfig/Ajax/Update', formData: formData }, 50); + } + //-------------------------------------------------------------- +}(window, window.document)); + +/* The End */ \ No newline at end of file diff --git a/SaxoniteCoreWebOnline/wwwroot/js/sax-pro-elg.js b/SaxoniteCoreWebOnline/wwwroot/js/sax-pro-elg.js index 6481fe5..6cd7562 100644 --- a/SaxoniteCoreWebOnline/wwwroot/js/sax-pro-elg.js +++ b/SaxoniteCoreWebOnline/wwwroot/js/sax-pro-elg.js @@ -12,6 +12,7 @@ sax.refreshProfileEligibilityInfo = function (delay) { ue.init(); + $pnl.infoTip.hide().find('.sax-info').text(sax.msg.eligibilityInfo); $pnl.usrElg.removeClass('sax-edit').addClass('sax-populating'); $('.sax-property', $pnl.usrElg).hide(); sax.showDataRefreshingMsg($pnl.usrElg); @@ -30,10 +31,11 @@ ue.clearItem(); if (!response || !response.success) return; ue.data.types = response.types; - $('.sax-message', $pnl.usrElg).stop(true, false).fadeOut(200).empty(); + $pnl.infoTip.toggle(!response.config.hideInfo); + $('.sax-panel-messages', $pnl.results).stop(true, false).hide(); let items = response.eligibilities; if (!items) return; - let $items = $('.sax-panel-results.UserEligibilities', $pnl.usrElg).empty(); + let $items = $('.sax-panel-item-list', $pnl.results).empty(); for (let itemIdx = 0; itemIdx < items.length; itemIdx++) $items.append(ue.populateItem(ue.getItemTemplate(), items[itemIdx])); $items.show(); @@ -45,7 +47,7 @@ if (!item) return; $item.prop('id', item.id); let fnUpd = function (evt) { ue.updateItem(item, $item); } - let fnRmv = function (evt) { ue.removeItem(item,$item); } + let fnRmv = function (evt) { ue.removeItem(item, $item); } $('.sax-header .sax-caption', $item).on('click', fnUpd); $('.sax-content', $item).on('dblclick', fnUpd); @@ -86,9 +88,26 @@ return $opt.find('div.sax-label').text(lbl).end().on('click', fn).addClass(cls); } //-------------------------------------------------------------- + ue.data.hideInfoKey = 'HideProfileEligibilityInfo'; + ue.showInfoTip = function () + { + sax.debug('showInfoTip'); + $pnl.infoTip.show(); + sax.updateUserConfigOption(ue.data.hideInfoKey, 0); + } + ue.hideInfoTip = function () + { + $pnl.infoTip.hide(); + sax.updateUserConfigOption(ue.data.hideInfoKey, 1); + } + //-------------------------------------------------------------- ue.addItem = function () { ue.clearItem(); + ue.showEligibilityDialog(); + } + ue.showEligibilityDialog = function () + { sax.openDialog($dlg.usrElg.dialog('option', 'title', sax.dlg.title.addUserEligibility), 640, 480); } ue.clearItem = function () @@ -98,7 +117,7 @@ let frm = $frm.usrElg; $('.UserEligibilityId,.EligibilityExists,.EligibilityRegionId,input.sax-input,textarea.sax-textarea,select.sax-select', frm).val(''); $('.SelectEligibilityRegion', frm).show(); - $('.sax-select.EligibilityType', frm).prop('disabled', false); + ue.$selType.prop('disabled', false).change(); ue.$chkExpires.prop("checked", false); sax.clearControlErrors(frm); } @@ -113,7 +132,7 @@ } ue.doUpdateItem = function (response) { - sax.debug('doUpdateItem', response); + //sax.debug('doUpdateItem', response); if (!response.success) return; ue.clearItem(); let frm = $frm.usrElg; @@ -122,19 +141,19 @@ ue.$hdnExists.val(1); $('.EligibilityRegionId', frm).val(item.regionId); $('.sax-input.EligibilityRegionName', frm).val(item.regionName); - $('.SelectEligibilityRegion', frm).hide(); - ue.$selType.val(item.eligibilityType).prop('disabled', true).change(); + //$('.SelectEligibilityRegion', frm).hide(); + ue.$selType.val(item.eligibilityType);//.prop('disabled', true).change(); $('.sax-textarea.EligibilityInfo', frm).val(item.info); ue.$chkExpires.prop("checked", !!item.expiresOnFrm); ue.$dpExpiresOn.val(item.expiresOnFrm); - sax.openDialog($dlg.usrElg.dialog('option', 'title', sax.dlg.title.updateUserEligibility), 640, 480); + ue.showEligibilityDialog(); } //-------------------------------------------------------------- ue.selectEligibilityRegion = function () { //sax.debug('selectEligibilityRegion'); let frm = $frm.usrElg; - if (ue.$hdnExists.val()) return; + //if (ue.$hdnExists.val()) return; sax.mdl.selectRegion.fn.selectRegion({ caption: sax.dlg.title.selectRegion, regionId: $('#ifEligibilityRegionId', frm).val(), fnCallback: ue.storeEligibilityRegion }) } ue.storeEligibilityRegion = function (eligibility) @@ -186,7 +205,7 @@ //-------------------------------------------------------------- ue.removeItem = function (item, $item) { - sax.debug('removeItem',item); + sax.debug('removeItem', item); ue.data.item = item; ue.data.$item = $item; let fn = function () @@ -209,7 +228,10 @@ { if ($pnl.usrElg) return; $pnl.usrElg = $('.sax-panel-section.ProfileEligibility'); - $('.sax-action.sax-add', $pnl.usrElg).on('click', function (evt) { ue.addItem(); }); + $pnl.usrElg.on('click', '.sax-action.sax-add', function (evt) { ue.addItem(); }); + $pnl.usrElg.on('click', '.sax-action.sax-info', function (evt) { ue.showInfoTip(); }); + $pnl.results = $('.sax-panel-results', $pnl.usrElg); + $pnl.infoTip = $('.sax-panel-infotip', $pnl.results).on('click', '.sax-close', function (evt) { ue.hideInfoTip(); }); $frm.usrElgId = $('#frmUserEligibilityId', $pnl.usrElg); var opt = sax.dlgOpts(); diff --git a/SaxoniteCoreWebOnline/wwwroot/js/sax-pro-usr.js b/SaxoniteCoreWebOnline/wwwroot/js/sax-pro-usr.js index 3a6a379..7cd232f 100644 --- a/SaxoniteCoreWebOnline/wwwroot/js/sax-pro-usr.js +++ b/SaxoniteCoreWebOnline/wwwroot/js/sax-pro-usr.js @@ -31,14 +31,15 @@ sax.onRefreshProfileContactInfo = function (response) { //sax.debug('onRefreshProfileContactInfo', response); - if (!response || !response.success || !response.contact) return; + if (!response || !response.success) return; + let item = response.contact || {}; $('.sax-panel-section').slideDown(750); $('.sax-message', $pnl.proCon).stop(true, false).fadeOut(200).empty(); $('.sax-value', $pnl.proConInf).empty(); - sax.refreshInfo($pnl.proConInf, 'AccountEmailAddress', response.contact.emailAddress); - sax.refreshInfo($pnl.proConInf, 'AccountName', response.contact.displayName); - sax.refreshInfo($pnl.proConInf, 'AccountLocation', response.contact.locationCaption); - $('img.AccountContact', $pnl.proConInf).prop('src', 'Image/Account/Contact/Profile?' + (new Date()).getTime()); + sax.refreshInfo($pnl.proConInf, 'AccountEmailAddress', item.emailAddress); + sax.refreshInfo($pnl.proConInf, 'AccountName', item.displayName); + sax.refreshInfo($pnl.proConInf, 'AccountLocation', item.locationCaption); + $('img.AccountContact', $pnl.proConInf).prop('src', item.hasImage ? 'Image/Account/Contact/Profile?' + (new Date()).getTime() : '').toggle(!!item.hasImage); sax.showNoInfoMsg($pnl.proConInf); $pnl.proCon.removeClass('sax-populating'); } @@ -49,27 +50,28 @@ sax.data.genders = response.genders; sax.data.months = response.months; sax.data.imageContentTypes = response.imageContentTypes; + let item = response.contact || {}; $('.sax-message', $pnl.proCon).stop(true, false).fadeOut(200).empty(); - sax.refreshInput($pnl.proConFrm, 'AccountEmailAddress', response.contact.emailAddress); - sax.refreshSelect($pnl.proConFrm, 'AccountTitle', response.contact.title); - sax.refreshInput($pnl.proConFrm, 'AccountFirstName', response.contact.firstName); - sax.refreshInput($pnl.proConFrm, 'AccountLastName', response.contact.lastName); - sax.refreshTextArea($pnl.proConFrm, 'AccountAbout', response.contact.about); + sax.refreshInput($pnl.proConFrm, 'AccountEmailAddress', item.emailAddress); + sax.refreshSelect($pnl.proConFrm, 'AccountTitle', item.title); + sax.refreshInput($pnl.proConFrm, 'AccountFirstName', item.firstName); + sax.refreshInput($pnl.proConFrm, 'AccountLastName', item.lastName); + sax.refreshTextArea($pnl.proConFrm, 'AccountAbout', item.about); let $selGender = $('#cbAccountGender'); if (response.genders && response.genders.length) sax.populateSelectCodeDesc($('#cbAccountGender'), response.genders); - sax.refreshSelect($pnl.proConFrm, 'AccountGender', response.contact.gender || ''); + sax.refreshSelect($pnl.proConFrm, 'AccountGender', item.gender || ''); sax.refreshDob(); - sax.refreshSelect($pnl.proConFrm, 'AccountDobYear', response.contact.dobYear); + sax.refreshSelect($pnl.proConFrm, 'AccountDobYear', item.dobYear); sax.refreshDob(); - sax.refreshSelect($pnl.proConFrm, 'AccountDobMonth', response.contact.dobMonth); + sax.refreshSelect($pnl.proConFrm, 'AccountDobMonth', item.dobMonth); sax.refreshDob(); - sax.refreshSelect($pnl.proConFrm, 'AccountDobDay', response.contact.dobDay); - sax.refreshInput($pnl.proConFrm, 'AccountRegionIdCountry', response.contact.regionIdCountry); - sax.refreshInput($pnl.proConFrm, 'AccountRegionCaptionCountry', response.contact.regionCaptionCountry); - sax.refreshInput($pnl.proConFrm, 'AccountRegionIdProvince', response.contact.regionIdProvince); - sax.refreshInput($pnl.proConFrm, 'AccountRegionCaptionProvince', response.contact.regionCaptionProvince); - $('img.AccountContact', $pnl.proConFrm).prop('src', 'Image/Account/Contact/Profile?' + (new Date()).getTime()); + sax.refreshSelect($pnl.proConFrm, 'AccountDobDay', item.dobDay); + sax.refreshInput($pnl.proConFrm, 'AccountRegionIdCountry', item.regionIdCountry); + sax.refreshInput($pnl.proConFrm, 'AccountRegionCaptionCountry', item.regionCaptionCountry); + sax.refreshInput($pnl.proConFrm, 'AccountRegionIdProvince', item.regionIdProvince); + sax.refreshInput($pnl.proConFrm, 'AccountRegionCaptionProvince', item.regionCaptionProvince); + $('img.AccountContact', $pnl.proConFrm).prop('src', item.hasImage ? 'Image/Account/Contact/Profile?' + (new Date()).getTime() : ''); $('.sax-panel-section').slideUp(750, function () { $pnl.proCon.addClass('sax-edit').slideDown(750); }); } sax.storeProfileContact = function () @@ -149,7 +151,7 @@ { //sax.debug('onDropContactImageFile', file, context); if (file.size > sax.maxProfileImageSize) return sax.doAlert(sax.dlg.title.imageUpload, sax.msg.uploadFileSizeMax.format(sax.formatFileSize(sax.maxProfileImageSize))); - if ((sax.data.imageContentTypes||[]).indexOf(file.type) < 0) return sax.doAlert(sax.dlg.title.imageUpload, sax.msg.uploadFileTypeInvalid.format(sax.getFileType(file))); + if ((sax.data.imageContentTypes || []).indexOf(file.type) < 0) return sax.doAlert(sax.dlg.title.imageUpload, sax.msg.uploadFileTypeInvalid.format(sax.getFileType(file))); $(".UploadMessage", context).text(sax.msg.uploadingFile.format(file.name)); $('img.ContactImageUploadProgress', context).fadeIn(200); sax.clearControlError($pnl.contactImageDrag); diff --git a/SaxoniteCoreWebOnline/wwwroot/js/sax-spt-cnt.js b/SaxoniteCoreWebOnline/wwwroot/js/sax-spt-cnt.js new file mode 100644 index 0000000..255baf6 --- /dev/null +++ b/SaxoniteCoreWebOnline/wwwroot/js/sax-spt-cnt.js @@ -0,0 +1,46 @@ +/* + * Sport contact. + */ + +(function (win, doc, undef) +{ + //-------------------------------------------------------------- + "use strict"; + let sc = sax.mdl.sportContact = { ajax: {}, data: {}, $pnl: {}, $dlg: {}, $frm: {} }; + //-------------------------------------------------------------- + /* + * Sport Contact config: + * - caption - dialog title. + * - contact: + * - type + * - name + * - email + * - phone + * - typesUsed + * - fnCallback - method to call on completion to store details. + */ + sax.showSportContact = function (cfg) + { + sc.fn.init(); + sc.data.cfg = cfg; + sax.openDialog(sc.$dlg.dialog('option', { title: sc.data.cfg.caption || 'Select Sport' }), sc.data.cfg.width || 400, sc.data.cfg.height || 800); + } + //-------------------------------------------------------------- + sc.fn.displayContact = function () + { + } + //-------------------------------------------------------------- + sc.fn.init = function () + { + if (sc.$dlg.sptCnt) return; + var opt = sax.dlgOpts(); + opt.open = function (evt, ui) { sc.fn.onDlgSize(); }; + opt.resize = function (evt, ui) { sc.fn.onDlgSize(); }; + opt.buttons[sax.dlg.btn.ok] = function () { sc.fn.storeSelectSport(); }; + opt.buttons[sax.dlg.btn.cancel] = function () { sc.fn.cleanUp(); $(this).dialog('close'); }; + sc.$dlg.sptCnt = $('#dlgSportContact').dialog(opt); + } + //-------------------------------------------------------------- +}(window, window.document)); + +/* The End */ \ No newline at end of file diff --git a/SaxoniteStandardBase/Base/App/Sax-Version.cs b/SaxoniteStandardBase/Base/App/Sax-Version.cs index e94fdf6..9636662 100644 --- a/SaxoniteStandardBase/Base/App/Sax-Version.cs +++ b/SaxoniteStandardBase/Base/App/Sax-Version.cs @@ -18,7 +18,7 @@ namespace Saxonite.Net.Standard.Base.App //------------------------------------------------------------------- public static class Version { - private static String version { get; } = "1.2.9.1"; + private static String version { get; } = "1.2.9.2"; // Retrieve version. public static String GetFullVersion () { return version; } public static String GetAppVersion () diff --git a/SaxoniteStandardBase/Base/App/Sax.cs b/SaxoniteStandardBase/Base/App/Sax.cs index 6895b72..ef98faf 100644 --- a/SaxoniteStandardBase/Base/App/Sax.cs +++ b/SaxoniteStandardBase/Base/App/Sax.cs @@ -20,6 +20,7 @@ namespace Saxonite.Net.Standard.Base.App DataItemType, Gender, SportSpecialityLabel, + SportContactType, SportParticipation, SportOfficiating, RegionType, @@ -138,6 +139,14 @@ namespace Saxonite.Net.Standard.Base.App Visa = 210, } + //------------------------------------------------------------------- + /// User Config + public enum UserConfigType + { + /* Do not change the values - tied to database. */ + Online_Profile = 100, + } + //------------------------------------------------------------------- /// User roles public enum UserRole @@ -159,6 +168,17 @@ namespace Saxonite.Net.Standard.Base.App NotRelevant = 90, } + //------------------------------------------------------------------- + /// Sport Contact Type + public enum SportContactType + { + Unknown = 0, + /* Do not change the values/codes - tied to database. */ + Coach = 100, + Manager = 200, + Agent = 300, + } + //------------------------------------------------------------------- /// Sport Participation public enum SportParticipation diff --git a/SaxoniteStandardBase/Base/App/SaxDbDfn_Core.cs b/SaxoniteStandardBase/Base/App/SaxDbDfn_Core.cs index 854615f..01a9ea4 100644 --- a/SaxoniteStandardBase/Base/App/SaxDbDfn_Core.cs +++ b/SaxoniteStandardBase/Base/App/SaxDbDfn_Core.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 13-Oct-2022 09:38:45 +// Code generated by Sarand Database Utilities Tue 15-Nov-2022 13:33:16 //--------------------------------------------------------------------------- namespace Saxonite.Base.App { @@ -31,6 +31,7 @@ namespace Saxonite.Base.App Sport, UserAccount, UserActivity, + UserConfig, UserEligibility, UserOnline, UserOrganisation, @@ -270,6 +271,7 @@ namespace Saxonite.Base.App UserAccount_PhoneMobile, UserAccount_PhoneAlt, UserAccount_Gender, + UserAccount_GenderOther, UserAccount_DateOfBirthDay, UserAccount_DateOfBirthMonth, UserAccount_DateOfBirthYear, @@ -314,6 +316,12 @@ namespace Saxonite.Base.App UserActivity_UpdateOn, UserActivity_UpdateBy, UserActivity_UpdateHost, + UserConfig_Id, + UserConfig_UserAccountId, + UserConfig_ConfigType, + UserConfig_ConfigData, + UserConfig_CreateOn, + UserConfig_UpdateOn, UserEligibility_Id, UserEligibility_UserAccountId, UserEligibility_RegionId, @@ -411,8 +419,8 @@ namespace Saxonite.Base.App //------------------------------------------------------------------- // Data members. - private static readonly int tableCount = 21; - private static readonly int columnCount = 362; + private static readonly int tableCount = 22; + private static readonly int columnCount = 369; private static ulong maxTextLen = 0; //------------------------------------------------------------------- @@ -572,6 +580,7 @@ namespace Saxonite.Base.App "Sport", "UserAccount", "UserActivity", + "UserConfig", "UserEligibility", "UserOnline", "UserOrganisation", @@ -830,6 +839,7 @@ namespace Saxonite.Base.App new ColumnDfn(13,"PhoneMobile",0,-9,false,50), new ColumnDfn(13,"PhoneAlt",0,-9,false,50), new ColumnDfn(13,"Gender",2,-6,false,3), + new ColumnDfn(13,"GenderOther",0,-9,false,50), new ColumnDfn(13,"DateOfBirthDay",2,-6,false,3), new ColumnDfn(13,"DateOfBirthMonth",2,-6,false,3), new ColumnDfn(13,"DateOfBirthYear",3,5,false,5), @@ -876,42 +886,33 @@ namespace Saxonite.Base.App new ColumnDfn(14,"UpdateHost",0,12,false,100), new ColumnDfn(15,"Id",5,-5,true,19), new ColumnDfn(15,"UserAccountId",4,4,false,10), - new ColumnDfn(15,"RegionId",4,4,false,10), - new ColumnDfn(15,"EligibilityType",3,5,false,5), - new ColumnDfn(15,"Info",0,-9,false,2000), - new ColumnDfn(15,"ExpiresOn",9,93,false,16), - new ColumnDfn(15,"Notes",0,-9,false,2000), - new ColumnDfn(15,"Flags",3,5,false,5), - new ColumnDfn(15,"Status",0,12,false,3), + new ColumnDfn(15,"ConfigType",3,5,false,5), + new ColumnDfn(15,"ConfigData",0,-9,false,0), new ColumnDfn(15,"CreateOn",9,93,false,23), - new ColumnDfn(15,"CreateBy",4,4,false,10), - new ColumnDfn(15,"CreateHost",0,12,false,100), new ColumnDfn(15,"UpdateOn",9,93,false,23), - new ColumnDfn(15,"UpdateBy",4,4,false,10), - new ColumnDfn(15,"UpdateHost",0,12,false,100), + new ColumnDfn(16,"Id",5,-5,true,19), new ColumnDfn(16,"UserAccountId",4,4,false,10), - new ColumnDfn(16,"OnlineAt",9,93,false,16), - new ColumnDfn(17,"Id",5,-5,true,19), + new ColumnDfn(16,"RegionId",4,4,false,10), + new ColumnDfn(16,"EligibilityType",3,5,false,5), + new ColumnDfn(16,"Info",0,-9,false,2000), + new ColumnDfn(16,"ExpiresOn",9,93,false,16), + new ColumnDfn(16,"Notes",0,-9,false,2000), + new ColumnDfn(16,"Flags",3,5,false,5), + new ColumnDfn(16,"Status",0,12,false,3), + new ColumnDfn(16,"CreateOn",9,93,false,23), + new ColumnDfn(16,"CreateBy",4,4,false,10), + new ColumnDfn(16,"CreateHost",0,12,false,100), + new ColumnDfn(16,"UpdateOn",9,93,false,23), + new ColumnDfn(16,"UpdateBy",4,4,false,10), + new ColumnDfn(16,"UpdateHost",0,12,false,100), new ColumnDfn(17,"UserAccountId",4,4,false,10), - new ColumnDfn(17,"OrganisationId",4,4,false,10), - new ColumnDfn(17,"OrganisationRoleCodes",0,12,false,256), - new ColumnDfn(17,"OrganisationRoleCount",2,-6,false,3), - new ColumnDfn(17,"AdminComment",0,-9,false,2000), - new ColumnDfn(17,"Notes",0,-9,false,2000), - new ColumnDfn(17,"Flags",3,5,false,5), - new ColumnDfn(17,"Status",0,12,false,3), - new ColumnDfn(17,"CreateOn",9,93,false,23), - new ColumnDfn(17,"CreateBy",4,4,false,10), - new ColumnDfn(17,"CreateHost",0,12,false,100), - new ColumnDfn(17,"UpdateOn",9,93,false,23), - new ColumnDfn(17,"UpdateBy",4,4,false,10), - new ColumnDfn(17,"UpdateHost",0,12,false,100), + new ColumnDfn(17,"OnlineAt",9,93,false,16), new ColumnDfn(18,"Id",5,-5,true,19), new ColumnDfn(18,"UserAccountId",4,4,false,10), - new ColumnDfn(18,"UserRoleCode",0,12,false,16), - new ColumnDfn(18,"LastLoginAt",9,93,false,16), - new ColumnDfn(18,"LastInvalidLoginAt",9,93,false,16), - new ColumnDfn(18,"InvalidLoginCount",3,5,false,5), + new ColumnDfn(18,"OrganisationId",4,4,false,10), + new ColumnDfn(18,"OrganisationRoleCodes",0,12,false,256), + new ColumnDfn(18,"OrganisationRoleCount",2,-6,false,3), + new ColumnDfn(18,"AdminComment",0,-9,false,2000), new ColumnDfn(18,"Notes",0,-9,false,2000), new ColumnDfn(18,"Flags",3,5,false,5), new ColumnDfn(18,"Status",0,12,false,3), @@ -921,43 +922,34 @@ namespace Saxonite.Base.App new ColumnDfn(18,"UpdateOn",9,93,false,23), new ColumnDfn(18,"UpdateBy",4,4,false,10), new ColumnDfn(18,"UpdateHost",0,12,false,100), + new ColumnDfn(19,"Id",5,-5,true,19), new ColumnDfn(19,"UserAccountId",4,4,false,10), - new ColumnDfn(19,"ActivityIndexIds",0,-9,false,0), - new ColumnDfn(19,"UserSessionData",0,-9,false,0), + new ColumnDfn(19,"UserRoleCode",0,12,false,16), + new ColumnDfn(19,"LastLoginAt",9,93,false,16), + new ColumnDfn(19,"LastInvalidLoginAt",9,93,false,16), + new ColumnDfn(19,"InvalidLoginCount",3,5,false,5), + new ColumnDfn(19,"Notes",0,-9,false,2000), new ColumnDfn(19,"Flags",3,5,false,5), + new ColumnDfn(19,"Status",0,12,false,3), new ColumnDfn(19,"CreateOn",9,93,false,23), + new ColumnDfn(19,"CreateBy",4,4,false,10), + new ColumnDfn(19,"CreateHost",0,12,false,100), new ColumnDfn(19,"UpdateOn",9,93,false,23), - new ColumnDfn(20,"Id",5,-5,true,19), + new ColumnDfn(19,"UpdateBy",4,4,false,10), + new ColumnDfn(19,"UpdateHost",0,12,false,100), new ColumnDfn(20,"UserAccountId",4,4,false,10), - new ColumnDfn(20,"SportId",4,4,false,10), - new ColumnDfn(20,"About",0,-9,false,2000), - new ColumnDfn(20,"Participation",3,5,false,5), - new ColumnDfn(20,"Officiating",3,5,false,5), - new ColumnDfn(20,"UserSportData",0,-9,false,0), - new ColumnDfn(20,"Notes",0,-9,false,2000), + new ColumnDfn(20,"ActivityIndexIds",0,-9,false,0), + new ColumnDfn(20,"UserSessionData",0,-9,false,0), new ColumnDfn(20,"Flags",3,5,false,5), - new ColumnDfn(20,"Status",0,12,false,3), new ColumnDfn(20,"CreateOn",9,93,false,23), - new ColumnDfn(20,"CreateBy",4,4,false,10), - new ColumnDfn(20,"CreateHost",0,12,false,100), new ColumnDfn(20,"UpdateOn",9,93,false,23), - new ColumnDfn(20,"UpdateBy",4,4,false,10), - new ColumnDfn(20,"UpdateHost",0,12,false,100), new ColumnDfn(21,"Id",5,-5,true,19), - new ColumnDfn(21,"UserSportId",5,-5,false,19), - new ColumnDfn(21,"PeriodFrom",9,93,false,16), - new ColumnDfn(21,"PeriodTo",9,93,false,16), - new ColumnDfn(21,"OrganisationId",4,4,false,10), - new ColumnDfn(21,"OrganisationName",0,-9,false,200), - new ColumnDfn(21,"Summary",0,-9,false,2000), - new ColumnDfn(21,"Team",0,-9,false,64), - new ColumnDfn(21,"League",0,-9,false,64), - new ColumnDfn(21,"Speciality",0,-9,false,64), - new ColumnDfn(21,"SpecialitiesOther",0,-9,false,1000), - new ColumnDfn(21,"RegionIdNation",4,4,false,10), - new ColumnDfn(21,"RegionIdProvince",4,4,false,10), - new ColumnDfn(21,"Awards",0,-9,false,2000), - new ColumnDfn(21,"UserSportExperienceData",0,-9,false,0), + new ColumnDfn(21,"UserAccountId",4,4,false,10), + new ColumnDfn(21,"SportId",4,4,false,10), + new ColumnDfn(21,"About",0,-9,false,2000), + new ColumnDfn(21,"Participation",3,5,false,5), + new ColumnDfn(21,"Officiating",3,5,false,5), + new ColumnDfn(21,"UserSportData",0,-9,false,0), new ColumnDfn(21,"Notes",0,-9,false,2000), new ColumnDfn(21,"Flags",3,5,false,5), new ColumnDfn(21,"Status",0,12,false,3), @@ -967,6 +959,30 @@ namespace Saxonite.Base.App new ColumnDfn(21,"UpdateOn",9,93,false,23), new ColumnDfn(21,"UpdateBy",4,4,false,10), new ColumnDfn(21,"UpdateHost",0,12,false,100), + new ColumnDfn(22,"Id",5,-5,true,19), + new ColumnDfn(22,"UserSportId",5,-5,false,19), + new ColumnDfn(22,"PeriodFrom",9,93,false,16), + new ColumnDfn(22,"PeriodTo",9,93,false,16), + new ColumnDfn(22,"OrganisationId",4,4,false,10), + new ColumnDfn(22,"OrganisationName",0,-9,false,200), + new ColumnDfn(22,"Summary",0,-9,false,2000), + new ColumnDfn(22,"Team",0,-9,false,64), + new ColumnDfn(22,"League",0,-9,false,64), + new ColumnDfn(22,"Speciality",0,-9,false,64), + new ColumnDfn(22,"SpecialitiesOther",0,-9,false,1000), + new ColumnDfn(22,"RegionIdNation",4,4,false,10), + new ColumnDfn(22,"RegionIdProvince",4,4,false,10), + new ColumnDfn(22,"Awards",0,-9,false,2000), + new ColumnDfn(22,"UserSportExperienceData",0,-9,false,0), + new ColumnDfn(22,"Notes",0,-9,false,2000), + new ColumnDfn(22,"Flags",3,5,false,5), + new ColumnDfn(22,"Status",0,12,false,3), + new ColumnDfn(22,"CreateOn",9,93,false,23), + new ColumnDfn(22,"CreateBy",4,4,false,10), + new ColumnDfn(22,"CreateHost",0,12,false,100), + new ColumnDfn(22,"UpdateOn",9,93,false,23), + new ColumnDfn(22,"UpdateBy",4,4,false,10), + new ColumnDfn(22,"UpdateHost",0,12,false,100), }; //------------------------------------------------------------------- diff --git a/SaxoniteStandardBase/Base/App/SaxInternals.cs b/SaxoniteStandardBase/Base/App/SaxInternals.cs index 4017c07..225d8ea 100644 --- a/SaxoniteStandardBase/Base/App/SaxInternals.cs +++ b/SaxoniteStandardBase/Base/App/SaxInternals.cs @@ -92,6 +92,7 @@ namespace Saxonite.Net.Standard.Base.App public List YesNoCodes { get { return GetCodesOfType(Sax.CodeType.YesNo); } } public List GenderCodes { get { return GetCodesOfType(Sax.CodeType.Gender); } } public List SportSpecialityLabelCodes { get { return GetCodesOfType(Sax.CodeType.SportSpecialityLabel); } } + public List SportContactTypeCodes { get { return GetCodesOfType(Sax.CodeType.SportContactType); } } public List SportParticipationCodes { get { return GetCodesOfType(Sax.CodeType.SportParticipation); } } public List SportOfficiatingCodes { get { return GetCodesOfType(Sax.CodeType.SportOfficiating); } } public List RegionTypeCodes { get { return GetCodesOfType(Sax.CodeType.RegionType); } } diff --git a/SaxoniteStandardBase/Base/App/SaxSystem-CodeTypes.cs b/SaxoniteStandardBase/Base/App/SaxSystem-CodeTypes.cs index 2c17e64..4e9465b 100644 --- a/SaxoniteStandardBase/Base/App/SaxSystem-CodeTypes.cs +++ b/SaxoniteStandardBase/Base/App/SaxSystem-CodeTypes.cs @@ -17,6 +17,7 @@ namespace Saxonite.Net.Standard.Base.App private static readonly List dataItemTypeCodes = new List(); private static readonly List genderCodes = new List(); private static readonly List sportSpecialityLabelCodes = new List(); + private static readonly List sportContactCodes = new List(); private static readonly List sportParticipationCodes = new List(); private static readonly List sportOfficiatingCodes = new List(); private static readonly List regionTypeCodes = new List(); @@ -50,6 +51,8 @@ namespace Saxonite.Net.Standard.Base.App return new List(genderCodes); case Sax.CodeType.SportSpecialityLabel: return new List(sportSpecialityLabelCodes); + case Sax.CodeType.SportContactType: + return new List(sportContactCodes); case Sax.CodeType.SportParticipation: return new List(sportParticipationCodes); case Sax.CodeType.SportOfficiating: @@ -133,6 +136,12 @@ namespace Saxonite.Net.Standard.Base.App sportSpecialityLabelCodes.Add(Sax.SportSpecialityLabel.Discipline, "DIS", "Discipline"); sportSpecialityLabelCodes.Add(Sax.SportSpecialityLabel.NotRelevant, "NRE", "Not relevant"); + //--------------------------------------------------------------- + // Sport contact. + sportContactCodes.Add(Sax.SportContactType.Coach, "COA", "Coach"); + sportContactCodes.Add(Sax.SportContactType.Manager, "MAN", "Manager"); + sportContactCodes.Add(Sax.SportContactType.Agent, "AGE", "Agent"); + //--------------------------------------------------------------- // Sport participation. sportParticipationCodes.Add(Sax.SportParticipation.Professional, "PRO", "Professional"); diff --git a/SaxoniteStandardBase/Base/Bus/SaxUserAccount.cs b/SaxoniteStandardBase/Base/Bus/SaxUserAccount.cs index c6c8327..eee7faf 100644 --- a/SaxoniteStandardBase/Base/Bus/SaxUserAccount.cs +++ b/SaxoniteStandardBase/Base/Bus/SaxUserAccount.cs @@ -78,6 +78,7 @@ namespace Saxonite.Net.Standard.Base.Bus public String PhoneMain { get; set; } = String.Empty; public String PhoneMobile { get; set; } = String.Empty; public Sax.Gender Gender { get; set; } + public String GenderOther { get; set; } public byte DateOfBirthDay { get; set; } public byte DateOfBirthMonth { get; set; } public short DateOfBirthYear { get; set; } @@ -151,6 +152,11 @@ namespace Saxonite.Net.Standard.Base.Bus get { return data.Gender; } set { CheckChanged((int)data.Gender, (int)value); data.Gender = value; } } + public String GenderOther + { + get { return data.GenderOther; } + set { CheckChanged(data.GenderOther, value); data.GenderOther = value; } + } public byte DateOfBirthDay { get { return data.DateOfBirthDay; } @@ -230,6 +236,7 @@ namespace Saxonite.Net.Standard.Base.Bus PhoneMain = data.PhoneMain; PhoneMobile = data.PhoneMobile; Gender = data.Gender; + GenderOther = data.GenderOther; DateOfBirthDay = data.DateOfBirthDay; DateOfBirthMonth = data.DateOfBirthMonth; DateOfBirthYear = data.DateOfBirthYear; @@ -268,6 +275,7 @@ namespace Saxonite.Net.Standard.Base.Bus public ValidValue PhoneMain { get; set; } = ValidValue.Valid; public ValidValue PhoneMobile { get; set; } = ValidValue.Valid; public ValidValue Gender { get; set; } = ValidValue.Valid; + public ValidValue GenderOther { get; set; } = ValidValue.Valid; public ValidValue DateOfBirthDay { get; set; } = ValidValue.Valid; public ValidValue DateOfBirthMonth { get; set; } = ValidValue.Valid; public ValidValue DateOfBirthYear { get; set; } = ValidValue.Valid; @@ -393,6 +401,11 @@ namespace Saxonite.Net.Standard.Base.Bus get { return data.Gender; } set { data.Gender = value; } } + public String GenderOther + { + get { return data.GenderOther; } + set { data.GenderOther = value; } + } public byte DateOfBirthDay { get { return data.DateOfBirthDay; } diff --git a/SaxoniteStandardBase/Base/Bus/SaxUserConfig.cs b/SaxoniteStandardBase/Base/Bus/SaxUserConfig.cs new file mode 100644 index 0000000..f052ca2 --- /dev/null +++ b/SaxoniteStandardBase/Base/Bus/SaxUserConfig.cs @@ -0,0 +1,181 @@ +using Sarand.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Base.Core; +using Saxonite.Net.Standard.Base.App; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using static Saxonite.Net.Standard.Base.App.Sax; + +namespace Saxonite.Net.Standard.Base.Bus +{ + //======================================================================= + // User Config. + //======================================================================= + /// + /// User Config - parameters to control application behaviour. + /// + public abstract partial class SaxUserConfig : SacsHierarchyItem + { + //------------------------------------------------------------------- + // Columns. + public enum Column + { + Pos, + Id, + // User. + UserAccountId, + User_EmailAddress, + User_DisplayName, + User_Title, + User_FirstName, + User_LastName, + // Configuration. + ConfigType, + // Associated data. + // Common. + //Flags, + CreateOn_Date, + UpdateOn_Date, + } + + //------------------------------------------------------------------- + /// Properties other than common. + public class DataProperties + { + public SysId UserAccountId { get; set; } + public Sax.UserConfigType ConfigType { get; set; } + public String ConfigData { get; set; } + } + + //------------------------------------------------------------------- + // Data. + public new class Data : SacsHierarchyItem.Data + { + // Data members. + private readonly DataProperties data = new DataProperties(); + // Construction. + public Data() + { + } + // Properties. + public SysId UserAccountId + { + get { return data.UserAccountId; } + set { CheckChanged(data.UserAccountId, value); data.UserAccountId = value; } + } + public Sax.UserConfigType ConfigType + { + get { return data.ConfigType; } + set { CheckChanged((int)data.ConfigType, (int)value); data.ConfigType = value; } + } + public String ConfigData + { + get { return data.ConfigData; } + set { CheckChanged(data.ConfigData, value); data.ConfigData = value; } + } + // Population. + internal void PopulateFrom(Data data) + { + UserAccountId = data.UserAccountId; + ConfigType = data.ConfigType; + ConfigData = data.ConfigData; + base.PopulateFrom(data); + } + public Data Clone() + { + Data data = new Data(); + data.PopulateFrom(this); + return data; + } + } + + //------------------------------------------------------------------- + // Error field - identify properties with validation error. + public new class ErrField : SacsHierarchyItem.ErrField + { + // Identifies the field that has invalid data. + public ValidValue UserAccountId { get; set; } = ValidValue.Valid; + public ValidValue ConfigType { get; set; } = ValidValue.Valid; + public ValidValue ConfigData { get; set; } = ValidValue.Valid; + } + + //------------------------------------------------------------------- + // Data members. + private readonly Data data = new Data(); + + //------------------------------------------------------------------- + // Construction. + protected SaxUserConfig(SysId id, SysId userAccountId, Sax.UserConfigType configType) : base(id) + { + base.SetData(data); + UserAccountId = userAccountId; + ConfigType = configType; + } + + //------------------------------------------------------------------- + // Utilities. + + //------------------------------------------------------------------- + // Properties. + public static String ActivityIndexDelim { get; } = ","; + public Data GetData() { return data.Clone(); } + public void SetData(Data data) + { + String fn = GetType().Name + ".SetData"; + // Properties that cannot be changed if previously specified. + if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) + throw new NotSupportedException(fn + " Id cannot be changed"); + if (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId)) + throw new NotSupportedException(fn + " User Account Id cannot be changed"); + if (ConfigType != data.ConfigType) + throw new NotSupportedException(fn + " Config Type cannot be changed"); + this.data.PopulateFrom(data); + } + public SysId UserAccountId + { + get { return data.UserAccountId; } + protected set { data.UserAccountId = value; } + } + public Sax.UserConfigType ConfigType + { + get { return data.ConfigType; } + protected set { data.ConfigType = value; } + } + public String ConfigData + { + get { return data.ConfigData; } + set { data.ConfigData = value; } + } + + //------------------------------------------------------------------- + // Flags - positions 1-16 available. + + //------------------------------------------------------------------- + // A s s o c i a t e d D a t a + //------------------------------------------------------------------- + + //------------------------------------------------------------------- + // P a r a m s + //------------------------------------------------------------------- + // List parameters. + /// + /// Item list parameters. + /// + public new class Params : SacsHierarchyItem.Params + { + // List filtering. + public List UserAccountIdsIncluded { get; } = new List(); + public Sax.UserConfigType ConfigType { get; set; } + } + + //------------------------------------------------------------------- + } + //======================================================================= + // Item list extension methods. + public static class SaxUserConfigList + { + } + + //======================================================================= +} diff --git a/SaxoniteStandardBase/Base/Bus/SaxUserEligibility.cs b/SaxoniteStandardBase/Base/Bus/SaxUserEligibility.cs index 254fcae..a851b0b 100644 --- a/SaxoniteStandardBase/Base/Bus/SaxUserEligibility.cs +++ b/SaxoniteStandardBase/Base/Bus/SaxUserEligibility.cs @@ -221,7 +221,7 @@ namespace Saxonite.Net.Standard.Base.Bus public SysId UserAccountId { get { return data.UserAccountId; } - set + protected set { if (SysId.IsValid(UserAccountId) && SysId.ToInt(UserAccountId) != SysId.ToInt(data.UserAccountId)) throw new NotSupportedException("EligibilityType.UserAccountId cannot be changed"); @@ -245,7 +245,7 @@ namespace Saxonite.Net.Standard.Base.Bus public Sax.EligibilityType EligibilityType { get { return data.EligibilityType; } - protected set { data.EligibilityType = value; } + set { data.EligibilityType = value; } } public String Info diff --git a/SaxoniteStandardBase/Base/Data/SaxConfigData.cs b/SaxoniteStandardBase/Base/Data/SaxConfigData.cs new file mode 100644 index 0000000..9492441 --- /dev/null +++ b/SaxoniteStandardBase/Base/Data/SaxConfigData.cs @@ -0,0 +1,109 @@ + +using Sarand.Net.Standard.Base.App; +using Sarand.Net.Standard.Base.Utils; +using System; +using System.Collections.Generic; +using System.Text; +using static Saxonite.Net.Standard.Base.Bus.SaxUserConfig; +using System.Xml.Linq; + +namespace Saxonite.Net.Standard.Base.Data +{ + //========================================================================== + public class SaxConfigData + { + //------------------------------------------------------------------- + // Definitions. + private static readonly String ElementName_Config = "Config"; + private static readonly String ElementName_Profile = "Profile"; + private static readonly String ElementName_Eligibility = "Eligibility"; + private static readonly String ElementName_HideInfo = "HideInfo"; + + //------------------------------------------------------------------- + /// Profile settings. + public class ProfileData + { + //--------------------------------------------------------------- + /// Eligibility settings. + public class EligibilityData + { + /// Hide the eligbiility information tip. + public bool HideInfo { get; set; } + } + public EligibilityData Eligibility { get; set; } = new EligibilityData(); + + //--------------------------------------------------------------- + /// Serialise to XML. + public static String ToXml(ProfileData profile) + { + String fn = typeof(ProfileData).FullName + ".GetConfigData"; + try + { + XDocument doc = new XDocument(); + XElement configElement = doc.AppendElement(ElementName_Config); + // Profile. + XElement profileElement = configElement.AppendElement(ElementName_Profile); + // Profile - Eligibility. + XElement eligibilityElement = profileElement.AppendElement(ElementName_Eligibility); + if (profile.Eligibility.HideInfo) + eligibilityElement.AppendElement(ElementName_HideInfo, "1"); + return doc.GetXml(); + } + catch (Exception exc) + { + SaLogger.Warn(fn + " " + ExceptionUtil.GetLogMessage(exc)); + } + return ""; + } + + //--------------------------------------------------------------- + /// Deserialise from XML. + public static ProfileData FromXml(String configData) + { + String fn = typeof(ProfileData).FullName + ".ExtractConfig"; + ProfileData profile = new ProfileData(); + if (StringUtil.IsEmpty(configData)) return profile; + try + { + // Load XML data. + // NB Serialised data has 'Config' as root element + XDocument doc = XDocument.Parse(configData); + XElement rootElement = doc.Root; + foreach (XElement rootChildElement in rootElement.GetChildElements()) + { + String rootChildElementName = rootChildElement.GetLocalName(); + if (rootChildElementName.EqualsCI(ElementName_Profile)) + { + // Profile. + XElement profileElement = rootChildElement; + foreach (XElement profileChildElement in profileElement.GetChildElements()) + { + String profileChildElementName = profileChildElement.GetLocalName(); + if (profileChildElementName.EqualsCI(ElementName_Eligibility)) + { + // Profile - Eligibility. + XElement eligibilityElement = profileChildElement; + String hideInfo = eligibilityElement.GetChildText(ElementName_HideInfo); + profile.Eligibility.HideInfo = StringUtil.ToBool(hideInfo); + } + else SaLogger.Warn(fn + " Unexpected 'Profile' child element: " + profileChildElementName); + } + } + else SaLogger.Warn(fn + " Unexpected 'Root' child element: " + rootChildElementName); + } + } + catch (Exception exc) + { + SaLogger.Warn(fn + " " + ExceptionUtil.GetLogMessage(exc)); + } + return profile; + } + + //--------------------------------------------------------------- + } + + //------------------------------------------------------------------- + } + + //========================================================================== +} diff --git a/SaxoniteStandardBase/Base/Mgr/SaxAccountMgr-UserAccount.cs b/SaxoniteStandardBase/Base/Mgr/SaxAccountMgr-UserAccount.cs index c3e0753..b40d76d 100644 --- a/SaxoniteStandardBase/Base/Mgr/SaxAccountMgr-UserAccount.cs +++ b/SaxoniteStandardBase/Base/Mgr/SaxAccountMgr-UserAccount.cs @@ -137,6 +137,12 @@ namespace Saxonite.Net.Standard.Base.Mgr errField.PhoneMobile = SacsHierarchyItem.ValidValue.Invalid; return false; } + // Gender other. + if (errField.GenderOther != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.GenderOther, "gender", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserAccount_GenderOther))) + { + errField.GenderOther = SacsHierarchyItem.ValidValue.Invalid; + return false; + } // Date of birth year. if (errField.DateOfBirthYear != SacsHierarchyItem.ValidValue.Ignore && data.DateOfBirthYear > DateTime.Today.Year) { diff --git a/SaxoniteStandardBase/Base/Mgr/SaxAccountMgr-UserConfig.cs b/SaxoniteStandardBase/Base/Mgr/SaxAccountMgr-UserConfig.cs new file mode 100644 index 0000000..82c3774 --- /dev/null +++ b/SaxoniteStandardBase/Base/Mgr/SaxAccountMgr-UserConfig.cs @@ -0,0 +1,135 @@ +using Sarand.Net.Standard.Base.App; +using Sarand.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Base.Core; +using Sarand.Net.Standard.Base.Dbas; +using Saxonite.Base.App; +using Saxonite.Net.Standard.Base.App; +using Saxonite.Net.Standard.Base.Bus; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Saxonite.Net.Standard.Base.Mgr +{ + //======================================================================= + partial class SaxAccountMgr + { + //******************************************************************* + // Account Mgr - User Config + //******************************************************************* + // Utilities. + public List GetConfigsForUser(SysId userAccountId) + { + SaxUserConfig.Params prmUserConfig = new SaxUserConfig.Params(); + prmUserConfig.UserAccountIdsIncluded.Add(userAccountId); + List userConfigs = AccountMgr.GetUserConfigList(prmUserConfig); + return userConfigs; + } + + //------------------------------------------------------------------- + // Create item. + public abstract SaxUserConfig CreateUserConfig(SysId userAccountId, Sax.UserConfigType configType); + + //------------------------------------------------------------------- + // Item exists. + public bool UserConfigExists(SysId userAccountId) + { + ClearErrorState(); + if (!SysId.IsValid(userAccountId)) return false; + SaxUserConfig.Params prmUserConfig = new SaxUserConfig.Params(); + prmUserConfig.UserAccountIdsIncluded.Add(userAccountId); + return GetUserConfigCount(prmUserConfig) == 1; + } + + //------------------------------------------------------------------- + // Retrieve individual items. + public abstract SaxUserConfig GetUserConfig(SaxUserConfig.Params prmUserConfig); + public SaxUserConfig GetUserConfig(SysId userAccountId, Sax.UserConfigType configType) + { + ClearErrorState(); + if (!SysId.IsValid(userAccountId) || configType <= 0) return null; + SaxUserConfig.Params prmUserConfig = new SaxUserConfig.Params(); + prmUserConfig.UserAccountIdsIncluded.Add(userAccountId); + prmUserConfig.ConfigType = configType; + return GetUserConfig(prmUserConfig); + } + + //------------------------------------------------------------------- + // Validate item data. + public bool IsValidUserConfig(SaxUserConfig userConfig) + { + ClearErrorState(); + if (userConfig == null) return SetErrorState(ErrorMessage.ItemNotSpecified); + return IsValidUserConfigData(userConfig.GetData(), new SaxUserConfig.ErrField()); + } + public virtual bool IsValidUserConfigData(SaxUserConfig.Data data, SaxUserConfig.ErrField errField) + { + ClearErrorState(); + + // User Account. + if (errField.UserAccountId != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.UserAccountId)) + { + errField.UserAccountId = SacsHierarchyItem.ValidValue.Invalid; + return SetErrorState("User Account Id must be specified"); + } + + // Config Type. + if (errField.ConfigType != SacsHierarchyItem.ValidValue.Ignore && data.ConfigType <= 0) + { + errField.UserAccountId = SacsHierarchyItem.ValidValue.Invalid; + return SetErrorState("Config type must be specified"); + } + + return true; + } + + //------------------------------------------------------------------- + // Item database interface. + public abstract bool InsertUserConfig(SaxUserConfig userConfig, DbUpdateInfo dbUpdateInfo); + public abstract bool UpdateUserConfig(SaxUserConfig userConfig, DbUpdateInfo dbUpdateInfo); + public virtual bool UserConfigCanBeDeleted(SaxUserConfig userConfig) + { + ClearErrorState(); + return true; + } + public abstract bool DeleteUserConfig(SaxUserConfig userConfig, DbUpdateInfo dbUpdateInfo); + + //------------------------------------------------------------------- + // Item list. + public abstract ColumnDfn GetUserConfigColumnDfn(SaxUserConfig.Column columnId, String caption = "", int width = 0); + public abstract List GetUserConfigQueryFilter(SaxUserConfig.Params prmUserConfig); + public abstract long GetUserConfigCount(SaxUserConfig.Params prmUserConfig); + public abstract List GetUserConfigList(SaxUserConfig.Params prmUserConfig); + public abstract DbResultSet ExecuteUserConfigQuery(List columns, SaxUserConfig.Params prmUserConfig); + + //------------------------------------------------------------------- + /// + /// Extract and format result set data value where specific handling is required. + /// Where response is an invalid data value, format value using column.FormatValue(values). + /// + public virtual DataValue GetUserConfigDataValue(ColumnDfn column, NamedValue.Map values) + { + DataValue value = new DataValue(); + switch ((SaxUserConfig.Column)column.Id) + { + //----------------------------------------------------------- + // User Display Name. + case SaxUserConfig.Column.User_DisplayName: + { + String userTitle = values.GetValue(GetUserConfigColumnDfn(SaxUserConfig.Column.User_Title).DataName).ToString(); + String userFirstName = values.GetValue(GetUserConfigColumnDfn(SaxUserConfig.Column.User_FirstName).DataName).ToString(); + String userLastName = values.GetValue(GetUserConfigColumnDfn(SaxUserConfig.Column.User_LastName).DataName).ToString(); + value = new DataValue(SaxUserAccount.GetDisplayName(userTitle, userFirstName, userLastName)); + } + break; + + //----------------------------------------------------------- + } + return value; + } + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaxoniteStandardBase/Base/Mgr/SaxItemMgr.cs b/SaxoniteStandardBase/Base/Mgr/SaxItemMgr.cs index 81be8a2..6ee0794 100644 --- a/SaxoniteStandardBase/Base/Mgr/SaxItemMgr.cs +++ b/SaxoniteStandardBase/Base/Mgr/SaxItemMgr.cs @@ -68,6 +68,7 @@ namespace Saxonite.Net.Standard.Base.Mgr // Application codes. public List DataItemTypeCodes { get { return Internals.DataItemTypeCodes; } } public List SportSpecialityLabelCodes { get { return Internals.SportSpecialityLabelCodes; } } + public List SportContactTypeCodes { get { return Internals.SportContactTypeCodes; } } public List SportParticipationCodes { get { return Internals.SportParticipationCodes; } } public List SportOfficiatingCodes { get { return Internals.SportOfficiatingCodes; } } public List RegionTypeCodes { get { return Internals.RegionTypeCodes; } } diff --git a/SaxoniteStandardDbas/Dbas/Bus/SaxUserConfig_Dbas.cs b/SaxoniteStandardDbas/Dbas/Bus/SaxUserConfig_Dbas.cs new file mode 100644 index 0000000..e231828 --- /dev/null +++ b/SaxoniteStandardDbas/Dbas/Bus/SaxUserConfig_Dbas.cs @@ -0,0 +1,33 @@ +using Sarand.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Base.Dbas; +using Saxonite.Net.Standard.Base.App; +using Saxonite.Net.Standard.Base.Bus; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Saxonite.Net.Standard.Dbas.Bus +{ + //======================================================================= + public class SaxUserConfig_Dbas : SaxUserConfig + { + //------------------------------------------------------------------- + // Data members. + private ISacsDatabase database; + + //------------------------------------------------------------------- + // Construction. + public SaxUserConfig_Dbas(ISacsDatabase database, SysId id, SysId userAccountId, Sax.UserConfigType configType, UInt16 flags) : + base(id, userAccountId, configType) + { + this.database = database; + Flags = flags; + } + + //------------------------------------------------------------------- + // Associated data. + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaxoniteStandardDbas/Dbas/Internal/ActivityFeedback_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/ActivityFeedback_Db.cs index 8c3f18c..80f22f8 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/ActivityFeedback_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/ActivityFeedback_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 13-Oct-2022 09:38:45 +// Code generated by Sarand Database Utilities Tue 15-Nov-2022 13:33:16 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/ActivityIndex_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/ActivityIndex_Db.cs index 5c1a344..6b842c9 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/ActivityIndex_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/ActivityIndex_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 13-Oct-2022 09:38:45 +// Code generated by Sarand Database Utilities Tue 15-Nov-2022 13:33:16 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Article_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Article_Db.cs index 609a851..31a92c3 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Article_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Article_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 13-Oct-2022 09:38:45 +// Code generated by Sarand Database Utilities Tue 15-Nov-2022 13:33:16 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/ItemAddress_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/ItemAddress_Db.cs index 9a16e0c..3026f00 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/ItemAddress_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/ItemAddress_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 13-Oct-2022 09:38:45 +// Code generated by Sarand Database Utilities Tue 15-Nov-2022 13:33:16 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/ItemAssociation_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/ItemAssociation_Db.cs index 4c4d866..ad6a9ea 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/ItemAssociation_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/ItemAssociation_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 13-Oct-2022 09:38:45 +// Code generated by Sarand Database Utilities Tue 15-Nov-2022 13:33:16 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/ItemImage_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/ItemImage_Db.cs index c7b5b1c..b6d3cbd 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/ItemImage_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/ItemImage_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 13-Oct-2022 09:38:45 +// Code generated by Sarand Database Utilities Tue 15-Nov-2022 13:33:16 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/ItemSport_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/ItemSport_Db.cs index e1198f7..4db92c4 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/ItemSport_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/ItemSport_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 13-Oct-2022 09:38:45 +// Code generated by Sarand Database Utilities Tue 15-Nov-2022 13:33:16 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/OrganisationEvent_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/OrganisationEvent_Db.cs index d220bdc..60fe441 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/OrganisationEvent_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/OrganisationEvent_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 13-Oct-2022 09:38:45 +// Code generated by Sarand Database Utilities Tue 15-Nov-2022 13:33:16 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/OrganisationOpportunity_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/OrganisationOpportunity_Db.cs index 434f251..94a3529 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/OrganisationOpportunity_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/OrganisationOpportunity_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 13-Oct-2022 09:38:46 +// Code generated by Sarand Database Utilities Tue 15-Nov-2022 13:33:16 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Organisation_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Organisation_Db.cs index 427fd4c..54dc158 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Organisation_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Organisation_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 13-Oct-2022 09:38:45 +// Code generated by Sarand Database Utilities Tue 15-Nov-2022 13:33:16 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Region_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Region_Db.cs index f8556bd..a4f6922 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Region_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Region_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 13-Oct-2022 09:38:46 +// Code generated by Sarand Database Utilities Tue 15-Nov-2022 13:33:16 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/Sport_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/Sport_Db.cs index a70d8a6..89e148a 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/Sport_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/Sport_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 13-Oct-2022 09:38:46 +// Code generated by Sarand Database Utilities Tue 15-Nov-2022 13:33:16 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/UserAccount_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/UserAccount_Db.cs index 67a41f8..388810d 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/UserAccount_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/UserAccount_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 13-Oct-2022 09:38:46 +// Code generated by Sarand Database Utilities Tue 15-Nov-2022 13:33:16 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { @@ -30,6 +30,7 @@ namespace Saxonite.Net.Standard.Dbas.Internal public ColumnDataString _PhoneMobile { get; } = new ColumnDataString("PhoneMobile"); public ColumnDataString _PhoneAlt { get; } = new ColumnDataString("PhoneAlt"); public ColumnDataByte _Gender { get; } = new ColumnDataByte("Gender"); + public ColumnDataString _GenderOther { get; } = new ColumnDataString("GenderOther"); public ColumnDataByte _DateOfBirthDay { get; } = new ColumnDataByte("DateOfBirthDay"); public ColumnDataByte _DateOfBirthMonth { get; } = new ColumnDataByte("DateOfBirthMonth"); public ColumnDataInt16 _DateOfBirthYear { get; } = new ColumnDataInt16("DateOfBirthYear"); @@ -69,6 +70,7 @@ namespace Saxonite.Net.Standard.Dbas.Internal "PhoneMobile", "PhoneAlt", "Gender", + "GenderOther", "DateOfBirthDay", "DateOfBirthMonth", "DateOfBirthYear", @@ -134,6 +136,7 @@ namespace Saxonite.Net.Standard.Dbas.Internal public String _PhoneMobile { get { return Cols._PhoneMobile.Value; } set { Cols._PhoneMobile.Value = value; } } public String _PhoneAlt { get { return Cols._PhoneAlt.Value; } set { Cols._PhoneAlt.Value = value; } } public Byte _Gender { get { return Cols._Gender.Value; } set { Cols._Gender.Value = value; } } + public String _GenderOther { get { return Cols._GenderOther.Value; } set { Cols._GenderOther.Value = value; } } public Byte _DateOfBirthDay { get { return Cols._DateOfBirthDay.Value; } set { Cols._DateOfBirthDay.Value = value; } } public Byte _DateOfBirthMonth { get { return Cols._DateOfBirthMonth.Value; } set { Cols._DateOfBirthMonth.Value = value; } } public Int16 _DateOfBirthYear { get { return Cols._DateOfBirthYear.Value; } set { Cols._DateOfBirthYear.Value = value; } } @@ -188,6 +191,7 @@ namespace Saxonite.Net.Standard.Dbas.Internal _PhoneMobile = GetFieldString(dbDataReader, "PhoneMobile", _PhoneMobile); _PhoneAlt = GetFieldString(dbDataReader, "PhoneAlt", _PhoneAlt); _Gender = GetFieldByte(dbDataReader, "Gender", _Gender); + _GenderOther = GetFieldString(dbDataReader, "GenderOther", _GenderOther); _DateOfBirthDay = GetFieldByte(dbDataReader, "DateOfBirthDay", _DateOfBirthDay); _DateOfBirthMonth = GetFieldByte(dbDataReader, "DateOfBirthMonth", _DateOfBirthMonth); _DateOfBirthYear = GetFieldInt16(dbDataReader, "DateOfBirthYear", _DateOfBirthYear); @@ -241,6 +245,7 @@ namespace Saxonite.Net.Standard.Dbas.Internal if (columnNames.ContainsCI("PhoneMobile")) AddCommandParameter(dbCommand, "@PhoneMobile", _PhoneMobile); if (columnNames.ContainsCI("PhoneAlt")) AddCommandParameter(dbCommand, "@PhoneAlt", _PhoneAlt); if (columnNames.ContainsCI("Gender")) AddCommandParameter(dbCommand, "@Gender", _Gender); + if (columnNames.ContainsCI("GenderOther")) AddCommandParameter(dbCommand, "@GenderOther", _GenderOther); if (columnNames.ContainsCI("DateOfBirthDay")) AddCommandParameter(dbCommand, "@DateOfBirthDay", _DateOfBirthDay); if (columnNames.ContainsCI("DateOfBirthMonth")) AddCommandParameter(dbCommand, "@DateOfBirthMonth", _DateOfBirthMonth); if (columnNames.ContainsCI("DateOfBirthYear")) AddCommandParameter(dbCommand, "@DateOfBirthYear", _DateOfBirthYear); @@ -309,6 +314,7 @@ namespace Saxonite.Net.Standard.Dbas.Internal if (columnNames.ContainsCI("PhoneMobile")) AddCommandParameter(dbCommand, "@PhoneMobile", _PhoneMobile); if (columnNames.ContainsCI("PhoneAlt")) AddCommandParameter(dbCommand, "@PhoneAlt", _PhoneAlt); if (columnNames.ContainsCI("Gender")) AddCommandParameter(dbCommand, "@Gender", _Gender); + if (columnNames.ContainsCI("GenderOther")) AddCommandParameter(dbCommand, "@GenderOther", _GenderOther); if (columnNames.ContainsCI("DateOfBirthDay")) AddCommandParameter(dbCommand, "@DateOfBirthDay", _DateOfBirthDay); if (columnNames.ContainsCI("DateOfBirthMonth")) AddCommandParameter(dbCommand, "@DateOfBirthMonth", _DateOfBirthMonth); if (columnNames.ContainsCI("DateOfBirthYear")) AddCommandParameter(dbCommand, "@DateOfBirthYear", _DateOfBirthYear); diff --git a/SaxoniteStandardDbas/Dbas/Internal/UserActivity_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/UserActivity_Db.cs index 691fd40..090ed18 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/UserActivity_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/UserActivity_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 13-Oct-2022 09:38:46 +// Code generated by Sarand Database Utilities Tue 15-Nov-2022 13:33:16 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/UserConfig_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/UserConfig_Db.cs new file mode 100644 index 0000000..158344b --- /dev/null +++ b/SaxoniteStandardDbas/Dbas/Internal/UserConfig_Db.cs @@ -0,0 +1,178 @@ +using Microsoft.Data.SqlClient; +using Sarand.Net.Standard.Base.Core; +using Sarand.Net.Standard.Base.Dbas; +using Sarand.Net.Standard.Base.Utils; +using Saxonite.Net.Standard.Dbas.Data; +using System; +using System.Collections.Generic; +using System.Data.Common; +using System.Linq; + +//--------------------------------------------------------------------------- +// Code generated by Sarand Database Utilities Tue 15-Nov-2022 13:33:16 +//--------------------------------------------------------------------------- +namespace Saxonite.Net.Standard.Dbas.Internal +{ + internal class UserConfig_Db : SaxDbDataItem + { + //------------------------------------------------------------------- + // Column definitions. + public class ColumnsData + { + public ColumnDataInt64 _Id { get; } = new ColumnDataInt64("Id", true); + public ColumnDataInt32 _UserAccountId { get; } = new ColumnDataInt32("UserAccountId"); + public ColumnDataInt16 _ConfigType { get; } = new ColumnDataInt16("ConfigType"); + public ColumnDataString _ConfigData { get; } = new ColumnDataString("ConfigData"); + public ColumnDataDateTime _CreateOn { get; } = new ColumnDataDateTime("CreateOn"); + public ColumnDataDateTime _UpdateOn { get; } = new ColumnDataDateTime("UpdateOn"); + } + + //------------------------------------------------------------------- + // Data members. + protected static List fields { get; } = new List() + { + "Id", + "UserAccountId", + "ConfigType", + "ConfigData", + "CreateOn", + "UpdateOn", + }; + protected static List fieldsId { get; } = new List() + { + "Id", + }; + protected static List fieldsPrimary { get; } = new List() + { + "Id", + }; + protected static List fieldsIgnoreOnUpdate { get; } = new List() + { + "CreateOn", + "CreateBy", + "CreateHost", + }; + + //------------------------------------------------------------------- + // Construction. + internal UserConfig_Db (IDatabaseInfo dbInfo) : base(dbInfo) + { + } + + //------------------------------------------------------------------- + // Properties. + public override String SchemaName { get; } = "dbo"; + public override String TableName { get; } = "UserConfig"; + public String TableNameFmt { get { return (!String.IsNullOrEmpty(SchemaName) ? "[" + SchemaName + "]." : "") + "[" + TableName + "]"; } } + public static List Fields { get { return new List(fields); } } + public static List FieldsId { get { return new List(fieldsId); } } + public static List FieldsNonId { get { return fields.FindAll(item => !fieldsId.ContainsCI(item)); } } + // Columns. + public ColumnsData Cols { get; } = new ColumnsData(); + public Int64 _Id { get { return Cols._Id.Value; } set { Cols._Id.Value = value; } } + public Int32 _UserAccountId { get { return Cols._UserAccountId.Value; } set { Cols._UserAccountId.Value = value; } } + public Int16 _ConfigType { get { return Cols._ConfigType.Value; } set { Cols._ConfigType.Value = value; } } + public String _ConfigData { get { return Cols._ConfigData.Value; } set { Cols._ConfigData.Value = value; } } + public DateTime _CreateOn { get { return Cols._CreateOn.Value; } set { Cols._CreateOn.Value = value; } } + public DateTime _UpdateOn { get { return Cols._UpdateOn.Value; } set { Cols._UpdateOn.Value = value; } } + // Existing columns - confirmed on database if table exists. + public List ExistingColumnNames { get { return GetExistingColumnNames(Fields); } } + public List ExistingColumnNamesNonId { get { return GetExistingColumnNames(FieldsNonId); } } + + //------------------------------------------------------------------- + // Population. + public override void PopulateFrom (DbCommand dbCommand, String tableAlias, String filter) + { + dbCommand.CommandText = + "SELECT " + ExistingColumnNames.Concat(", ", (!String.IsNullOrEmpty(tableAlias) ? tableAlias + "." : "") + "[", "]") + " " + + "FROM " + TableNameFmt + (!String.IsNullOrEmpty(tableAlias) ? " " + tableAlias : "") + " " + + (!String.IsNullOrEmpty(filter) ? "WHERE " + filter : ""); + Log(GetType().Name + ".PopulateFrom", dbCommand.CommandText); + using (DbDataReader dbDataReader = dbCommand.ExecuteReader()) + { + dbDataReader.Read(); + PopulateFrom(dbDataReader); + } + } + public override void PopulateFrom (DbDataReader dbDataReader) + { + _Id = GetFieldInt64(dbDataReader, "Id", _Id); + _UserAccountId = GetFieldInt32(dbDataReader, "UserAccountId", _UserAccountId); + _ConfigType = GetFieldInt16(dbDataReader, "ConfigType", _ConfigType); + _ConfigData = GetFieldString(dbDataReader, "ConfigData", _ConfigData); + _CreateOn = GetFieldDateTime(dbDataReader, "CreateOn", _CreateOn); + _UpdateOn = GetFieldDateTime(dbDataReader, "UpdateOn", _UpdateOn); + } + + //------------------------------------------------------------------- + // Insert command. + public override bool ExecuteInsertCommand (DbCommand dbCommand) + { + List columnNames = ExistingColumnNamesNonId; + // Avoid insert if Identity field is already valid. + if (_Id != 0) throw new Exception("Invalid for Insert - item already has a valid Id"); + // Construct query. + String query = + "INSERT INTO " + TableNameFmt + " " + + "("+columnNames.Concat(",","[","]")+") "; + query += "Output Inserted.Id "; + if (dbCommand is SqlCommand) + query += "VALUES (" + columnNames.Concat(",", "@", "") + ") "; + else query += "VALUES (" + StringListUtil.CreateList("?", columnNames.Count).Concat(",") + ") "; + dbCommand.CommandText = query; + Log(GetType().Name + ".ExecuteInsertCommand", dbCommand.CommandText); + // Populate parameters. + dbCommand.Parameters.Clear(); + if (columnNames.ContainsCI("UserAccountId")) AddCommandParameter(dbCommand, "@UserAccountId", _UserAccountId); + if (columnNames.ContainsCI("ConfigType")) AddCommandParameter(dbCommand, "@ConfigType", _ConfigType); + if (columnNames.ContainsCI("ConfigData")) AddCommandParameter(dbCommand, "@ConfigData", _ConfigData); + if (columnNames.ContainsCI("CreateOn")) AddCommandParameter(dbCommand, "@CreateOn", _CreateOn); + if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn); + // Execute insert command. + bool commandSuccess = false; + int executeNonQuery = dbCommand.ExecuteNonQuery(); + if (executeNonQuery == 1) + { + dbCommand.CommandText = "SELECT Max(Id) FROM " + TableNameFmt + ";"; + _Id = Convert.ToInt64(dbCommand.ExecuteScalar()); + commandSuccess = (_Id > 0); + } + return commandSuccess; + } + + //------------------------------------------------------------------- + // Update command. + public override bool ExecuteUpdateCommand (DbCommand dbCommand) + { + // Avoid update if Identity field isn't valid. + if (_Id == 0) throw new Exception("Invalid for Update - item has an invalid Id"); + // Columns to update. + List columnNames = ExistingColumnNamesNonId.Where(item => !fieldsPrimary.ContainsCI(item) && !fieldsIgnoreOnUpdate.ContainsCI(item)).ToList(); + // Construct query. + String query = "UPDATE " + TableNameFmt + " SET "; + if (dbCommand is SqlCommand) + { + query += StringPairList.CreateFrom(columnNames.Bracket("[","]"),columnNames).Concat("=@").Concat(", ") + " "; + query += "WHERE Id=@Id;"; + } + else + { + query += columnNames.Concat(", ", "", "=?") + " "; + query += "WHERE Id=?;"; + } + dbCommand.CommandText = query; + Log(GetType().Name + ".ExecuteUpdateCommand", dbCommand.CommandText); + // Populate parameters. + dbCommand.Parameters.Clear(); + if (columnNames.ContainsCI("UserAccountId")) AddCommandParameter(dbCommand, "@UserAccountId", _UserAccountId); + if (columnNames.ContainsCI("ConfigType")) AddCommandParameter(dbCommand, "@ConfigType", _ConfigType); + if (columnNames.ContainsCI("ConfigData")) AddCommandParameter(dbCommand, "@ConfigData", _ConfigData); + if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn); + AddCommandParameter(dbCommand, "@Id", _Id); + int executeNonQueryResult = dbCommand.ExecuteNonQuery(); + return (executeNonQueryResult == 1); + } + + //------------------------------------------------------------------- + } +} diff --git a/SaxoniteStandardDbas/Dbas/Internal/UserEligibility_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/UserEligibility_Db.cs index 8a82fcb..bf1ff32 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/UserEligibility_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/UserEligibility_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 13-Oct-2022 09:38:46 +// Code generated by Sarand Database Utilities Tue 15-Nov-2022 13:33:16 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/UserOnline_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/UserOnline_Db.cs index 000435a..d88bc84 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/UserOnline_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/UserOnline_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 13-Oct-2022 09:38:46 +// Code generated by Sarand Database Utilities Tue 15-Nov-2022 13:33:16 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/UserOrganisation_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/UserOrganisation_Db.cs index a72470b..b25c668 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/UserOrganisation_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/UserOrganisation_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 13-Oct-2022 09:38:46 +// Code generated by Sarand Database Utilities Tue 15-Nov-2022 13:33:16 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/UserRole_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/UserRole_Db.cs index 02a2a09..e1bb0fa 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/UserRole_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/UserRole_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 13-Oct-2022 09:38:46 +// Code generated by Sarand Database Utilities Tue 15-Nov-2022 13:33:16 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/UserSession_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/UserSession_Db.cs index 445abd2..c09c726 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/UserSession_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/UserSession_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 13-Oct-2022 09:38:46 +// Code generated by Sarand Database Utilities Tue 15-Nov-2022 13:33:16 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/UserSportExperience_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/UserSportExperience_Db.cs index e38c1ee..515f1e7 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/UserSportExperience_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/UserSportExperience_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 13-Oct-2022 09:38:46 +// Code generated by Sarand Database Utilities Tue 15-Nov-2022 13:33:16 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Internal/UserSport_Db.cs b/SaxoniteStandardDbas/Dbas/Internal/UserSport_Db.cs index 885ed69..3d94ffc 100644 --- a/SaxoniteStandardDbas/Dbas/Internal/UserSport_Db.cs +++ b/SaxoniteStandardDbas/Dbas/Internal/UserSport_Db.cs @@ -9,7 +9,7 @@ using System.Data.Common; using System.Linq; //--------------------------------------------------------------------------- -// Code generated by Sarand Database Utilities Thu 13-Oct-2022 09:38:46 +// Code generated by Sarand Database Utilities Tue 15-Nov-2022 13:33:16 //--------------------------------------------------------------------------- namespace Saxonite.Net.Standard.Dbas.Internal { diff --git a/SaxoniteStandardDbas/Dbas/Mgr/SaxAccountMgr_Dbas-UserConfig.cs b/SaxoniteStandardDbas/Dbas/Mgr/SaxAccountMgr_Dbas-UserConfig.cs new file mode 100644 index 0000000..218776d --- /dev/null +++ b/SaxoniteStandardDbas/Dbas/Mgr/SaxAccountMgr_Dbas-UserConfig.cs @@ -0,0 +1,478 @@ +using Sarand.Net.Standard.Dbas.Data; +using Sarand.Net.Standard.Base.App; +using Sarand.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Base.Core; +using Sarand.Net.Standard.Base.Dbas; +using Saxonite.Base.App; +using Saxonite.Net.Standard.Dbas.Bus; +using Saxonite.Net.Standard.Dbas.Internal; +using Saxonite.Net.Standard.Base.Bus; +using System; +using System.Collections.Generic; +using System.Data.Common; +using System.Text; +using Saxonite.Net.Standard.Base.App; +using System.Linq; +using Sarand.Net.Standard.Base.Utils; + +namespace Saxonite.Net.Standard.Dbas.Mgr +{ + //======================================================================= + partial class SaxAccountMgr_Dbas + { + //******************************************************************* + // Account Mgr - User Config + //******************************************************************* + // Utilities. + private List GetLogProperties(SaxUserConfig userConfig) + { + return new List() + { + new StringPair("Id",SysId.ToString(userConfig.Id)), + new StringPair("UserAccountId",SysId.ToString(userConfig.UserAccountId)), + new StringPair("ConfigType",userConfig.ConfigType.ToString()), + }; + } + + //------------------------------------------------------------------- + // Create item. + public override SaxUserConfig CreateUserConfig(SysId userAccountId, Sax.UserConfigType configType) + { + ClearErrorState(); + return new SaxUserConfig_Dbas(CoreDatabase, null, userAccountId, configType, 0); + } + private SaxUserConfig_Dbas CreateUserConfig(UserConfig_Db dbUserConfig) + { + ClearErrorState(); + SaxUserConfig_Dbas userConfig = new SaxUserConfig_Dbas(CoreDatabase, new SysId(dbUserConfig._Id), new SysId(dbUserConfig._UserAccountId), (Sax.UserConfigType)dbUserConfig._ConfigType, 0); + PopulateFrom(dbUserConfig, userConfig); + return userConfig; + } + + //------------------------------------------------------------------- + // Get item. + public override SaxUserConfig GetUserConfig(SaxUserConfig.Params prm) + { + ClearErrorState(); + return GetUserConfig(GetUserConfigQueryFilter(prm).Concat(" And ", "(", ")")); + } + private SaxUserConfig GetUserConfig(String filter) + { + ClearErrorState(); + long count = GetUserConfigCount(filter); + if (count == 0) return null; + if (count != 1) + { + SetErrorState("Multiple items found"); + return null; + } + SaxUserConfig userConfig = null; + // Query data. + using (var dbConnection = CoreDatabase.CreateConnection()) + using (var dbCommand = dbConnection.CreateCommand()) + { + try + { + dbConnection.Open(); + UserConfig_Db dbUserConfig = new UserConfig_Db(CoreDbInfo); + dbUserConfig.PopulateFrom(dbCommand, aliasUserConfig, filter); + userConfig = CreateUserConfig(dbUserConfig); + } + catch (Exception exc) + { + SetErrorState("Database query exception"); + SaLogger.Warn(GetType().Name + ".GetUserConfig\n\tQuery: " + dbCommand.CommandText + "\n\t" + ExceptionUtil.GetLogMessage(exc)); + } + } + return userConfig; + } + + //------------------------------------------------------------------- + // Validate item. + public override bool IsValidUserConfigData(SaxUserConfig.Data data, SaxUserConfig.ErrField errField) + { + ClearErrorState(); + if (!base.IsValidUserConfigData(data, errField)) return false; + return true; + } + + //------------------------------------------------------------------- + // Insert item. + public override bool InsertUserConfig(SaxUserConfig userConfig, DbUpdateInfo dbUpdateInfo) + { + String fn = GetType().Name + ".InsertUserConfig"; + ClearErrorState(); + if (!IsValidUserConfig(userConfig)) return false; + if (SysId.IsValid(userConfig.Id)) return SetErrorState(ErrorMessage.ValiditemId); + using (var dbConnection = CoreDatabase.CreateConnection()) + using (var dbCommand = dbConnection.CreateCommand()) + { + try + { + dbConnection.Open(); + UserConfig_Db dbUserConfig = new UserConfig_Db(CoreDbInfo); + PopulateTo(dbUserConfig, userConfig, dbUpdateInfo); + if (UserConfig_Db.FieldsNonId.Contains("Id")) + { + // Generate next Id. + dbUserConfig._Id = CoreDatabase.GetNextIdFromTable("UserConfig"); + } + dbUserConfig.ExecuteInsertCommand(dbCommand); + //userConfig.Id = new SysId(dbUserConfig._Id); + userConfig.Changed = false; + if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(userConfig).Concat(": ").Concat("", "\n\t")); + } + catch (Exception exc) { SetErrorState(exc.Message); } + } + return !HasErrorState(); + } + + //------------------------------------------------------------------- + // Update item. + public override bool UpdateUserConfig(SaxUserConfig userConfig, DbUpdateInfo dbUpdateInfo) + { + String fn = GetType().Name + ".UpdateUserConfig"; + ClearErrorState(); + if (!IsValidUserConfig(userConfig)) return false; + if (!SysId.IsValid(userConfig.Id)) return SetErrorState(ErrorMessage.InvalidItemId); + if (!userConfig.Changed) + { + if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(userConfig).Concat(": ").Concat("", "\n\t")); + return true; + } + using (var dbConnection = CoreDatabase.CreateConnection()) + using (var dbCommand = dbConnection.CreateCommand()) + { + try + { + // Retrieve item. + dbConnection.Open(); + UserConfig_Db dbUserConfig = new UserConfig_Db(CoreDbInfo); + dbUserConfig.PopulateFrom(dbCommand, aliasUserConfig, "Id=" + SysId.ToString(userConfig.Id)); + // Update properties. + PopulateTo(dbUserConfig, userConfig, dbUpdateInfo); + dbUserConfig.ExecuteUpdateCommand(dbCommand); + userConfig.Changed = false; + if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(userConfig).Concat(": ").Concat("", "\n\t")); + } + catch (Exception exc) { SetErrorState(exc.Message); } + } + return !HasErrorState(); + } + + //------------------------------------------------------------------- + // Delete item. + public override bool UserConfigCanBeDeleted(SaxUserConfig userConfig) + { + ClearErrorState(); + if (!base.UserConfigCanBeDeleted(userConfig)) return false; + return true; + } + public override bool DeleteUserConfig(SaxUserConfig userConfig, DbUpdateInfo dbUpdateInfo) + { + String fn = GetType().Name + ".DeleteUserConfig"; + ClearErrorState(); + if (!UserConfigCanBeDeleted(userConfig)) return false; + using (var dbConnection = CoreDatabase.CreateConnection()) + using (var dbCommand = dbConnection.CreateCommand()) + { + try + { + // Retrieve item. + dbConnection.Open(); + UserConfig_Db dbUserConfig = new UserConfig_Db(CoreDbInfo); + dbUserConfig.PopulateFrom(dbCommand, aliasUserConfig, "Id=" + SysId.ToString(userConfig.Id)); + // Delete item. + dbCommand.CommandType = System.Data.CommandType.Text; + dbCommand.CommandText = "DELETE FROM " + SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.UserConfig) + " WHERE Id=" + SysId.ToString(userConfig.Id) + ";"; + dbCommand.ExecuteNonQuery(); + userConfig.Changed = false; + if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(userConfig).Concat(": ").Concat("", "\n\t")); + } + catch (Exception exc) { SetErrorState(exc.Message); } + } + return !HasErrorState(); + } + + //------------------------------------------------------------------- + // Copy data properties to and from database. + private void PopulateTo(UserConfig_Db dbUserConfig, SaxUserConfig userConfig, DbUpdateInfo dbUpdateInfo) + { + dbUserConfig._UserAccountId = SysId.ToInt(userConfig.UserAccountId); + dbUserConfig._ConfigType = (short)userConfig.ConfigType; + dbUserConfig._ConfigData = userConfig.ConfigData; + // Common. + //dbUserConfig._Flags = (short)userConfig.Flags; + if (!DateUtil.IsValid(dbUserConfig._CreateOn)) + { + dbUserConfig._CreateOn = DateTime.Now; + } + dbUserConfig._UpdateOn = DateTime.Now; + } + private void PopulateFrom(UserConfig_Db dbUserConfig, SaxUserConfig userConfig) + { + //userConfig.UserAccountId = new SysId(dbUserConfig._UserAccountId); + //userConfig.ConfigType = (Sax.UserConfigType)dbUserConfig._ConfigType; + userConfig.ConfigData = dbUserConfig._ConfigData; + // Common. + userConfig.SetCreateStamp(dbUserConfig._CreateOn, new SysId(), ""); + userConfig.SetUpdateStamp(dbUserConfig._UpdateOn, new SysId(), ""); + userConfig.AcceptChanges(); + } + + //------------------------------------------------------------------- + // Item column definitions. + private static readonly String aliasUserConfig = "UsrCfg"; + private static readonly String aliasUserConfig_UserAccount = "UsrCfg_Usr"; + private static readonly String prefixUserConfig_UserAccount = aliasUserConfig_UserAccount + "_"; + private void SetUserConfigColDfn + (ColumnDfn col, String caption, int width, SaxDbDfn_Core.ColumnIdx dbCol, + ColumnAlignment align = ColumnAlignment.Default, DataValue.DataType dataType = DataValue.DataType.String, + String alias = "", String prefix = "") + { + if (String.IsNullOrEmpty(alias) && SaxDbDfn_Core.GetTableForColumn(dbCol) == SaxDbDfn_Core.TableIdx.UserConfig) + alias = aliasUserConfig; + col.Set(caption, width, (int)dbCol, prefix + SaxDbDfn_Core.GetColumnName(dbCol, false), SaxDbDfn_Core.GetColumnNameQual(dbCol, alias), dataType, align); + if (dataType == DataValue.DataType.String && dbCol != SaxDbDfn_Core.ColumnIdx.Unknown) + col.MaxLength = (int)SaxDbDfn_Core.GetColTextLen(dbCol); + } + public override ColumnDfn GetUserConfigColumnDfn(SaxUserConfig.Column columnId, string caption = "", int width = 0) + { + ColumnDfn columnDfn = new ColumnDfn((int)columnId, caption, width); + switch (columnId) + { + //----------------------------------------------------------- + case SaxUserConfig.Column.Pos: + SetUserConfigColDfn(columnDfn, "Pos", 60, SaxDbDfn_Core.ColumnIdx.Unknown, ColumnAlignment.Right); + columnDfn.SortMode = ColumnDfn.ColumnSortMode.Off; + columnDfn.ReadOnly = true; + columnDfn.Resizable = false; + break; + case SaxUserConfig.Column.UserAccountId: + SetUserConfigColDfn(columnDfn, "User Id", 80, SaxDbDfn_Core.ColumnIdx.UserConfig_UserAccountId, ColumnAlignment.Right, DataValue.DataType.Long); + columnDfn.ReadOnly = true; + break; + + //------------------------------------------------------- + // User. + case SaxUserConfig.Column.User_EmailAddress: + SetUserConfigColDfn(columnDfn, "Email address", 160, SaxDbDfn_Core.ColumnIdx.UserAccount_EmailAddress, ColumnAlignment.Left, DataValue.DataType.String, aliasUserConfig_UserAccount, prefixUserConfig_UserAccount); + columnDfn.ReadOnly = true; + break; + case SaxUserConfig.Column.User_DisplayName: + SetUserConfigColDfn(columnDfn, "User", 160, SaxDbDfn_Core.ColumnIdx.Unknown, ColumnAlignment.Left, DataValue.DataType.String); + columnDfn.ReadOnly = true; + break; + case SaxUserConfig.Column.User_Title: + SetUserConfigColDfn(columnDfn, "Title", 80, SaxDbDfn_Core.ColumnIdx.UserAccount_Title, ColumnAlignment.Left, DataValue.DataType.String, aliasUserConfig_UserAccount, prefixUserConfig_UserAccount); + columnDfn.ReadOnly = true; + break; + case SaxUserConfig.Column.User_FirstName: + SetUserConfigColDfn(columnDfn, "First name", 120, SaxDbDfn_Core.ColumnIdx.UserAccount_FirstName, ColumnAlignment.Left, DataValue.DataType.String, aliasUserConfig_UserAccount, prefixUserConfig_UserAccount); + columnDfn.ReadOnly = true; + break; + case SaxUserConfig.Column.User_LastName: + SetUserConfigColDfn(columnDfn, "Last name", 120, SaxDbDfn_Core.ColumnIdx.UserAccount_LastName, ColumnAlignment.Left, DataValue.DataType.String, aliasUserConfig_UserAccount, prefixUserConfig_UserAccount); + columnDfn.ReadOnly = true; + break; + + //----------------------------------------------------------- + // Configuration. + case SaxUserConfig.Column.ConfigType: + SetUserConfigColDfn(columnDfn, "Type", 60, SaxDbDfn_Core.ColumnIdx.UserConfig_ConfigType, ColumnAlignment.Center, DataValue.DataType.Long); + columnDfn.ReadOnly = true; + break; + + //----------------------------------------------------------- + // Derived properties. + + //----------------------------------------------------------- + // Common properties. + /* + case SaxUserConfig.Column.Flags: + SetUserConfigColDfn(columnDfn, "Flags", 60, SaxDbDfn_Core.ColumnIdx.UserConfig_Flags, ColumnAlignment.Center, DataValue.DataType.Long); + break; + */ + case SaxUserConfig.Column.CreateOn_Date: + SetUserConfigColDfn(columnDfn, "Created", 80, SaxDbDfn_Core.ColumnIdx.UserConfig_CreateOn, ColumnAlignment.Center, DataValue.DataType.Date); + columnDfn.ReadOnly = true; + break; + case SaxUserConfig.Column.UpdateOn_Date: + SetUserConfigColDfn(columnDfn, "Updated", 80, SaxDbDfn_Core.ColumnIdx.UserConfig_UpdateOn, ColumnAlignment.Center, DataValue.DataType.Date); + columnDfn.ReadOnly = true; + break; + //----------------------------------------------------------- + } + if (!String.IsNullOrEmpty(caption)) + columnDfn.Caption = caption; + if (width > 0) + columnDfn.Width = width; + return columnDfn; + } + + //------------------------------------------------------------------- + // Item query filter. + public override List GetUserConfigQueryFilter(SaxUserConfig.Params prm) + { + List filter = new List(); + + // User accounts. + String userAccountIdsIncluded = prm.UserAccountIdsIncluded.Concat(","); + if (!userAccountIdsIncluded.IsEmpty()) + filter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserConfig_UserAccountId, aliasUserConfig) + " IN (" + userAccountIdsIncluded + ")"); + + // Config type. + if (prm.ConfigType > 0) + filter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserConfig_ConfigType, aliasUserConfig) + "=" + ((short)prm.ConfigType).ToString()); + + if (filter.Count < 1) filter.Add("1=1"); + return filter; + } + // Item sort columns. + public List GetUserConfigSortColumns(SaxUserConfig.Params prm) + { + // Sort sequence: + List sortColumnNames = new List(); + foreach (var columnDfn in prm.SortColumns) + { + // Need to ensure correct alias used for UserConfig columns in case of conflict. + String sortCol = String.Empty; + if (SaxDbDfn_Core.GetTableForColumn((SaxDbDfn_Core.ColumnIdx)columnDfn.DbColumn) == SaxDbDfn_Core.TableIdx.UserConfig) + { + sortCol = SaxDbDfn_Core.GetColumnNameQual((SaxDbDfn_Core.ColumnIdx)columnDfn.DbColumn, aliasUserConfig); + } + else + { + sortCol = columnDfn.DataName; + if (!StringUtil.IsEmpty(columnDfn.SortDataName)) + sortCol = columnDfn.SortDataName; + } + if (!sortCol.IsEmpty()) + { + DbOrderByNullMode orderByNullMode = DbOrderByNullMode.Default; // eSaOrderByDemoteNulls, eSaOrderByPromoteNulls + sortColumnNames.Add(DbQuery.FormatForOrderBy(sortCol, columnDfn.SortAscending, orderByNullMode).Concat(", ")); + } + } + sortColumnNames.RemoveBlanks(); + if (sortColumnNames.IsEmpty()) + { + // Default sort columns. + sortColumnNames.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserConfig_UserAccountId, aliasUserConfig) + " ASC"); + sortColumnNames.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserConfig_ConfigType, aliasUserConfig) + " ASC"); + } + return sortColumnNames; + } + + //------------------------------------------------------------------- + // Item count. + private long GetUserConfigCount(String filter) + { + ClearErrorState(); + return CoreDatabase.GetRowCount(SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.UserConfig) + " As " + aliasUserConfig, filter); + } + public override long GetUserConfigCount(SaxUserConfig.Params prm) + { + ClearErrorState(); + return GetUserConfigCount(GetUserConfigQueryFilter(prm).Concat(" AND ", "(", ")")); + } + + //------------------------------------------------------------------- + // Item list. + public override List GetUserConfigList(SaxUserConfig.Params prm) + { + List userConfigs = new List(); + DbQuery qry = new DbQuery(CoreDatabase.DbmsType); + qry.Tables.Add(SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.UserConfig), aliasUserConfig); + UserConfig_Db dbUserConfig = new UserConfig_Db(CoreDbInfo); + qry.Columns.AddRange(dbUserConfig.ExistingColumnNames); + qry.Filters.AddRange(GetUserConfigQueryFilter(prm)); + qry.OrderBy.AddRange(GetUserConfigSortColumns(prm)); + // Query data. + using (var dbConnection = CoreDatabase.CreateConnection()) + using (var dbCommand = dbConnection.CreateCommand()) + { + try + { + dbConnection.Open(); + dbCommand.CommandText = qry.BuildQuery(prm.ResultsPaging); + using (DbDataReader dbDataReader = dbCommand.ExecuteReader()) + { + while (dbDataReader.Read()) + { + dbUserConfig = new UserConfig_Db(CoreDbInfo); + dbUserConfig.PopulateFrom(dbDataReader); + userConfigs.Add(CreateUserConfig(dbUserConfig)); + } + } + } + catch (Exception exc) + { + SaLogger.Warn(GetType().Name + ".GetUserConfigList\n\tQuery: " + dbCommand.CommandText + "\n\t" + ExceptionUtil.GetLogMessage(exc)); + } + } + return userConfigs; + } + + //------------------------------------------------------------------- + // Item query execution. + public override DbResultSet ExecuteUserConfigQuery(List columns, SaxUserConfig.Params prm) + { + ClearErrorState(); + + //--------------------------------------------------------------------- + // Construct query. + DbQuery query = new DbQuery(CoreDatabase.DbmsType); + query.Tables.Add(SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.UserConfig), aliasUserConfig); + + // Add columns as defined in query list. + bool hasUserAccountCols = (columns.HasId(SaxUserConfig.Column.User_EmailAddress) || columns.HasId(SaxUserConfig.Column.User_DisplayName) || columns.HasId(SaxUserConfig.Column.User_Title) || columns.HasId(SaxUserConfig.Column.User_FirstName) || columns.HasId(SaxUserConfig.Column.User_LastName)); + if (columns.HasId(SaxUserConfig.Column.UserAccountId) || hasUserAccountCols) + query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserConfig_UserAccountId, aliasUserConfig)); + if (columns.HasId(SaxUserConfig.Column.ConfigType)) + query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserConfig_ConfigType, aliasUserConfig)); + // Common properties. + //if (columns.HasId(SaxUserConfig.Column.Flags)) + // query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserConfig_Flags, aliasUserConfig)); + if (columns.HasId(SaxUserConfig.Column.CreateOn_Date)) + query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserConfig_CreateOn, aliasUserConfig)); + if (columns.HasId(SaxUserConfig.Column.UpdateOn_Date)) + query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserConfig_UpdateOn, aliasUserConfig)); + + //--------------------------------------------------------------------- + // User Account. + if (hasUserAccountCols) + { + DbQueryJoin joinUserAccount = new DbQueryJoin(DbJoinType.LeftOuter); + joinUserAccount.Table = new StringPair(SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.UserAccount), aliasUserConfig_UserAccount); + joinUserAccount.Filters.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserAccount_Id, aliasUserConfig_UserAccount) + "=" + SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserConfig_UserAccountId, aliasUserConfig)); + query.Joins.Add(joinUserAccount); + List cols = new List(); + cols.Add(SaxDbDfn_Core.ColumnIdx.UserAccount_EmailAddress); + cols.Add(SaxDbDfn_Core.ColumnIdx.UserAccount_Title); + cols.Add(SaxDbDfn_Core.ColumnIdx.UserAccount_FirstName); + cols.Add(SaxDbDfn_Core.ColumnIdx.UserAccount_LastName); + foreach (var col in cols) + query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(col, aliasUserConfig_UserAccount), prefixUserConfig_UserAccount + SaxDbDfn_Core.GetColumnName(col, false)); + } + + //--------------------------------------------------------------------- + // Populate filter. + query.Filters.AddRange(GetUserConfigQueryFilter(prm)); + + // Sort is applied if the results are likely to be more than a single row. + if (prm.UserAccountIdsIncluded.Count != 1 || prm.ConfigType <= 0) + { + // Configure sort sequence. + foreach (String sortColumn in GetUserConfigSortColumns(prm)) + query.OrderBy.Add(sortColumn); + } + + //--------------------------------------------------------------------- + //return new DbResultSet_DataTableReader(db, query.BuildQuery(prm.ResultsPaging)); + return DbResultSet_DataReader.ExecuteQuery(CoreDatabase, query.BuildQuery(prm.ResultsPaging)); + } + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaxoniteStandardDbas/Resources/Database/SaxDbDfn_Core.xml b/SaxoniteStandardDbas/Resources/Database/SaxDbDfn_Core.xml index d326719..9ffe7e6 100644 --- a/SaxoniteStandardDbas/Resources/Database/SaxDbDfn_Core.xml +++ b/SaxoniteStandardDbas/Resources/Database/SaxDbDfn_Core.xml @@ -4888,6 +4888,23 @@ dbo UserAccount
12 + GenderOther + VarChar + + -9 + nvarchar + false + 50 + 100 + 0 + Nullable + true + + + + dbo + UserAccount
+ 13 DateOfBirthDay TinyInt @@ -4904,7 +4921,7 @@ dbo UserAccount
- 13 + 14 DateOfBirthMonth TinyInt @@ -4921,7 +4938,7 @@ dbo UserAccount
- 14 + 15 DateOfBirthYear SmallInt @@ -4938,7 +4955,7 @@ dbo UserAccount
- 15 + 16 RegionIdCountry Int @@ -4955,7 +4972,7 @@ dbo UserAccount
- 16 + 17 RegionIdProvince Int @@ -4972,7 +4989,7 @@ dbo UserAccount
- 17 + 18 JournalistData VarChar @@ -4989,7 +5006,7 @@ dbo UserAccount
- 18 + 19 PasswordToken VarChar @@ -5006,7 +5023,7 @@ dbo UserAccount
- 19 + 20 PasswordHashed VarChar @@ -5023,7 +5040,7 @@ dbo UserAccount
- 20 + 21 PasswordHistory VarChar @@ -5040,7 +5057,7 @@ dbo UserAccount
- 21 + 22 PasswordChangedAt DateTime @@ -5057,7 +5074,7 @@ dbo UserAccount
- 22 + 23 LastLoginAt DateTime @@ -5074,7 +5091,7 @@ dbo UserAccount
- 23 + 24 LastInvalidLoginAt DateTime @@ -5091,7 +5108,7 @@ dbo UserAccount
- 24 + 25 InvalidLoginCount SmallInt @@ -5108,7 +5125,7 @@ dbo UserAccount
- 25 + 26 Notes VarChar @@ -5125,7 +5142,7 @@ dbo UserAccount
- 26 + 27 Flags SmallInt @@ -5142,7 +5159,7 @@ dbo UserAccount
- 27 + 28 Status VarChar @@ -5159,7 +5176,7 @@ dbo UserAccount
- 28 + 29 CreateOn DateTime @@ -5176,7 +5193,7 @@ dbo UserAccount
- 29 + 30 CreateBy Int @@ -5193,7 +5210,7 @@ dbo UserAccount
- 30 + 31 CreateHost VarChar @@ -5210,7 +5227,7 @@ dbo UserAccount
- 31 + 32 UpdateOn DateTime @@ -5227,7 +5244,7 @@ dbo UserAccount
- 32 + 33 UpdateBy Int @@ -5244,7 +5261,7 @@ dbo UserAccount
- 33 + 34 UpdateHost VarChar @@ -5845,6 +5862,162 @@ + + dbo + UserConfig + + + + dbo + UserConfig
+ 1 + Id + BigInt + + -5 + bigint + true + 19 + 8 + 0 + NoNulls + false + +
+ + dbo + UserConfig
+ 2 + UserAccountId + Int + + 4 + int + false + 10 + 4 + 0 + NoNulls + false + +
+ + dbo + UserConfig
+ 3 + ConfigType + SmallInt + + 5 + smallint + false + 5 + 2 + 0 + Nullable + true + +
+ + dbo + UserConfig
+ 4 + ConfigData + VarChar + + -9 + nvarchar + false + 0 + 0 + 0 + NoNulls + false + +
+ + dbo + UserConfig
+ 5 + CreateOn + DateTime + + 93 + datetime + false + 23 + 16 + 3 + NoNulls + false + +
+ + dbo + UserConfig
+ 6 + UpdateOn + DateTime + + 93 + datetime + false + 23 + 16 + 3 + NoNulls + false + +
+
+ + + dbo + UserConfig
+ PK_UserConfig + 1 + true + false + false + false + 0 + 0 + false + + + 1 + Id + true + + +
+ + dbo + UserConfig
+ IX_UserConfig_User_Type + 3 + true + false + false + false + 0 + 0 + false + + + 1 + UserAccountId + true + + + 2 + ConfigType + true + + +
+
+
dbo UserEligibility @@ -6130,7 +6303,7 @@ dbo UserEligibility
- IDX_UserEligibility_User_Region_Eligibilty + IDX_UserEligibility_User_Region_Eligibility 3 true false @@ -7410,7 +7583,7 @@ false false 1 - 15 + 16 false