v1.0.6.0
Refresh Online Session with profile region and sports.
This commit is contained in:
@@ -18,7 +18,7 @@ namespace Saxonite.Net.Standard.Base.App
|
||||
//-------------------------------------------------------------------
|
||||
public static class Version
|
||||
{
|
||||
private static String version { get; } = "1.0.5.3";
|
||||
private static String version { get; } = "1.0.6.0";
|
||||
// Retrieve version.
|
||||
public static String GetFullVersion () { return version; }
|
||||
public static String GetAppVersion ()
|
||||
@@ -39,6 +39,9 @@ namespace Saxonite.Net.Standard.Base.App
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Version history.
|
||||
//-------------------------------------------------------------------
|
||||
// 1.0.6 ?-Jun-2021 ???
|
||||
// - ?.
|
||||
// 1.0.5 31-May-2021 Activity Index
|
||||
// - Admin Database Schema (Home) and Tables page.
|
||||
// - Online Account country, Home activities.
|
||||
|
||||
@@ -88,6 +88,8 @@ namespace Saxonite.Net.Standard.Base.App
|
||||
public enum CodeType
|
||||
{
|
||||
YesNo,
|
||||
SportParticipation,
|
||||
SportOfficiating,
|
||||
RegionType,
|
||||
UserRole,
|
||||
Title,
|
||||
@@ -170,10 +172,23 @@ namespace Saxonite.Net.Standard.Base.App
|
||||
{
|
||||
Unknown = 0,
|
||||
/* Do not change the values/codes - tied to database. */
|
||||
Regular,
|
||||
Occasional,
|
||||
Spectator,
|
||||
Interested
|
||||
Professional = 100,
|
||||
Regular = 200,
|
||||
Occasional = 300,
|
||||
Spectator = 400,
|
||||
Interested = 900,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Sport Officiating</summary>
|
||||
public enum SportOfficiating
|
||||
{
|
||||
Unknown = 0,
|
||||
/* Do not change the values/codes - tied to database. */
|
||||
Professional = 100,
|
||||
Regular = 200,
|
||||
Occasional = 300,
|
||||
Interested = 900,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Tue 25-May-2021 19:36:10
|
||||
// Code generated by Sarand Database Utilities Wed 2-Jun-2021 15:39:57
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Saxonite.Base.App
|
||||
{
|
||||
@@ -201,6 +201,8 @@ namespace Saxonite.Base.App
|
||||
UserSport_Id,
|
||||
UserSport_UserAccountId,
|
||||
UserSport_SportId,
|
||||
UserSport_Participation,
|
||||
UserSport_Officiating,
|
||||
UserSport_UserSportData,
|
||||
UserSport_Notes,
|
||||
UserSport_Flags,
|
||||
@@ -216,7 +218,7 @@ namespace Saxonite.Base.App
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private static readonly int tableCount = 11;
|
||||
private static readonly int columnCount = 176;
|
||||
private static readonly int columnCount = 178;
|
||||
private static ulong maxTextLen = 0;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -565,6 +567,8 @@ namespace Saxonite.Base.App
|
||||
new ColumnDfn(11,"Id",4,4,true,10),
|
||||
new ColumnDfn(11,"UserAccountId",4,4,false,10),
|
||||
new ColumnDfn(11,"SportId",4,4,false,10),
|
||||
new ColumnDfn(11,"Participation",3,5,false,5),
|
||||
new ColumnDfn(11,"Officiating",3,5,false,5),
|
||||
new ColumnDfn(11,"UserSportData",0,-9,false,0),
|
||||
new ColumnDfn(11,"Notes",0,-9,false,2000),
|
||||
new ColumnDfn(11,"Flags",3,5,false,5),
|
||||
|
||||
@@ -87,13 +87,15 @@ namespace Saxonite.Net.Standard.Base.App
|
||||
//-------------------------------------------------------------------
|
||||
// System codes.
|
||||
private readonly Dictionary<Sax.CodeType, List<TypeCodeDesc>> codeTypes = new Dictionary<Sax.CodeType, List<TypeCodeDesc>>();
|
||||
public List<TypeCodeDesc> RegionTypes { get { return GetCodesOfType(Sax.CodeType.RegionType); } }
|
||||
public List<TypeCodeDesc> UserRoles { get { return GetCodesOfType(Sax.CodeType.UserRole); } }
|
||||
public List<TypeCodeDesc> OrganisationTypes { get { return GetCodesOfType(Sax.CodeType.OrganisationType); } }
|
||||
public List<TypeCodeDesc> OrganisationCategories { get { return GetCodesOfType(Sax.CodeType.OrganisationCategory); } }
|
||||
public List<TypeCodeDesc> OrganisationRoles { get { return GetCodesOfType(Sax.CodeType.OrganisationRole); } }
|
||||
public List<TypeCodeDesc> OpportunityTypes { get { return GetCodesOfType(Sax.CodeType.OpportunityType); } }
|
||||
public List<TypeCodeDesc> DataItemTypes { get { return GetCodesOfType(Sax.CodeType.DataItemType); } }
|
||||
public List<TypeCodeDesc> SportParticipationCodes { get { return GetCodesOfType(Sax.CodeType.SportParticipation); } }
|
||||
public List<TypeCodeDesc> SportOfficiatingCodes { get { return GetCodesOfType(Sax.CodeType.SportOfficiating); } }
|
||||
public List<TypeCodeDesc> RegionTypeCodes { get { return GetCodesOfType(Sax.CodeType.RegionType); } }
|
||||
public List<TypeCodeDesc> UserRoleCodes { get { return GetCodesOfType(Sax.CodeType.UserRole); } }
|
||||
public List<TypeCodeDesc> OrganisationTypeCodes { get { return GetCodesOfType(Sax.CodeType.OrganisationType); } }
|
||||
public List<TypeCodeDesc> OrganisationCategoryCodes { get { return GetCodesOfType(Sax.CodeType.OrganisationCategory); } }
|
||||
public List<TypeCodeDesc> OrganisationRoleCodes { get { return GetCodesOfType(Sax.CodeType.OrganisationRole); } }
|
||||
public List<TypeCodeDesc> OpportunityTypeCodes { get { return GetCodesOfType(Sax.CodeType.OpportunityType); } }
|
||||
public List<TypeCodeDesc> DataItemTypeCodes { get { return GetCodesOfType(Sax.CodeType.DataItemType); } }
|
||||
public List<TypeCodeDesc> GetCodesOfType(Sax.CodeType codeType)
|
||||
{
|
||||
if (!codeTypes.ContainsKey(codeType))
|
||||
|
||||
@@ -14,7 +14,7 @@ using Newtonsoft.Json.Converters;
|
||||
namespace Saxonite.Net.Standard.Base.App
|
||||
{
|
||||
//=======================================================================
|
||||
public class SaxSessionData
|
||||
public abstract class SaxSessionData
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Protected construction.
|
||||
@@ -28,7 +28,7 @@ namespace Saxonite.Net.Standard.Base.App
|
||||
private SaxSessionData(SaxSessionContext sessionContext)
|
||||
{
|
||||
SessionContext = sessionContext;
|
||||
User = new UserData(SessionContext, null, null);
|
||||
userData = CreateUserData(SessionContext, null, null);
|
||||
}
|
||||
/// <summary>
|
||||
/// Primary constructor - on user login.
|
||||
@@ -38,7 +38,7 @@ namespace Saxonite.Net.Standard.Base.App
|
||||
protected SaxSessionData(SaxSessionContext sessionContext, SaxUserAccount userAccount, List<SaxUserRole> userRoles)
|
||||
{
|
||||
SessionContext = sessionContext;
|
||||
User = new UserData(SessionContext, userAccount, userRoles);
|
||||
userData = CreateUserData(SessionContext, userAccount, userRoles);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -60,17 +60,12 @@ namespace Saxonite.Net.Standard.Base.App
|
||||
public class UserData
|
||||
{
|
||||
protected UserData() { }
|
||||
public UserData(SaxSessionContext sessionContext, SaxUserAccount userAccount, List<SaxUserRole> userRoles)
|
||||
protected UserData(SaxSessionContext sessionContext, SaxUserAccount userAccount, List<SaxUserRole> userRoles)
|
||||
{
|
||||
if (userAccount != null)
|
||||
{
|
||||
UserAccountId = userAccount.Id;
|
||||
FirstName = userAccount.FirstName;
|
||||
LastName = userAccount.LastName;
|
||||
DisplayName = userAccount.GetDisplayName();
|
||||
EmailAddress = userAccount.EmailAddress;
|
||||
RegionIdCountry = userAccount.RegionIdCountry;
|
||||
RegionIdProvince = userAccount.RegionIdProvince;
|
||||
RefreshUserData(userAccount);
|
||||
if (sessionContext.Application == Sax.Application.Admin)
|
||||
KeepLoggedIn = userAccount.KeepLoggedIn_Admin;
|
||||
else if (sessionContext.Application == Sax.Application.Online)
|
||||
@@ -84,7 +79,22 @@ namespace Saxonite.Net.Standard.Base.App
|
||||
}
|
||||
}
|
||||
}
|
||||
protected UserData(UserData userData)
|
||||
{
|
||||
UserAccountId = userData.UserAccountId;
|
||||
Title = userData.Title;
|
||||
FirstName = userData.FirstName;
|
||||
LastName = userData.LastName;
|
||||
DisplayName = userData.DisplayName;
|
||||
EmailAddress = userData.EmailAddress;
|
||||
RegionIdCountry = userData.RegionIdCountry;
|
||||
RegionIdProvince = userData.RegionIdProvince;
|
||||
KeepLoggedIn = userData.KeepLoggedIn;
|
||||
roles.AddRange(userData.Roles);
|
||||
}
|
||||
// Properties.
|
||||
public SysId UserAccountId { get; protected set; }
|
||||
public String Title { get; protected set; }
|
||||
public String FirstName { get; protected set; }
|
||||
public String LastName { get; protected set; }
|
||||
public String DisplayName { get; protected set; }
|
||||
@@ -93,6 +103,21 @@ namespace Saxonite.Net.Standard.Base.App
|
||||
public SysId RegionIdProvince { get; protected set; }
|
||||
public bool KeepLoggedIn { get; protected set; }
|
||||
public bool UserAccountSupplied { get; protected set; }
|
||||
// Refresh properties.
|
||||
protected bool RefreshUserData(SaxUserAccount userAccount)
|
||||
{
|
||||
// Check that user matches the session.
|
||||
if (!SysId.IsValid(UserAccountId) || !SysId.IsValid(userAccount?.Id ?? null) || !UserAccountId.Equals(userAccount.Id)) return false;
|
||||
// Refresh properties.
|
||||
Title = userAccount.Title;
|
||||
FirstName = userAccount.FirstName;
|
||||
LastName = userAccount.LastName;
|
||||
DisplayName = userAccount.GetDisplayName();
|
||||
EmailAddress = userAccount.EmailAddress;
|
||||
RegionIdCountry = userAccount.RegionIdCountry;
|
||||
RegionIdProvince = userAccount.RegionIdProvince;
|
||||
return true;
|
||||
}
|
||||
// Roles.
|
||||
public class RoleData
|
||||
{
|
||||
@@ -107,19 +132,20 @@ namespace Saxonite.Net.Standard.Base.App
|
||||
public Sax.UserRole Role { get; protected set; }
|
||||
public SaStatus Status { get; protected set; }
|
||||
}
|
||||
[JsonIgnore]
|
||||
private readonly List<RoleData> roles = new List<RoleData>();
|
||||
public List<RoleData> Roles { get { return new List<RoleData>(roles); } protected set { roles.Clear(); roles.AddRange(value); } }
|
||||
[JsonIgnore]
|
||||
public bool IsJournalist { get { return roles?.Exists(item => item.Role == Sax.UserRole.Journalist) ?? false; } }
|
||||
}
|
||||
public UserData User { get; private set; }
|
||||
protected abstract UserData CreateUserData(SaxSessionContext sessionContext, SaxUserAccount userAccount, List<SaxUserRole> userRoles);
|
||||
private UserData userData;
|
||||
public UserData User { get { return userData; } }
|
||||
/// <summary>User - JSON deserialisation route.</summary>
|
||||
protected void SetUser(UserData user)
|
||||
{
|
||||
if (User != null && User.UserAccountSupplied)
|
||||
if (this.userData != null && User.UserAccountSupplied)
|
||||
throw new NotSupportedException("Session User cannot be replaced.");
|
||||
User = user;
|
||||
this.userData = user;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -14,8 +14,10 @@ namespace Saxonite.Net.Standard.Base.App
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
// Code types.
|
||||
private static readonly List<TypeCodeDesc> regionTypeCodes = new List<TypeCodeDesc>();
|
||||
private static readonly List<TypeCodeDesc> yesNoCodes = new List<TypeCodeDesc>();
|
||||
private static readonly List<TypeCodeDesc> sportParticipationCodes = new List<TypeCodeDesc>();
|
||||
private static readonly List<TypeCodeDesc> sportOfficiatingCodes = new List<TypeCodeDesc>();
|
||||
private static readonly List<TypeCodeDesc> regionTypeCodes = new List<TypeCodeDesc>();
|
||||
private static readonly List<TypeCodeDesc> userRoleCodes = new List<TypeCodeDesc>();
|
||||
private static readonly List<TypeCodeDesc> titleCodes = new List<TypeCodeDesc>();
|
||||
private static readonly List<TypeCodeDesc> organisationTypeCodes = new List<TypeCodeDesc>();
|
||||
@@ -33,6 +35,20 @@ namespace Saxonite.Net.Standard.Base.App
|
||||
yesNoCodes.Add(Sax.YesNo.Yes, "YES", "Yes");
|
||||
yesNoCodes.Add(Sax.YesNo.No, "NO", "No");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Sport participation.
|
||||
sportParticipationCodes.Add(Sax.SportParticipation.Professional, "PRO", "Professional");
|
||||
sportParticipationCodes.Add(Sax.SportParticipation.Regular, "REG", "Regular");
|
||||
sportParticipationCodes.Add(Sax.SportParticipation.Occasional, "OCC", "Occasional");
|
||||
sportParticipationCodes.Add(Sax.SportParticipation.Spectator, "SPC", "Spectator");
|
||||
sportParticipationCodes.Add(Sax.SportParticipation.Interested, "INT", "Interested");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Sport officiating.
|
||||
sportOfficiatingCodes.Add(Sax.SportParticipation.Professional, "PRO", "Professional");
|
||||
sportOfficiatingCodes.Add(Sax.SportParticipation.Regular, "REG", "Regular");
|
||||
sportOfficiatingCodes.Add(Sax.SportParticipation.Occasional, "OCC", "Occasional");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Region types.
|
||||
regionTypeCodes.Add(Sax.RegionType.Continent, "CONT", "Continent");
|
||||
|
||||
@@ -38,6 +38,10 @@ namespace Saxonite.Net.Standard.Base.App
|
||||
{
|
||||
case Sax.CodeType.YesNo:
|
||||
return new List<TypeCodeDesc>(yesNoCodes);
|
||||
case Sax.CodeType.SportParticipation:
|
||||
return new List<TypeCodeDesc>(sportParticipationCodes);
|
||||
case Sax.CodeType.SportOfficiating:
|
||||
return new List<TypeCodeDesc>(sportOfficiatingCodes);
|
||||
case Sax.CodeType.RegionType:
|
||||
return new List<TypeCodeDesc>(regionTypeCodes);
|
||||
case Sax.CodeType.UserRole:
|
||||
|
||||
Reference in New Issue
Block a user