This commit is contained in:
2021-11-20 15:17:48 +00:00
parent 806ebb4024
commit 74fb9448ec
68 changed files with 4117 additions and 794 deletions
+6
View File
@@ -261,6 +261,12 @@ namespace Saxonite.Net.Core.Web.Base.App
return GetCodeTypeCaption(Sax.CodeType.OrganisationRole, organisationRole);
}
// Event type.
public String GetEventTypeCaption(Sax.EventType eventType)
{
return GetCodeTypeCaption(Sax.CodeType.EventType, eventType);
}
// Opportunity type.
public String GetOpportunityTypeCaption(Sax.OpportunityType opportunityType)
{
@@ -75,6 +75,8 @@ namespace Saxonite.Net.Core.Web.Base.Consoles
if (!(new List<Sax.DataItemType>() { Sax.DataItemType.Sport, Sax.DataItemType.Region }).Contains(itemType))
return candidateValue;
lock (data.encryptedIdCache)
{
Dictionary<SysId, String> itemIds = data.encryptedIdCache.GetValue(itemType, null);
if (itemIds == null)
{
@@ -91,6 +93,7 @@ namespace Saxonite.Net.Core.Web.Base.Consoles
}
return encryptedId;
}
}
//-------------------------------------------------------------------
// Regions.
@@ -119,6 +119,7 @@ namespace Saxonite.Net.Core.Web.Base.Controllers
public List<TypeCodeDesc> OrganisationCategoryCodes { get { return Internals.OrganisationCategoryCodes; } }
public List<TypeCodeDesc> OrganisationRoleCodes { get { return Internals.OrganisationRoleCodes; } }
public List<TypeCodeDesc> AddressTypeCodes { get { return Internals.AddressTypeCodes; } }
public List<TypeCodeDesc> EventTypeCodes { get { return Internals.EventTypeCodes; } }
public List<TypeCodeDesc> OpportunityTypeCodes { get { return Internals.OpportunityTypeCodes; } }
public List<TypeCodeDesc> ActivityReactionCodes { get { return Internals.ActivityReactionCodes; } }
// Email.
@@ -240,7 +241,7 @@ namespace Saxonite.Net.Core.Web.Base.Controllers
// Copy the list of parameters, adding a random name/value pair to randomise the encryption.
NameValueCollection parametersToEncrypt = new NameValueCollection(parameters);
// NB Range 10-189 intended to have equal chance of 2 or 3 digit number.
parametersToEncrypt.Add("!" + SacsRandomHelper.GetInt32(10, 190).ToString(), SacsRandomHelper.GetInt32(10, 190).ToString());
parametersToEncrypt.Add("!" + SacsRandomHelper.getRandomLengthNumber(4), null);
// Sort the keys to ensure that the random '!' param is first in the query string.
String[] paramKeys = parametersToEncrypt.AllKeys;
@@ -249,11 +250,7 @@ namespace Saxonite.Net.Core.Web.Base.Controllers
// Serialise parameters as if in a URL query string - so that they can be deserialised in DecryptParameters() below.
string queryString = String.Join("&", paramKeys.Select(a => a + "=" + HttpUtility.UrlEncode(parametersToEncrypt[a])));
String encrypted = SacsEncryptionHelper.Encrypt(queryString, base64IV, base64Key);
if (SacsSystem.DebugMode)
{
SaLogger.Debug(fn + " Encrypted: " + encrypted);
NameValueCollection decryptedParams = DecryptParameters(encrypted, base64IV, base64Key);
}
if (SacsSystem.DebugMode) SaLogger.Debug(fn + "\n\tData: " + queryString + " \n\tEncrypted: " + encrypted);
return encrypted;
}
catch (Exception exc) { SaLogger.Warn(fn + " " + ExceptionUtil.GetErrorStateMessage(exc)); }
@@ -262,10 +259,10 @@ namespace Saxonite.Net.Core.Web.Base.Controllers
public static NameValueCollection DecryptParameters(String encrypted, String base64IV, String base64Key)
{
String fn = nameof(ControllerBase) + ".DecryptParameters";
if (SacsSystem.DebugMode) SaLogger.Debug(fn + " \n\tEncrypted: " + encrypted + "\n\tIV: " + base64IV + "\n\tKey: " + base64Key);
try
{
String queryString = SacsEncryptionHelper.Decrypt(encrypted, base64IV, base64Key);
if (SacsSystem.DebugMode) SaLogger.Debug(fn + " \n\tEncrypted: " + encrypted + "\n\tData: " + queryString);
return HttpUtility.ParseQueryString(queryString);
}
catch (Exception exc) { SaLogger.Warn(fn + " " + ExceptionUtil.GetErrorStateMessage(exc)); }
@@ -300,10 +297,12 @@ namespace Saxonite.Net.Core.Web.Base.Controllers
// Session.
//-------------------------------------------------------------------
public bool ValidUserSession { get { return SessionData?.ValidUserSession ?? false; } }
public SysId UserAccountId { get { return SessionData?.User?.UserAccountId ?? null; } }
public DbUpdateInfo DbUpdateInfo { get { return SessionData?.DbUpdateInfo ?? new DbUpdateInfo(null, "", SaxSystem.ComputerName); } }
// Referrer.
public String Referer { get { return Request.Headers["Referer"].ToString(); } }
public bool ValidReferer { get { return !StringUtil.IsEmpty(Referer); } }
/// <summary>Store session data, eg. to start a new user session on sign-in.</summary>
protected bool SetSessionData(SaxSessionData sessionData)
{
+5 -4
View File
@@ -65,10 +65,10 @@ namespace Saxonite.Net.Core.Web.Base.Models
protected SaxDataCacheConsole DataCacheConsole { get { return Internals.DataCacheConsole; } }
protected SaxActivityConsole ActivityConsole { get { return Internals.ActivityConsole; } }
// Managers.
protected SaxReferenceMgr ReferenceMgr { get { return Internals.ReferenceMgr; } }
protected SaxAccountMgr AccountMgr { get { return Internals.AccountMgr; } }
protected SaxActivityMgr ActivityMgr { get { return Internals.ActivityMgr; } }
protected SaxItemDataMgr ItemDataMgr { get { return Internals.ItemDataMgr; } }
public SaxReferenceMgr ReferenceMgr { get { return Internals.ReferenceMgr; } }
public SaxAccountMgr AccountMgr { get { return Internals.AccountMgr; } }
public SaxActivityMgr ActivityMgr { get { return Internals.ActivityMgr; } }
public SaxItemDataMgr ItemDataMgr { get { return Internals.ItemDataMgr; } }
// System codes.
public List<TypeCodeDesc> DataItemTypeCodes { get { return Internals.DataItemTypeCodes; } }
public List<TypeCodeDesc> YesNoCodes { get { return Internals.YesNoCodes; } }
@@ -81,6 +81,7 @@ namespace Saxonite.Net.Core.Web.Base.Models
public List<TypeCodeDesc> OrganisationCategoryCodes { get { return Internals.OrganisationCategoryCodes; } }
public List<TypeCodeDesc> OrganisationRoleCodes { get { return Internals.OrganisationRoleCodes; } }
public List<TypeCodeDesc> AddressTypeCodes { get { return Internals.AddressTypeCodes; } }
public List<TypeCodeDesc> EventTypeCodes { get { return Internals.EventTypeCodes; } }
public List<TypeCodeDesc> OpportunityTypeCodes { get { return Internals.OpportunityTypeCodes; } }
public List<TypeCodeDesc> ActivityReactionCodes { get { return Internals.ActivityReactionCodes; } }
@@ -1,4 +1,6 @@
using Saxonite.Net.Core.Web.Base.App;
using Sarand.Net.Standard.Base.Bus;
using Saxonite.Net.Core.Web.Admin.App;
using Saxonite.Net.Core.Web.Base.App;
using Saxonite.Net.Core.Web.Base.Models;
using System;
using System.Collections.Generic;
@@ -17,6 +19,13 @@ namespace Saxonite.Net.Core.Web.Admin.Models
{
}
//-------------------------------------------------------------------
// Properties.
//-------------------------------------------------------------------
// Session.
public SaxSessionData_Admin SessionData_Admin { get { return SessionData as SaxSessionData_Admin; } }
public SysId UserAccountId { get { return SessionData_Admin?.User?.UserAccountId ?? null; } }
//-------------------------------------------------------------------
}
//=======================================================================
@@ -617,6 +617,12 @@ You will then be able to publicise your sporting activities.</value>
<data name="msg.validation.maximum.length" xml:space="preserve">
<value>Value must not exceed {0} characters</value>
</data>
<data name="organisation.caption.event" xml:space="preserve">
<value>Event</value>
</data>
<data name="organisation.caption.events" xml:space="preserve">
<value>Events</value>
</data>
<data name="organisation.caption.member.create" xml:space="preserve">
<value>Add Member</value>
</data>
@@ -74,7 +74,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
// Utilites.
private ItemId GetUserItemId(SysId userAccountId)
{
return new ItemId((short)Sax.DataItemType.UserAccount, SessionData.User.UserAccountId);
return new ItemId((short)Sax.DataItemType.UserAccount, UserAccountId);
}
//-------------------------------------------------------------------
@@ -114,10 +114,10 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
responseData.Months.Add(month.ToString(), DateUtil.Format(new DateTime(DateTime.Today.Year, month, 1), "MMMM", SessionCulture));
// Retrieve user details.
SaxUserAccount userAccount = AccountMgr.GetUserAccountById(SessionData.User.UserAccountId);
SaxUserAccount userAccount = AccountMgr.GetUserAccountById(UserAccountId);
if (userAccount == null)
{
SaLogger.Warn(fn + " Failed to retrieve user account for Id: " + SysId.ToString(SessionData.User.UserAccountId));
SaLogger.Warn(fn + " Failed to retrieve user account for Id: " + SysId.ToString(UserAccountId));
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.something.gone.wrong"]));
}
@@ -191,7 +191,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
return Json(responseData.SetControlError("AccountContactImage", Localiser["msg.upload.image.invalid"]));
// Image belongs to the user's account.
ItemId userItemId = GetUserItemId(SessionData.User.UserAccountId);
ItemId userItemId = GetUserItemId(UserAccountId);
// Store uploaded image as 'Upload' Avatar - awaiting confirmation that the contact details are to be saved.
SaxItemImage itemImage = ItemDataMgr.GetItemImage(userItemId, Sax.ImageType.AvatarUpload, SaxItemImage.StatusCat.Any);
@@ -258,10 +258,10 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
return Json(responseData);
// Retrieve user details.
SaxUserAccount userAccount = AccountMgr.GetUserAccountById(SessionData.User.UserAccountId);
SaxUserAccount userAccount = AccountMgr.GetUserAccountById(UserAccountId);
if (userAccount == null)
{
SaLogger.Warn(fn + " Failed to retrieve user account for Id: " + SysId.ToString(SessionData.User.UserAccountId));
SaLogger.Warn(fn + " Failed to retrieve user account for Id: " + SysId.ToString(UserAccountId));
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.something.gone.wrong"]));
}
if (!userAccount.EmailAddress.EqualsCI(SessionData.User.EmailAddress))
@@ -24,16 +24,14 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
partial class AccountController
{
//-------------------------------------------------------------------
// Account - Get Organisations.
//-------------------------------------------------------------------
private class ProfileOrganisationData
/// <summary>Organisation properteis for list population.</summary>
private class ProfileOrganisationData_List : AjaxResponse_Data.ItemData_Base
{
public long Id { get; set; }
public String Name { get; set; }
public long SportId { get; set; }
public String CategoryDesc { get; set; }
public String TypeDesc { get; set; }
public String SportName { get; set; }
public long RegionId { get; set; }
public String RegionName { get; set; }
public String RegionNameCountry { get; set; }
public long MemberCount { get; set; }
public long OpportunityCount { get; set; }
public bool? Admin { get; set; } = null;
@@ -42,20 +40,96 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
public bool? ScheduleAdmin { get; set; } = null;
public bool? ArticleAdmin { get; set; } = null;
}
private class AjaxResponse_ProfileOrganisationsData : AjaxResponse_Data
/// <summary>Address properties.</summary>
private class AddressData : AjaxResponse_Data.ItemData_Base
{
public String Line1 { get; set; }
public String Line2 { get; set; }
public String Line3 { get; set; }
public String Town { get; set; }
public String Province { get; set; }
public String RegionIdProvince { get; set; }
public String Country { get; set; }
public String PostalCode { get; set; }
}
/// <summary>Organisation properties for popup dialog and form.</summary>
private class ProfileOrganisationData : ProfileOrganisationData_List
{
public String CategoryCode { get; set; }
public String TypeCode { get; set; }
public String SportId { get; set; }
public String RegionIdCountry { get; set; }
public AddressData Address { get; set; }
}
/// <summary>Populate organisation properties for list.</summary>
private void PopulateOrganisationResponseData(SaxModel_Online model, SaxOrganisation organisation, SaxUserOrganisation userOrganisation, ProfileOrganisationData_List data)
{
data.Id = model.EncryptId(organisation.Id);
data.Name = organisation.Name;
data.SportName = model.GetSportCaption(organisation.SportIdPrimary);
data.RegionNameCountry = model.GetRegionCaption(organisation.RegionIdPrimary);
if (userOrganisation != null)
{
List<String> roleCodes = userOrganisation.GetOrganisationRoleCodes();
if (roleCodes.ContainsCI(OrganisationRoleCodes.GetCodeForType(Sax.OrganisationRole.Admin)))
data.Admin = true;
if (roleCodes.ContainsCI(OrganisationRoleCodes.GetCodeForType(Sax.OrganisationRole.MemberAdmin)))
data.MemberAdmin = true;
if (roleCodes.ContainsCI(OrganisationRoleCodes.GetCodeForType(Sax.OrganisationRole.OpportunityAdmin)))
data.OpportunitiyAdmin = true;
if (roleCodes.ContainsCI(OrganisationRoleCodes.GetCodeForType(Sax.OrganisationRole.ScheduleAdmin)))
data.ScheduleAdmin = true;
if (roleCodes.ContainsCI(OrganisationRoleCodes.GetCodeForType(Sax.OrganisationRole.ArticleAdmin)))
data.ArticleAdmin = true;
}
// NB Member and Opportunity counts are only populated for the Organisation list.
data.CreatedOnFmt = Localiser.FormatDate(organisation.CreateStamp.On);
data.UpdatedOnFmt = Localiser.FormatDate(organisation.UpdateStamp.On);
data.StatusCode = organisation.StatusCode;
data.StatusDesc = organisation.StatusDesc;
}
/// <summary>Populate organisation properties for popup dialog and form.</summary>
private void PopulateOrganisationResponseData(SaxModel_Online model, SaxOrganisation organisation, SaxUserOrganisation userOrganisation, SaxItemAddress address, ProfileOrganisationData data)
{
PopulateOrganisationResponseData(model, organisation, userOrganisation, (ProfileOrganisationData_List)data);
data.CategoryCode = OrganisationCategoryCodes.GetCodeForType(organisation.OrganisationCategory);
data.CategoryDesc = Localiser.GetOrganisationCategoryCaption(organisation.OrganisationCategory);
data.TypeCode = OrganisationTypeCodes.GetCodeForType(organisation.OrganisationType);
data.TypeDesc = Localiser.GetOrganisationTypeCaption(organisation.OrganisationType);
data.SportId = model.GetEncryptedSportId(organisation.SportIdPrimary);
data.RegionIdCountry = model.GetEncryptedRegionId(organisation.RegionIdPrimary);
if (address != null)
{
data.Address = new AddressData();
data.Address.Id = model.EncryptId(address.Id);
data.Address.Line1 = address.Line1;
data.Address.Line2 = address.Line2;
data.Address.Line3 = address.Line3;
data.Address.Town = address.Town;
data.Address.Province = address.Province;
data.Address.Country = address.Country;
data.Address.PostalCode = address.PostalCode;
}
}
//-------------------------------------------------------------------
// Account - Get Profile Organisations.
//-------------------------------------------------------------------
private class AjaxResponse_ProfileOrganisationList : AjaxResponse_Data
{
// Construction.
public AjaxResponse_ProfileOrganisationsData(SaxModel_Online model) : base(model) { }
public AjaxResponse_ProfileOrganisationList(SaxModel_Online model) : base(model) { }
// Organisation list.
public List<ProfileOrganisationData> Organisations { get; } = new List<ProfileOrganisationData>();
public List<ProfileOrganisationData_List> Organisations { get; } = new List<ProfileOrganisationData_List>();
}
// Ajax request.
[HttpPost]
[Route("Account/Ajax/GetProfileOrganisations")]
public IActionResult GetProfileOrganisations(Model_Account model)
[Route("Account/Ajax/GetProfileOrganisationList")]
public IActionResult GetProfileOrganisationList(Model_Account model)
{
String fn = GetType().Name + ".GetProfileOrganisations";
AjaxResponse_ProfileOrganisationsData responseData = new AjaxResponse_ProfileOrganisationsData(model);
String fn = GetType().Name + ".GetProfileOrganisationList";
AjaxResponse_ProfileOrganisationList responseData = new AjaxResponse_ProfileOrganisationList(model);
String messageTitle = Localiser["account.caption.profile.organisations"];
// Validate session and referrer.
@@ -63,9 +137,13 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData);
RefreshModel(model);
// Record disposable items as they are created so all can be disposed when needed.
using (DisposableCollection<SacsHierarchyItem> disposableItems = new DisposableCollection<SacsHierarchyItem>())
{
// Query organisations that user is a member of.
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
prmUserOrganisation.UserAccountIdsIncluded.Add(SessionData.User.UserAccountId);
prmUserOrganisation.UserAccountIdsIncluded.Add(UserAccountId);
prmUserOrganisation.OrganisationStatusCat = SaxOrganisation.StatusCat.ActiveOnly;
prmUserOrganisation.OrganisationMembersOnly = true;
prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.ActiveOnly;
@@ -73,12 +151,12 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
List<SysId> organisationIds = userOrganisations.GetOrganisationIds();
// Item columns.
ColumnDfn colId = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Id);
ColumnDfn colOrganisationId = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.OrganisationId);
// NB Although UserOrgansiation data is queried, the response data is a list of Organisations.
ColumnDfn colId = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.OrganisationId);
ColumnDfn colOrganisationName = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_Name);
ColumnDfn colOrganisationSportId = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_SportId);
ColumnDfn colOrganisationCategory = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_Category);
ColumnDfn colOrganisationType = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_Type);
ColumnDfn colOrganisationSportName = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_Sport_Name);
ColumnDfn colOrganisationRegionId = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_RegionId);
ColumnDfn colOrganisationRegionName = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_Region_Name);
ColumnDfn colMemberCount = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_Member_Count);
ColumnDfn colOpportunityCount = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_Opportunity_Count);
@@ -87,9 +165,8 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
ColumnDfn colRoleCodes = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.OrganisationRoleCodes);
List<ColumnDfn> columns = new List<ColumnDfn>()
{
colId, colOrganisationId , colOrganisationName,
colOrganisationSportId, colOrganisationSportName,
colOrganisationRegionId, colOrganisationRegionName,
colId, colOrganisationName, colOrganisationCategory, colOrganisationType,
colOrganisationSportName, colOrganisationRegionName,
colMemberCount, colOpportunityCount,
colStatus, colStatus, colCreatedOn,
colRoleCodes
@@ -105,18 +182,23 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
while (resultSet != null && resultSet.HasRows && resultSet.NextRecord())
{
NamedValue.Map values = resultSet.GetRecordValues();
List<String> roleCodes = StringListUtil.Split(values.GetString(colRoleCodes.DataName), ",");
ProfileOrganisationData organisationData = new ProfileOrganisationData()
Sax.OrganisationCategory organisationCategory = (Sax.OrganisationCategory)OrganisationCategoryCodes.GetTypeForCode(values.GetString(colOrganisationCategory.DataName));
Sax.OrganisationType organisationType = (Sax.OrganisationType)OrganisationTypeCodes.GetTypeForCode(values.GetString(colOrganisationType.DataName));
ProfileOrganisationData_List organisationData = new ProfileOrganisationData_List()
{
Id = values.GetLong(colId.DataName),
Id = model.EncryptId(new SysId(values.GetLong(colId.DataName))),
Name = values.GetString(colOrganisationName.DataName),
SportId = values.GetLong(colOrganisationSportId.DataName),
CategoryDesc = Localiser.GetOrganisationCategoryCaption(organisationCategory),
TypeDesc = Localiser.GetOrganisationTypeCaption(organisationType),
//SportId = model.EncryptId(new SysId(values.GetLong(colOrganisationSportId.DataName))),
SportName = values.GetString(colOrganisationSportName.DataName),
RegionId = values.GetLong(colOrganisationRegionId.DataName),
RegionName = values.GetString(colOrganisationRegionName.DataName),
//RegionId = model.EncryptId(new SysId(values.GetLong(colOrganisationRegionId.DataName))),
RegionNameCountry = values.GetString(colOrganisationRegionName.DataName),
MemberCount = values.GetLong(colMemberCount.DataName),
OpportunityCount = values.GetLong(colOpportunityCount.DataName)
};
// Roles.
List<String> roleCodes = StringListUtil.Split(values.GetString(colRoleCodes.DataName), SaxUserOrganisation.UserOrgnisationRoleDelim);
if (roleCodes.ContainsCI(OrganisationRoleCodes.GetCodeForType(Sax.OrganisationRole.Admin)))
organisationData.Admin = true;
if (roleCodes.ContainsCI(OrganisationRoleCodes.GetCodeForType(Sax.OrganisationRole.MemberAdmin)))
@@ -130,6 +212,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
responseData.Organisations.Add(organisationData);
}
}
}
if (model.Paging.IsPaged)
model.Paging.ItemCount = (ushort)responseData.Organisations.Count;
@@ -139,6 +222,260 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
return Json(responseData);
}
//-------------------------------------------------------------------
// Account - Get Profile Organisation.
//-------------------------------------------------------------------
private class AjaxResponse_ProfileOrganisation : AjaxResponse_Data
{
// Construction.
public AjaxResponse_ProfileOrganisation(SaxModel_Online model) : base(model) { }
// Organisation list.
public ProfileOrganisationData Organisation { get; set; }
}
// Ajax request.
[HttpPost]
[Route("Account/Ajax/GetProfileOrganisation")]
public IActionResult GetProfileOrganisation(Model_Account model)
{
String fn = GetType().Name + ".GetProfileOrganisation";
AjaxResponse_ProfileOrganisation responseData = new AjaxResponse_ProfileOrganisation(model);
String messageTitle = Localiser["label.organisation"];
// 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<SacsHierarchyItem> disposableItems = new DisposableCollection<SacsHierarchyItem>())
{
// Identify item.
SysId organisationId = model.ExtractSysId(model.Organisation.Id);
if (!SysId.IsValid(organisationId))
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.specified"]));
// Retrieve item.
SaxOrganisation organisation = AccountMgr.GetOrganisationById(organisationId);
disposableItems.Add(organisation);
if (organisation == null)
{
SaLogger.Warn(fn + " Failed to retrieve Organisation for Id: " + organisationId.ToString());
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
}
// Organisation address.
SaxItemAddress address = ItemDataMgr.GetFirstItemAddressByItemAndType(organisation.GetItemId());
disposableItems.Add(address);
// Check whether user is a member of this organisation.
SaxUserOrganisation userOrganisation = AccountMgr.GetUserOrganisationByUserOrganisation(UserAccountId, organisationId);
disposableItems.Add(userOrganisation);
if (userOrganisation != null)
{
// Make a note of the selected Organisation.
SessionData_Online.Filter.SetMemberOrganisation(organisation);
}
// Construct response.
responseData.Organisation = new ProfileOrganisationData();
PopulateOrganisationResponseData(model, organisation, userOrganisation, address, responseData.Organisation);
}
// Complete response.
responseData.Success = true;
return Json(responseData);
}
//-------------------------------------------------------------------
// Account - Store Profile Organisation.
//-------------------------------------------------------------------
private class AjaxResponse_StoreProfileOrganisation : AjaxResponse_Data
{
// Construction.
public AjaxResponse_StoreProfileOrganisation(SaxModel_Online model) : base(model) { }
// Organisation list.
public ProfileOrganisationData Organisation { get; set; }
}
// Ajax request.
[HttpPost]
[Route("Account/Ajax/StoreProfileOrganisation")]
public IActionResult StoreProfileOrganisation(Model_Account model)
{
String fn = GetType().Name + ".StoreProfileOrganisation";
AjaxResponse_StoreProfileOrganisation responseData = new AjaxResponse_StoreProfileOrganisation(model);
String messageTitle = Localiser["label.organisation"];
// 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<SacsHierarchyItem> disposableItems = new DisposableCollection<SacsHierarchyItem>())
{
// Retrieve organisation.
SysId organisationId = model.ExtractSysId(model.Organisation.Id);
if (!SysId.IsValid(organisationId))
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.specified"]));
SaxOrganisation organisation = AccountMgr.GetOrganisationById(organisationId);
disposableItems.Add(organisation);
if (organisation == null)
{
SaLogger.Warn(fn + " Failed to retrieve Organisation for Id: " + organisationId.ToString() + ". " + GetLogSuffix());
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
}
// Organisation address.
SaxItemAddress organisationAddress = ItemDataMgr.GetFirstItemAddressByItemAndType(organisation.GetItemId());
disposableItems.Add(organisationAddress);
if (!StringUtil.IsEmpty(model.Organisation.Address.Id))
{
// Validate supplied Address Id.
SysId organisationAddressId = model.ExtractSysId(model.Organisation.Address.Id);
if (organisationAddress != null)
{
if (!organisationAddress.Id.Equals(organisationAddressId))
{
SaLogger.Warn(fn + " Organisation Address Id mismatch. Supplied: " + organisationAddressId + ". Found: " + organisationAddress.Id + ". " + GetLogSuffix());
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
}
}
else
{
SaLogger.Warn(fn + " Organisation Address Id supplied (" + organisationAddressId + ") but no address found for Organisation. " + GetLogSuffix());
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
}
}
else
{
// Address Id not supplied.
if (organisationAddress == null)
{
organisationAddress = ItemDataMgr.CreateItemAddress(organisation.GetItemId(), SaxItemAddress.DefaultOrganisationAddressType);
disposableItems.Add(organisationAddress);
}
else
{
SaLogger.Warn(fn + " Organisation Address Id not supplied but no address found for Organisation. Id: " + organisationAddress.Id + ". " + GetLogSuffix());
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
}
}
// Check whether user is a member of this organisation.
SaxUserOrganisation userOrganisation = AccountMgr.GetUserOrganisationByUserOrganisation(UserAccountId, organisationId);
disposableItems.Add(userOrganisation);
if (userOrganisation == null)
{
SaLogger.Warn(fn + " Account: " + SessionData.User.EmailAddress + ". OrganisationId: " + organisationId.ToString() + ". User Organisation not found. " + GetLogSuffix());
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
}
if (!userOrganisation.GetOrganisationRoles().Contains(Sax.OrganisationRole.Admin))
{
SaLogger.Warn(fn + " Account: " + SessionData.User.EmailAddress + ". OrganisationId: " + organisationId.ToString() + ". User does not have Admin role to update organisation. " + GetLogSuffix());
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
}
// Validate organisation data.
model.ValidateProfileOrganisationData(responseData);
if (responseData.HasControlErrors())
return Json(responseData);
// Regions.
SysId regionIdCountry = model.ExtractSysId(model.Organisation.RegionIdCountry);
SaxRegion.Data regionCountry = Internals.GetRegion(regionIdCountry);
if (SysId.IsValid(regionIdCountry) && regionCountry == null)
{
SaLogger.Warn(fn + " Country region not found. Id: " + model.Organisation.RegionIdCountry + ". " + GetLogSuffix());
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
}
SysId regionIdAddressProvince = model.ExtractSysId(model.Organisation.Address.RegionIdProvince);
SaxRegion.Data regionProvince = Internals.GetRegion(regionIdAddressProvince);
if (SysId.IsValid(regionIdAddressProvince) && regionProvince == null)
{
SaLogger.Warn(fn + " Province region not found. Id: " + model.Organisation.Address.RegionIdProvince + ". " + GetLogSuffix());
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
}
// Update organisation.
if (model.Organisation.Name != null)
organisation.Name = model.Organisation.Name;
if (model.Organisation.Type != null)
organisation.OrganisationType = model.Organisation.GetOrganisationType();
if (model.Organisation.Category != null)
organisation.OrganisationCategory = model.Organisation.GetOrganisationCategory();
if (model.Organisation.SportId != null)
organisation.SportIdPrimary = model.ExtractSysId(model.Organisation.SportId);
if (model.Organisation.RegionIdCountry != null)
organisation.RegionIdPrimary = model.ExtractSysId(model.Organisation.RegionIdCountry);
if (model.Organisation.PhoneMain != null)
organisation.PhoneMain = model.Organisation.PhoneMain;
if (!AccountMgr.UpdateOrganisation(organisation, DbUpdateInfo))
{
SaLogger.Warn(fn + " Failed to update organisation - " + AccountMgr.ErrorStateMessage);
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
}
// Store address.
if (model.Organisation.Address.Line1 != null)
organisationAddress.Line1 = model.Organisation.Address.Line1;
if (model.Organisation.Address.Line2 != null)
organisationAddress.Line2 = model.Organisation.Address.Line2;
if (model.Organisation.Address.Line3 != null)
organisationAddress.Line3 = model.Organisation.Address.Line3;
if (model.Organisation.Address.Town != null)
organisationAddress.Town = model.Organisation.Address.Town;
if (regionProvince != null)
{
organisationAddress.Province = regionProvince.Name;
organisationAddress.RegionIdProvince = regionProvince.Id;
}
else
{
if (model.Organisation.Address.Province != null)
organisationAddress.Province = model.Organisation.Address.Province;
}
if (regionCountry != null)
{
organisationAddress.Country = regionCountry.Name;
organisationAddress.RegionIdCountry = regionCountry.Id;
}
else
{
if (model.Organisation.Address.Country != null)
organisationAddress.Country = model.Organisation.Address.Country;
}
organisationAddress.PostalCode = model.Organisation.Address.PostalCode;
if (!SysId.IsValid(organisationAddress.Id))
{
// Create new address.
if (!ItemDataMgr.InsertItemAddress(organisationAddress, DbUpdateInfo))
{
SaLogger.Warn(fn + " Failed to insert organisation address - " + ItemDataMgr.ErrorStateMessage);
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
}
}
else
{
// Update existing address.
if (!ItemDataMgr.UpdateItemAddress(organisationAddress, DbUpdateInfo))
{
SaLogger.Warn(fn + " Failed to update organisation address - " + ItemDataMgr.ErrorStateMessage);
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
}
}
// Construct response.
responseData.Organisation = new ProfileOrganisationData();
PopulateOrganisationResponseData(model, organisation, userOrganisation, organisationAddress, responseData.Organisation);
}
// Complete response.
responseData.Success = true;
return Json(responseData);
}
//-------------------------------------------------------------------
}
//=======================================================================
@@ -81,7 +81,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
// Item filter.
SaxUserSport.Params prmUserSport = new SaxUserSport.Params();
prmUserSport.UserAccountIdsIncluded.Add(SessionData.User.UserAccountId);
prmUserSport.UserAccountIdsIncluded.Add(UserAccountId);
prmUserSport.StatusCat = SaxUserSport.StatusCat.NotDeleted;
model.Paging.ItemTotal = (ulong)AccountMgr.GetUserSportCount(prmUserSport);
model.PopulatePagingTo(prmUserSport.ResultsPaging);
@@ -250,7 +250,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
if (userSport == null)
{
SaxUserSport.Params prmUserSport = new SaxUserSport.Params();
prmUserSport.UserAccountIdsIncluded.Add(SessionData.User.UserAccountId);
prmUserSport.UserAccountIdsIncluded.Add(UserAccountId);
prmUserSport.SportIdsIncluded.Add(sportId);
prmUserSport.StatusCat = SaxUserSport.StatusCat.Any;
userSport = AccountMgr.GetUserSport(prmUserSport);
@@ -268,7 +268,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
}
}
else
userSport = AccountMgr.CreateUserSport(SessionData.User.UserAccountId, sportId);
userSport = AccountMgr.CreateUserSport(UserAccountId, sportId);
}
// Populate item properties.
@@ -123,7 +123,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
SysId userSportId = model.ExtractSysId(model.UserSportId);
SaxUserSport userSport = AccountMgr.GetUserSportById(userSportId);
disposableItems.Add(userSport);
if (userSport == null || !userSport.UserAccountId.Equals(SessionData.User.UserAccountId))
if (userSport == null || !userSport.UserAccountId.Equals(UserAccountId))
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.something.gone.wrong"]));
// Sport details.
@@ -220,7 +220,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
disposableItems.Add(userSportExperience);
SaxUserSport userSport = AccountMgr.GetUserSportById(userSportExperience?.UserSportId ?? null);
disposableItems.Add(userSport);
if (userSportExperience == null || userSport == null || !userSport.UserAccountId.Equals(SessionData.User.UserAccountId))
if (userSportExperience == null || userSport == null || !userSport.UserAccountId.Equals(UserAccountId))
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.something.gone.wrong"]));
// Populate data to response.
@@ -279,7 +279,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
disposableItems.Add(userSportExperience);
userSport = AccountMgr.GetUserSportById(userSportExperience?.UserSportId ?? null);
disposableItems.Add(userSport);
if (userSportExperience == null || userSport == null || !userSport.UserAccountId.Equals(SessionData.User.UserAccountId))
if (userSportExperience == null || userSport == null || !userSport.UserAccountId.Equals(UserAccountId))
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.something.gone.wrong"]));
}
else
@@ -289,7 +289,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
SysId userSportId = model.ExtractSysId(model.UserSportId);
userSport = AccountMgr.GetUserSportById(userSportId);
disposableItems.Add(userSport);
if (userSport == null || !userSport.UserAccountId.Equals(SessionData.User.UserAccountId))
if (userSport == null || !userSport.UserAccountId.Equals(UserAccountId))
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.something.gone.wrong"]));
// Create User Sport Experience.
userSportExperience = AccountMgr.CreateUserSportExperience(userSport.Id);
@@ -148,7 +148,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
SaxSessionData_Online sessionData = SessionData_Online;
// User context.
SysId userAccountId = SessionData.User.UserAccountId;
SysId userAccountId = UserAccountId;
SaxActivityConsole.IndexContext indexContext = new SaxActivityConsole.IndexContext(userAccountId);
// Regions.
@@ -261,7 +261,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
}
// Record activty viewing.
if (!ActivityConsole.RecordUserActivityViewed(SessionData.User.UserAccountId, new ItemId((short)itemType, itemId), DbUpdateInfo))
if (!ActivityConsole.RecordUserActivityViewed(UserAccountId, new ItemId((short)itemType, itemId), DbUpdateInfo))
{
SaLogger.Warn(fn + " Failed to record Activity Viewing: " + ActivityConsole.ErrorStateMessage + "." + GetLogSuffix());
return Json(responseData);
@@ -306,7 +306,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
}
// Record activity reaction.
if (!ActivityConsole.RecordUserActivityReaction(SessionData.User.UserAccountId, new ItemId((short)itemType, itemId), model.GetActivityReaction(), DbUpdateInfo))
if (!ActivityConsole.RecordUserActivityReaction(UserAccountId, new ItemId((short)itemType, itemId), model.GetActivityReaction(), DbUpdateInfo))
{
SaLogger.Warn(fn + " Failed to record Activity Reaction: " + ActivityConsole.ErrorStateMessage + "." + GetLogSuffix());
return Json(responseData);
@@ -141,7 +141,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
if (!ValidReferer) return Forbid();
if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData);
SaxSessionData_Online sessionData = SessionData_Online;
SysId userAccountId = SessionData.User.UserAccountId;
SysId userAccountId = UserAccountId;
RefreshModel(model);
// Organisations that the user has rights to author articles for.
@@ -257,7 +257,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
// Validate session and referrer.
if (!ValidReferer) return Forbid();
if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData);
SysId userAccountId = SessionData.User.UserAccountId;
SysId userAccountId = UserAccountId;
RefreshModel(model);
// Identify item.
@@ -445,7 +445,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
return Json(responseData);
// Validate User & Organisation.
SysId userAccountId = SessionData.User.UserAccountId;
SysId userAccountId = UserAccountId;
SysId organisationId = model.ExtractSysId(model.ArticleOrganisationId);
if (SysId.IsValid(organisationId))
{
@@ -34,7 +34,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
return RedirectToAction("", "");
// User must either be a Journalist or have Article Admin rights with at least one organisation.
List<SaxAccountMgr.OrganisationIdName> organisations = AccountMgr.GetOrganisationsForAnyUserRole(SessionData.User.UserAccountId, new [] { Sax.OrganisationRole.Admin, Sax.OrganisationRole.ArticleAdmin });
List<SaxAccountMgr.OrganisationIdName> organisations = AccountMgr.GetOrganisationsForAnyUserRole(UserAccountId, new [] { Sax.OrganisationRole.Admin, Sax.OrganisationRole.ArticleAdmin });
if (organisations.Count < 1 && !UserIsJournalist)
return RedirectToAction("", "");
@@ -55,7 +55,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
String userAccountIdParam = "";// ToDo Decrypt from uaie value.
SysId userAccountId = userAccountIdParam.ToSysId();
if (!SysId.IsValid(userAccountId))
userAccountId = SessionData.User.UserAccountId;
userAccountId = UserAccountId;
return GetAccountContactImage(userAccountId, Sax.ImageType.Avatar);
}
@@ -77,7 +77,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
// Response should not be cached.
Response.Headers[HeaderNames.CacheControl] = "no-cache, no-store, must-revalidate, max-age=0";
Response.Headers[HeaderNames.Expires] = "-1";
SysId userAccountId = SessionData.User.UserAccountId;
SysId userAccountId = UserAccountId;
return GetAccountContactImage(userAccountId, Sax.ImageType.AvatarUpload);
}
@@ -137,7 +137,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
// Validate session and referrer.
if (!ValidReferer) return Forbid();
if (!ValidUserSession) return Forbid();
ItemId userItemId = new ItemId((short)Sax.DataItemType.UserAccount, SessionData.User.UserAccountId);
ItemId userItemId = new ItemId((short)Sax.DataItemType.UserAccount, UserAccountId);
// Extract encrypted parameters.
NameValueCollection parameters = ExtractOnlineParams(aie);
@@ -0,0 +1,431 @@
using Microsoft.AspNetCore.Mvc;
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 Sarand.Net.Standard.Base.Utils;
using Saxonite.Net.Core.Web.Online.Models;
using Saxonite.Net.Standard.Base.App;
using Saxonite.Net.Standard.Base.Bus;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Saxonite.Net.Core.Web.Online.Controllers
{
//=======================================================================
// Online Organisation Controller - Events - Ajax actions.
//=======================================================================
partial class OrganisationController
{
//-------------------------------------------------------------------
// Organisation Event data.
private class EventData_List : AjaxResponse_Data.ItemData_Base
{
public String EventDateFmt { get; set; }
public String EventTimeFmt { get; set; }
public String TypeCode { get; set; }
public String TypeDesc { get; set; }
public String About { get; set; }
public String RegionCaption { get; set; }
public String SportCaption { get; set; }
public String PublishedOnFmt { get; set; }
public String ExpiresOnFmt { get; set; }
}
private class EventData_Detail : EventData_List
{
public String EventAt_YYYYMMDD { get; set; }
public String EventAt_HHMM { get; set; }
public String RegionIdCountry { get; set; }
public String SportIdPrimary { get; set; }
public String PublishedOn_YYYYMMDD { get; set; }
public String ExpiresOn_YYYYMMDD { get; set; }
}
private void PopulateEventResponseData(Model_Organisation_Events model, SaxOrganisationEvent organisationEvent, EventData_List data)
{
data.Id = SysId.ToString(organisationEvent.Id);
data.EventDateFmt = Localiser.FormatDate(organisationEvent.EventAt);
data.EventTimeFmt = DateUtil.Format(organisationEvent.EventAt, "HH:mm");
data.TypeCode = EventTypeCodes.GetCodeForType(organisationEvent.EventType);
data.TypeDesc = Localiser.GetEventTypeCaption(organisationEvent.EventType);
data.About = organisationEvent.About;
data.RegionCaption = model.GetRegionCaption(organisationEvent.RegionIdCountry);
data.SportCaption = model.GetSportCaption(organisationEvent.SportIdPrimary);
data.CreatedOnFmt = Localiser.FormatDate(organisationEvent.CreateStamp.On);
data.PublishedOnFmt = Localiser.FormatDate(organisationEvent.PublishedAt);
data.ExpiresOnFmt = Localiser.FormatDate(organisationEvent.ExpiresAt);
data.StatusCode = organisationEvent.StatusCode;
data.StatusDesc = organisationEvent.StatusDesc;
}
private void PopulateEventResponseData(Model_Organisation_Events model, SaxOrganisationEvent organisationEvent, EventData_Detail data)
{
PopulateEventResponseData(model, organisationEvent, data as EventData_List);
data.EventAt_YYYYMMDD = DateUtil.Format(organisationEvent.EventAt, "yyyyMMdd");
data.EventAt_HHMM = DateUtil.Format(organisationEvent.EventAt, "HH:mm");
data.RegionIdCountry = model.GetEncryptedRegionId(organisationEvent.RegionIdCountry);
data.SportIdPrimary = model.GetEncryptedSportId(organisationEvent.SportIdPrimary);
data.PublishedOn_YYYYMMDD = DateUtil.Format(organisationEvent.PublishedAt, "yyyyMMdd");
data.ExpiresOn_YYYYMMDD = DateUtil.Format(organisationEvent.ExpiresAt, "yyyyMMdd");
}
//-------------------------------------------------------------------
// Get Event List ajax request.
//-------------------------------------------------------------------
private class AjaxResponse_EventList : AjaxResponse_Data
{
// Construction.
public AjaxResponse_EventList(SaxModel_Online model) : base(model) { }
// Event list.
public List<EventData_List> Events { get; } = new List<EventData_List>();
// User profile.
public class UserData
{
public bool CanManage { get; set; }
}
public UserData User { get; } = new UserData();
// Organisation.
public class OrganisationData
{
public String Id { get; set; }
public String Name { get; set; }
public String SportId { get; set; }
public String SportName { get; set; }
public String RegionId { get; set; }
public String RegionName { get; set; }
}
public OrganisationData Organisation { get; } = new OrganisationData();
// Reference data.
public List<CodeDesc> EventTypes { get; } = new List<CodeDesc>();
}
//-------------------------------------------------------------------
[HttpPost]
[Route("Organisation/Ajax/GetEventList")]
[Route("Organisation/Ajax/GetEvents")]
public IActionResult Ajax_GetEventList(Model_Organisation_Events model)
{
String fn = GetType().Name + ".Ajax_GetEventList";
String messageTitle = Localiser["organisation.caption.events"];
AjaxResponse_EventList responseData = new AjaxResponse_EventList(model);
// Validate session and referrer.
if (!ValidReferer) return Forbid();
if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData);
RefreshModel(model);
SysId userAccountId = UserAccountId;
// Record disposable items as they are created so all can be disposed when needed.
using (DisposableCollection<SacsHierarchyItem> disposableItems = new DisposableCollection<SacsHierarchyItem>())
{
// Organisation.
SysId organisationId = model.ExtractSysId(model.Filter.OrganisationId);
SaxOrganisation organisation = AccountMgr.GetOrganisationById(organisationId);
disposableItems.Add(organisation);
if (organisation == null || !organisation.IsStatusActive)
{
SaLogger.Warn(fn + " " + (organisation == null ? "Invalid" : "Inactive") + " organisation for Event list. OrganisationId: '" + model.Filter.OrganisationId + "'");
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
}
if (organisation != null)
{
// Store filter data.
SessionData_Online.Filter.SetMemberOrganisation(organisation);
// Reference data - organisationEvent types.
foreach (TypeCodeDesc eventType in EventTypeCodes)
responseData.EventTypes.Add(eventType.Code, Localiser.GetEventTypeCaption((Sax.EventType)eventType.Type));
// User organisation.
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
prmUserOrganisation.UserAccountIdsIncluded.Add(userAccountId);
prmUserOrganisation.OrganisationIdsIncluded.Add(organisationId);
prmUserOrganisation.UserAccountStatusCat = SaxUserAccount.StatusCat.ActiveOnly;
prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.ActiveOnly;
SaxUserOrganisation userOrganisation = AccountMgr.GetUserOrganisation(prmUserOrganisation);
disposableItems.Add(userOrganisation);
if (userOrganisation == null)
{
SaLogger.Warn(fn + " Invalid/inactive user organisation for Event list. UserAccountId: " + SysId.ToString(userAccountId) + ". OrganisationId: " + model.Filter.OrganisationId + ".");
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
}
// Organisation.
responseData.Organisation.Id = SysId.ToString(organisation.Id);
responseData.Organisation.Name = organisation.Name;
responseData.Organisation.SportId = model.GetEncryptedSportId(organisation.SportIdPrimary);
responseData.Organisation.SportName = model.GetSportCaption(organisation.SportIdPrimary);
responseData.Organisation.RegionId = model.GetEncryptedRegionId(organisation.RegionIdPrimary);
responseData.Organisation.RegionName = model.GetRegionCaption(organisation.RegionIdPrimary);
// User details.
responseData.User.CanManage = userOrganisation.CanManageSchedule;
// Item filter.
SaxOrganisationEvent.Params prmEvent = new SaxOrganisationEvent.Params();
prmEvent.UserAccountIdsIncluded.Add(userAccountId);
prmEvent.OrganisationIdsIncluded.Add(organisationId);
prmEvent.EventFilter = model.Filter.Event;
prmEvent.StatusCat = SaxOrganisationEvent.StatusCat.NotDeleted;
model.Paging.ItemTotal = (ulong)ActivityMgr.GetOrganisationEventCount(prmEvent);
model.PopulatePagingTo(prmEvent.ResultsPaging);
// Item columns.
ColumnDfn colId = ActivityMgr.GetOrganisationEventColumnDfn(SaxOrganisationEvent.Column.Id);
ColumnDfn colEventAt = ActivityMgr.GetOrganisationEventColumnDfn(SaxOrganisationEvent.Column.EventAt_DateTime);
ColumnDfn colEventTypeCode = ActivityMgr.GetOrganisationEventColumnDfn(SaxOrganisationEvent.Column.EventTypeCode);
ColumnDfn colAbout = ActivityMgr.GetOrganisationEventColumnDfn(SaxOrganisationEvent.Column.About);
ColumnDfn colRegionId = ActivityMgr.GetOrganisationEventColumnDfn(SaxOrganisationEvent.Column.RegionIdCountry);
ColumnDfn colRegionName = ActivityMgr.GetOrganisationEventColumnDfn(SaxOrganisationEvent.Column.Region_Name);
ColumnDfn colSportId = ActivityMgr.GetOrganisationEventColumnDfn(SaxOrganisationEvent.Column.SportIdPrimary);
ColumnDfn colSportName = ActivityMgr.GetOrganisationEventColumnDfn(SaxOrganisationEvent.Column.Sport_Name);
ColumnDfn colPublishedOn = ActivityMgr.GetOrganisationEventColumnDfn(SaxOrganisationEvent.Column.PublishedAt_Date);
ColumnDfn colExpiresOn = ActivityMgr.GetOrganisationEventColumnDfn(SaxOrganisationEvent.Column.ExpiresAt_Date);
ColumnDfn colStatus = ActivityMgr.GetOrganisationEventColumnDfn(SaxOrganisationEvent.Column.Status);
ColumnDfn colCreatedOn = ActivityMgr.GetOrganisationEventColumnDfn(SaxOrganisationEvent.Column.CreateOn_Date);
List<ColumnDfn> columns = new List<ColumnDfn>()
{
colId, colEventAt, colEventTypeCode, colAbout,
colRegionId, colRegionName, colSportId, colSportName,
colPublishedOn, colExpiresOn,
colStatus, colCreatedOn
};
// Sort columns.
colCreatedOn.SortAscending = false;
prmEvent.SortColumns.Add(colCreatedOn);
// Query items.
using (DbResultSet resultSet = ActivityMgr.ExecuteOrganisationEventQuery(columns, prmEvent))
{
while (resultSet != null && resultSet.HasRows && resultSet.NextRecord())
{
NamedValue.Map values = resultSet.GetRecordValues();
EventData_List eventData = new EventData_List()
{
Id = values.GetLong(colId.DataName).ToString(),
EventDateFmt = Localiser.FormatDate(values.GetDateTime(colEventAt.DataName)),
EventTimeFmt = DateUtil.Format(values.GetDateTime(colEventAt.DataName), "HH:mm"),
TypeCode = values.GetString(colEventTypeCode.DataName),
TypeDesc = Localiser.GetEventTypeCaption((Sax.EventType)EventTypeCodes.GetTypeForCode(values.GetString(colEventTypeCode.DataName))),
About = values.GetString(colAbout.DataName),
RegionCaption = model.GetRegionCaption(values.GetString(colRegionId.DataName).ToSysId()),
SportCaption = model.GetSportCaption(values.GetString(colSportId.DataName).ToSysId()),
CreatedOnFmt = Localiser.FormatDate(values.GetDateTime(colCreatedOn.DataName)),
PublishedOnFmt = Localiser.FormatDate(values.GetDateTime(colPublishedOn.DataName)),
ExpiresOnFmt = Localiser.FormatDate(values.GetDateTime(colExpiresOn.DataName)),
StatusCode = values.GetString(colStatus.DataName),
StatusDesc = SacsSystem.GetStatusDescForCode(values.GetString(colStatus.DataName))
};
responseData.Events.Add(eventData);
}
}
}
}
if (model.Paging.IsPaged)
model.Paging.ItemCount = (ushort)responseData.Events.Count;
// Complete response.
responseData.SetPaging(model);
responseData.Success = true;
return Json(responseData);
}
//-------------------------------------------------------------------
// Get Event ajax request.
//-------------------------------------------------------------------
private class AjaxResponse_Event : AjaxResponse_Data
{
// Construction.
public AjaxResponse_Event(SaxModel_Online model) : base(model) { }
// Event details.
public EventData_Detail Event { get; } = new EventData_Detail();
}
//-------------------------------------------------------------------
[HttpPost]
[Route("Organisation/Ajax/GetEvent")]
public IActionResult Ajax_GetEvent(Model_Organisation_Events model)
{
String fn = GetType().Name + ".Ajax_GetEvent";
String messageTitle = Localiser["organisation.caption.organisationEvent"];
AjaxResponse_Event responseData = new AjaxResponse_Event(model);
// 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<SacsHierarchyItem> disposableItems = new DisposableCollection<SacsHierarchyItem>())
{
// Identify item.
SysId eventId = model.ExtractSysId(model.EventId);
if (!SysId.IsValid(eventId))
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.specified"]));
// Retrieve item.
SaxOrganisationEvent organisationEvent = ActivityMgr.GetOrganisationEventById(eventId);
disposableItems.Add(organisationEvent);
if (organisationEvent == null)
{
SaLogger.Warn(fn + " Failed to retrieve Organisation Event for Id: '" + model.EventId + "'");
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
}
// Validate organisation.
SaxOrganisation organisation = AccountMgr.GetOrganisationById(organisationEvent.OrganisationId);
disposableItems.Add(organisation);
if (organisation == null || !organisation.IsStatusActive)
{
SaLogger.Warn(fn + " " + (organisation == null ? "Invalid" : "Inactive") + " organisation for Event. OrganisationId: '" + organisationEvent.OrganisationId + "'");
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
}
// Make a note of the selected Organisation.
SessionData_Online.Filter.SetMemberOrganisation(organisation);
// Construct response.
PopulateEventResponseData(model, organisationEvent, responseData.Event);
}
// Complete response.
responseData.Success = true;
return Json(responseData);
}
//-------------------------------------------------------------------
// Store Event ajax request.
//-------------------------------------------------------------------
[HttpPost]
[Route("Organisation/Ajax/StoreEvent")]
public IActionResult Ajax_StoreEvent(Model_Organisation_Events model)
{
String fn = GetType().Name + ".Ajax_StoreEvent";
String messageTitle = Localiser["organisation.caption.organisationEvent"];
AjaxResponse_Event responseData = new AjaxResponse_Event(model);
// 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<SacsHierarchyItem> disposableItems = new DisposableCollection<SacsHierarchyItem>())
{
// Validate item properties.
model.ValidateEventData(responseData);
if (responseData.HasControlErrors())
return Json(responseData);
// Validate Event against Id against 'Exists' flag.
SysId eventId = model.ExtractSysId(model.EventId);
bool eventExists = StringUtil.ToBool(model.EventExists);
if (eventExists && !SysId.IsValid(eventId))
{
SaLogger.Warn(fn + " Id not specified for existing Event.");
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
}
if (!eventExists && SysId.IsValid(eventId))
{
SaLogger.Warn(fn + " Id specified for new Event: '" + model.EventId + "'");
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
}
// Retrieve existing item.
SaxOrganisationEvent organisationEvent = ActivityMgr.GetOrganisationEventById(eventId);
disposableItems.Add(organisationEvent);
if (organisationEvent == null && SysId.IsValid(eventId))
{
SaLogger.Warn(fn + " Failed to retrieve organisationEvent for Id: '" + model.EventId + "'");
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
}
// Validate the Organisation.
SysId organisationId = model.ExtractSysId(model.EventOrganisationId);
if (!SysId.IsValid(organisationId))
{
SaLogger.Warn(fn + " Organisation Id not specified for Event.");
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
}
SaxOrganisation organisation = AccountMgr.GetOrganisationById(organisationId);
disposableItems.Add(organisation);
if (organisation == null || !organisation.IsStatusActive)
{
SaLogger.Warn(fn + " " + (organisation == null ? "Invalid" : "Inactive") + " organisation for Event. OrganisationId: '" + model.EventOrganisationId + "'");
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
}
if (organisationEvent != null && !organisationEvent.OrganisationId.Equals(organisationId))
{
SaLogger.Warn(fn + " Inconsistent Organisation Id specified for Event. Expected: " + organisationEvent.OrganisationId + ". Found: " + organisationId);
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
}
// Ensure that the user has the correct role to update Events for this organisation.
if (!AccountMgr.UserHasAnyOrganisationRole(UserAccountId, organisationId, new[] { Sax.OrganisationRole.Admin, Sax.OrganisationRole.ScheduleAdmin }))
{
SaLogger.Warn(fn + " User doesn't have 'Event Admin' role for Organisation Id: " + organisationId);
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
}
// Create new item if required.
if (organisationEvent == null)
{
organisationEvent = ActivityMgr.CreateOrganisationEvent(organisationId);
disposableItems.Add(organisationEvent);
}
// Populate item properties.
if (model.EventSportIdPrimary != null)
organisationEvent.SportIdPrimary = model.ExtractSysId(model.EventSportIdPrimary);
if (model.EventRegionIdCountry != null)
organisationEvent.RegionIdCountry = model.ExtractSysId(model.EventRegionIdCountry);
if (model.EventDate != null)
{
organisationEvent.EventAt = model.ParseDateFromForm(model.EventDate);
if (!StringUtil.IsEmpty(model.EventTime))
organisationEvent.EventAt = DateUtil.SetTime(organisationEvent.EventAt, DateUtil.ParseExact(model.EventTime, "HH:mm"));
}
if (model.EventTypeCode != null)
organisationEvent.EventType = (Sax.EventType)EventTypeCodes.GetTypeForCode(model.EventTypeCode);
if (model.EventAbout != null)
organisationEvent.About = model.EventAbout;
if (model.EventStatusCode != null)
organisationEvent.Status = model.EventStatus;
// Store item.
if (!SysId.IsValid(organisationEvent.Id))
{
if (!ActivityMgr.InsertOrganisationEvent(organisationEvent, DbUpdateInfo))
{
SaLogger.Warn(fn + " Failed to insert organisationEvent: " + ActivityMgr.ErrorStateMessage);
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.insert.failed"]));
}
}
else
{
if (!ActivityMgr.UpdateOrganisationEvent(organisationEvent, DbUpdateInfo))
{
SaLogger.Warn(fn + " Failed to update organisationEvent [Id:" + SysId.ToString(organisationEvent.Id) + "]: " + ActivityMgr.ErrorStateMessage);
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.update.failed"]));
}
}
// Store Event Activity Index data.
// ToDo ActivityConsole.StoreActivityIndex(organisationEvent, DbUpdateInfo);
// Construct response.
PopulateEventResponseData(model, organisationEvent, responseData.Event);
}
// Complete response.
responseData.Success = true;
return Json(responseData);
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -43,7 +43,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
{
data.Id = SysId.ToString(userOrganisation.Id);
data.UserAccountId = SysId.ToString(userOrganisation.UserAccountId);
if (userOrganisation.UserAccountId.Equals(SessionData.User.UserAccountId)) data.CurrentUser = true;
if (userOrganisation.UserAccountId.Equals(UserAccountId)) data.CurrentUser = true;
data.EmailAddress = userAccount.EmailAddress;
data.DisplayName = userAccount.GetDisplayName();
data.RoleCodes.Clear();
@@ -131,7 +131,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
responseData.MemberRoles.Add(memberRole.Code, Localiser.GetOrganisationRoleCaption((Sax.OrganisationRole)memberRole.Type));
// Session User roles.
responseData.User.CanManage = AccountMgr.UserHasAnyOrganisationRole(SessionData.User.UserAccountId, organisation.Id, new List<Sax.OrganisationRole> { Sax.OrganisationRole.Admin, Sax.OrganisationRole.MemberAdmin });
responseData.User.CanManage = AccountMgr.UserHasAnyOrganisationRole(UserAccountId, organisation.Id, new List<Sax.OrganisationRole> { Sax.OrganisationRole.Admin, Sax.OrganisationRole.MemberAdmin });
// Item filter.
SaxUserOrganisation.Params prmMember = new SaxUserOrganisation.Params();
@@ -181,7 +181,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
StatusCode = values.GetString(colUserStatus.DataName),
StatusDesc = SacsSystem.GetStatusDescForCode(values.GetString(colUserStatus.DataName))
};
if (model.ExtractSysId(memberData.UserAccountId).Equals(SessionData.User.UserAccountId)) memberData.CurrentUser = true;
if (model.ExtractSysId(memberData.UserAccountId).Equals(UserAccountId)) memberData.CurrentUser = true;
String memberRoleCodes = values.GetString(colOrganisationRoleCodes.DataName);
foreach (String memberRoleCode in StringListUtil.Split(memberRoleCodes, SaxUserOrganisation.UserOrgnisationRoleDelim))
{
@@ -256,7 +256,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
}
// Session User roles.
bool userCanManageMembers = AccountMgr.UserHasAnyOrganisationRole(SessionData.User.UserAccountId, organisation.Id, new List<Sax.OrganisationRole> { Sax.OrganisationRole.Admin, Sax.OrganisationRole.MemberAdmin });
bool userCanManageMembers = AccountMgr.UserHasAnyOrganisationRole(UserAccountId, organisation.Id, new List<Sax.OrganisationRole> { Sax.OrganisationRole.Admin, Sax.OrganisationRole.MemberAdmin });
// Validate user account.
SaxUserAccount userAccount = AccountMgr.GetUserAccountById(userOrganisation.UserAccountId);
@@ -366,7 +366,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
}
// Ensure that the user has the correct role to update Members for this organisation.
bool userCanManageMembers = AccountMgr.UserHasAnyOrganisationRole(SessionData.User.UserAccountId, organisationId, new List<Sax.OrganisationRole> { Sax.OrganisationRole.Admin, Sax.OrganisationRole.MemberAdmin });
bool userCanManageMembers = AccountMgr.UserHasAnyOrganisationRole(UserAccountId, organisationId, new List<Sax.OrganisationRole> { Sax.OrganisationRole.Admin, Sax.OrganisationRole.MemberAdmin });
if (!userCanManageMembers)
{
SaLogger.Warn(fn + " User doesn't have 'Member Admin' role for Organisation Id: " + organisationId);
@@ -392,7 +392,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
}
// Validate roles for current user.
if (userOrganisation.UserAccountId.Equals(SessionData.User.UserAccountId))
if (userOrganisation.UserAccountId.Equals(UserAccountId))
{
// User is modifying their own organisation member.
if (userOrganisation.CanManageOrganisation && !model.OrganisationRoleCodes.Any(item => item.Type == (int)Sax.OrganisationRole.Admin))
@@ -559,7 +559,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
}
// Ensure that the user has the correct role to update Members for this organisation.
bool userCanManageMembers = AccountMgr.UserHasAnyOrganisationRole(SessionData.User.UserAccountId, organisation.Id, new List<Sax.OrganisationRole> { Sax.OrganisationRole.Admin, Sax.OrganisationRole.MemberAdmin });
bool userCanManageMembers = AccountMgr.UserHasAnyOrganisationRole(UserAccountId, organisation.Id, new List<Sax.OrganisationRole> { Sax.OrganisationRole.Admin, Sax.OrganisationRole.MemberAdmin });
if (!userCanManageMembers)
{
SaLogger.Warn(fn + " User doesn't have 'Member Admin' role for Organisation Id: " + organisation.Id);
@@ -675,7 +675,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
}
// Ensure that the user has the correct role to update Members for this organisation.
bool userCanManageMembers = AccountMgr.UserHasAnyOrganisationRole(SessionData.User.UserAccountId, organisation.Id, new List<Sax.OrganisationRole> { Sax.OrganisationRole.Admin, Sax.OrganisationRole.MemberAdmin });
bool userCanManageMembers = AccountMgr.UserHasAnyOrganisationRole(UserAccountId, organisation.Id, new List<Sax.OrganisationRole> { Sax.OrganisationRole.Admin, Sax.OrganisationRole.MemberAdmin });
if (!userCanManageMembers)
{
SaLogger.Warn(fn + " User doesn't have 'Member Admin' role for Organisation Id: " + organisation.Id);
@@ -106,7 +106,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
if (!ValidReferer) return Forbid();
if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData);
RefreshModel(model);
SysId userAccountId = SessionData.User.UserAccountId;
SysId userAccountId = UserAccountId;
// Record disposable items as they are created so all can be disposed when needed.
using (DisposableCollection<SacsHierarchyItem> disposableItems = new DisposableCollection<SacsHierarchyItem>())
@@ -249,14 +249,18 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData);
RefreshModel(model);
// Record disposable items as they are created so all can be disposed when needed.
using (DisposableCollection<SacsHierarchyItem> disposableItems = new DisposableCollection<SacsHierarchyItem>())
{
// Identify item.
SysId opportunityId = model.ExtractSysId(model.OpportunityId);
if (!SysId.IsValid(opportunityId))
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.specified"]));
// Retrieve item.
using (SaxOrganisationOpportunity opportunity = ActivityMgr.GetOrganisationOpportunityById(opportunityId))
{
SaxOrganisationOpportunity opportunity = ActivityMgr.GetOrganisationOpportunityById(opportunityId);
disposableItems.Add(opportunity);
if (opportunity == null)
{
SaLogger.Warn(fn + " Failed to retrieve Organisation Opportunity for Id: '" + model.OpportunityId + "'");
@@ -264,8 +268,8 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
}
// Validate organisation.
using (SaxOrganisation organisation = AccountMgr.GetOrganisationById(opportunity.OrganisationId))
{
SaxOrganisation organisation = AccountMgr.GetOrganisationById(opportunity.OrganisationId);
disposableItems.Add(organisation);
if (organisation == null || !organisation.IsStatusActive)
{
SaLogger.Warn(fn + " " + (organisation == null ? "Invalid" : "Inactive") + " organisation for Opportunity. OrganisationId: '" + opportunity.OrganisationId + "'");
@@ -278,7 +282,6 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
// Construct response.
PopulateOpportunityResponseData(model, opportunity, responseData.Opportunity);
}
}
// Complete response.
responseData.Success = true;
@@ -301,6 +304,10 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData);
RefreshModel(model);
// Record disposable items as they are created so all can be disposed when needed.
using (DisposableCollection<SacsHierarchyItem> disposableItems = new DisposableCollection<SacsHierarchyItem>())
{
// Validate item properties.
model.ValidateOpportunityData(responseData);
if (responseData.HasControlErrors())
@@ -320,10 +327,6 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
}
// Record disposable items as they are created so all can be disposed when needed.
using (DisposableCollection<SacsHierarchyItem> disposableItems = new DisposableCollection<SacsHierarchyItem>())
{
// Retrieve existing item.
SaxOrganisationOpportunity opportunity = ActivityMgr.GetOrganisationOpportunityById(opportunityId);
disposableItems.Add(opportunity);
@@ -354,7 +357,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
}
// Ensure that the user has the correct role to update Opportunities for this organisation.
if (!AccountMgr.UserHasAnyOrganisationRole(SessionData.User.UserAccountId, organisationId, new [] { Sax.OrganisationRole.Admin, Sax.OrganisationRole.OpportunityAdmin }))
if (!AccountMgr.UserHasAnyOrganisationRole(UserAccountId, organisationId, new[] { Sax.OrganisationRole.Admin, Sax.OrganisationRole.OpportunityAdmin }))
{
SaLogger.Warn(fn + " User doesn't have 'Opportunity Admin' role for Organisation Id: " + organisationId);
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
@@ -44,22 +44,26 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
if (!ValidReferer) return Forbid();
SaxSessionData_Online sessionData = SessionData_Online;
// Record disposable items as they are created so all can be disposed when needed.
using (DisposableCollection<SacsHierarchyItem> disposableItems = new DisposableCollection<SacsHierarchyItem>())
{
if (!model.ValidateOrganisationRequestData(responseData))
return Json(responseData);
// Check Regions.
SysId regionIdCountry = model.ExtractSysId(model.OrganisationRegionIdCountry);
SysId regionIdCountry = model.ExtractSysId(model.Organisation.RegionIdCountry);
SaxRegion.Data regionCountry = Internals.GetRegion(regionIdCountry);
if (SysId.IsValid(regionIdCountry) && regionCountry == null)
{
SaLogger.Warn(fn + " Country region not found. Id: " + model.OrganisationRegionIdCountry + ". " + GetLogSuffix());
SaLogger.Warn(fn + " Country region not found. Id: " + model.Organisation.RegionIdCountry + ". " + GetLogSuffix());
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
}
SysId regionIdAddressProvince= model.ExtractSysId(model.OrganisationAddressRegionIdProvince);
SysId regionIdAddressProvince = model.ExtractSysId(model.Organisation.Address.RegionIdProvince);
SaxRegion.Data regionProvince = Internals.GetRegion(regionIdAddressProvince);
if (SysId.IsValid(regionIdAddressProvince) && regionProvince == null)
{
SaLogger.Warn(fn + " Province region not found. Id: " + model.OrganisationAddressRegionIdProvince + ". " + GetLogSuffix());
SaLogger.Warn(fn + " Province region not found. Id: " + model.Organisation.Address.RegionIdProvince + ". " + GetLogSuffix());
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
}
@@ -77,6 +81,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
}
// Retrieve user account.
userAccount = AccountMgr.GetUserAccountById(sessionData.User.UserAccountId);
disposableItems.Add(userAccount);
if (userAccount == null)
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
}
@@ -91,6 +96,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
// Check that the email doesn't exist.
// NB This is validated by the model and shouldn't be required here.
userAccount = AccountMgr.GetUserAccountByEmailAddress(model.ContactEmailAddress);
disposableItems.Add(userAccount);
if (userAccount != null)
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
userAccount = AccountMgr.CreateUserAccount();
@@ -104,7 +110,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
}
}
SysId organisationSportId = model.ExtractSysId(model.OrganisationSportId);
SysId organisationSportId = model.ExtractSysId(model.Organisation.SportId);
if (SysId.IsValid(organisationSportId))
{
// Add User Sport if not already present.
@@ -116,6 +122,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
SaxUserSport userSport = AccountMgr.GetUserSport(prmUserSport);
if (userSport == null)
userSport = AccountMgr.CreateUserSport(userAccount.Id, organisationSportId);
disposableItems.Add(userSport);
userSport.Status = SaxUserSport.DefaultStatus;
if (!SysId.IsValid(userSport.Id))
{
@@ -137,12 +144,13 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
// Create Organisation.
SaxOrganisation organisation = AccountMgr.CreateOrganisation();
organisation.Name = model.OrganisationName;
organisation.OrganisationType = model.GetOrganisationType();
organisation.OrganisationCategory = model.GetOrganisationCategory();
disposableItems.Add(organisation);
organisation.Name = model.Organisation.Name;
organisation.OrganisationType = model.Organisation.GetOrganisationType();
organisation.OrganisationCategory = model.Organisation.GetOrganisationCategory();
organisation.SportIdPrimary = organisationSportId;
organisation.RegionIdPrimary = model.ExtractSysId(model.OrganisationRegionIdCountry);
organisation.PhoneMain = model.OrganisationPhoneMain;
organisation.RegionIdPrimary = regionIdCountry;
organisation.PhoneMain = model.Organisation.PhoneMain;
organisation.Status = SaStatus.Awaiting;
if (!AccountMgr.InsertOrganisation(organisation, DbUpdateInfo))
{
@@ -152,6 +160,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
// Add user as member of organisation.
SaxUserOrganisation userOrganisation = AccountMgr.CreateUserOrganisation(userAccount.Id, organisation.Id);
disposableItems.Add(userOrganisation);
userOrganisation.OrganisationRoles = new[] { Sax.OrganisationRole.Member, Sax.OrganisationRole.Admin };
if (!AccountMgr.InsertUserOrganisation(userOrganisation, DbUpdateInfo))
{
@@ -160,25 +169,39 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
}
// Create Organisation address.
SaxItemAddress organisationAddress = ItemDataMgr.CreateItemAddress(organisation.GetItemId(), Sax.AddressType.Office);
organisationAddress.Line1 = model.OrganisationAddressLine1;
organisationAddress.Line2 = model.OrganisationAddressLine2;
organisationAddress.Line3 = model.OrganisationAddressLine3;
organisationAddress.Town = model.OrganisationAddressTown;
organisationAddress.Province = model.OrganisationAddressProvince;
organisationAddress.RegionIdProvince = model.ExtractSysId(model.OrganisationAddressRegionIdProvince);
if (SysId.IsValid(regionCountry.Id))
SaxItemAddress organisationAddress = ItemDataMgr.CreateItemAddress(organisation.GetItemId(), SaxItemAddress.DefaultOrganisationAddressType);
disposableItems.Add(organisationAddress);
organisationAddress.Line1 = model.Organisation.Address.Line1;
organisationAddress.Line2 = model.Organisation.Address.Line2;
organisationAddress.Line3 = model.Organisation.Address.Line3;
organisationAddress.Town = model.Organisation.Address.Town;
if (regionProvince != null)
{
organisationAddress.Province = regionProvince.Name;
organisationAddress.RegionIdProvince = regionProvince.Id;
}
else
{
if (model.Organisation.Address.Province != null)
organisationAddress.Province = model.Organisation.Address.Province;
}
if (regionCountry != null)
{
organisationAddress.Country = regionCountry.Name;
organisationAddress.RegionIdCountry = regionCountry.Id;
}
else organisationAddress.Country = model.OrganisationAddressCountry;
organisationAddress.PostalCode = model.OrganisationAddressPostalCode;
else
{
if (model.Organisation.Address.Country != null)
organisationAddress.Country = model.Organisation.Address.Country;
}
organisationAddress.PostalCode = model.Organisation.Address.PostalCode;
if (!ItemDataMgr.InsertItemAddress(organisationAddress, DbUpdateInfo))
{
SaLogger.Warn(fn + " Failed to insert organisation address - " + ItemDataMgr.ErrorStateMessage);
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
}
}
// Complete response.
responseData.SetMessage(messageTitle, Localiser["msg.organisation.request.success"].ToString().ReplaceAll("\n", "<br/><br/>"));
@@ -145,7 +145,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
// Organisation filter
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
prmUserOrganisation.UserAccountIdsIncluded.Add(SessionData.User.UserAccountId);
prmUserOrganisation.UserAccountIdsIncluded.Add(UserAccountId);
prmUserOrganisation.OrganisationMembersOnly = true;
prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.ActiveOnly;
prmUserOrganisation.SortColumns.Add(colOrganisationName);
@@ -34,8 +34,35 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
if (!ValidUserSession)
return RedirectToAction("", "");
// No 'Index' view as yet - default to 'Opportunities' view.
return RedirectToAction("Opportunities", "Organisation");
// No 'Index' view as yet - default to home page.
return RedirectToAction("", "");
}
//-------------------------------------------------------------------
[HttpGet]
public IActionResult Events()
{
// Validate session.
if (!ValidUserSession)
return RedirectToAction("", "");
// Model.
Model_Organisation_Events model = new Model_Organisation_Events(Localiser);
// Get a suitable organisation for the filter.
SysId filterOrganisationId = SessionData_Online.Filter.OrganisationIdMember;
String filterOrganisationCaption = SessionData_Online.Filter.OrganisationCaptionMember;
OrganisationData organisationData = GetOrganisationForFilter(filterOrganisationId, filterOrganisationCaption);
if (organisationData == null)
return RedirectToAction("", "");
// Make a note of the filter values.
model.Filter.OrganisationId = SysId.ToString(organisationData.Id);
model.Filter.OrganisationCaption = organisationData.Caption;
SessionData_Online.Filter.OrganisationIdMember = organisationData.Id;
SessionData_Online.Filter.OrganisationCaptionMember = organisationData.Caption;
return View(model);
}
//-------------------------------------------------------------------
@@ -103,7 +130,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
{
// Check that user is associated with organisations.
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
prmUserOrganisation.UserAccountIdsIncluded.Add(SessionData.User.UserAccountId);
prmUserOrganisation.UserAccountIdsIncluded.Add(UserAccountId);
prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.ActiveOnly;
if (AccountMgr.GetUserOrganisationCount(prmUserOrganisation) < 1)
return null;
@@ -117,7 +144,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
ColumnDfn colOrganisationId = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.OrganisationId);
ColumnDfn colOrganisationName = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_Name);
prmUserOrganisation = new SaxUserOrganisation.Params();
prmUserOrganisation.UserAccountIdsIncluded.Add(SessionData.User.UserAccountId);
prmUserOrganisation.UserAccountIdsIncluded.Add(UserAccountId);
if (SysId.IsValid(filterOrganisationId))
prmUserOrganisation.OrganisationIdsIncluded.Add(filterOrganisationId);
prmUserOrganisation.OrganisationMembersOnly = true;
@@ -0,0 +1,127 @@
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Helpers;
using Sarand.Net.Standard.Base.Utils;
using Saxonite.Base.App;
using Saxonite.Net.Core.Web.Base.App;
using Saxonite.Net.Core.Web.Base.Controllers;
using Saxonite.Net.Standard.Base.App;
using Saxonite.Net.Standard.Base.Bus;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Saxonite.Net.Core.Web.Online.Models
{
//=======================================================================
/// <summary>
/// Address model data properties.
/// </summary>
public class ModelData_Address : ModelData_Online
{
//-------------------------------------------------------------------
// Construction.
public ModelData_Address(SaxModel_Online model, String controlNameSuffix) : base(model)
{
this.ControlNameSuffix = StringUtil.EmptyOnNull(controlNameSuffix) + "Address";
}
//-------------------------------------------------------------------
// Properties.
private String ControlNameSuffix { get; }
// Address properties.
public String Id { get; set; }
public String Line1 { get; set; }
public String Line2 { get; set; }
public String Line3 { get; set; }
public String Town { get; set; }
public String Province { get; set; }
public String RegionIdProvince { get; set; }
public String Country { get; set; }
public String PostalCode { get; set; }
//-------------------------------------------------------------------
// Validation.
//-------------------------------------------------------------------
// Address.
public bool ValidateAddressData(SaxController_Base.AjaxResponse_Data responseData)
{
// Address Line 1 - mandatory.
responseData.SetControlValue(ControlNameSuffix + "Line1", Line1);
if (StringUtil.IsEmpty(Line1))
responseData.SetControlError(ControlNameSuffix + "Line1", Model.Localiser["msg.validation.mandatory.value"]);
else if (StringUtil.GetLength(Line1) > Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line1))
responseData.SetControlError(ControlNameSuffix + "Line1", Model.Localiser["msg.validation.maximum.length", Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line1)]);
// Address Line 2 - optional.
if (Line2 != null)
{
responseData.SetControlValue(ControlNameSuffix + "Line2", Line2);
if (!StringUtil.IsEmpty(Line2))
{
if (StringUtil.GetLength(Line2) > Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line2))
responseData.SetControlError(ControlNameSuffix + "Line2", Model.Localiser["msg.validation.maximum.length", Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line2)]);
}
}
// Address Line 3 - optional.
if (Line3 != null)
{
responseData.SetControlValue(ControlNameSuffix + "Line3", Line3);
if (!StringUtil.IsEmpty(Line3))
{
if (StringUtil.GetLength(Line3) > Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line3))
responseData.SetControlError(ControlNameSuffix + "Line3", Model.Localiser["msg.validation.maximum.length", Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line3)]);
}
}
// Address Town - mandatory.
responseData.SetControlValue(ControlNameSuffix + "Town", Town);
if (StringUtil.IsEmpty(Town))
responseData.SetControlError(ControlNameSuffix + "Town", Model.Localiser["msg.validation.mandatory.value"]);
else if (StringUtil.GetLength(Town) > Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Town))
responseData.SetControlError(ControlNameSuffix + "Town", Model.Localiser["msg.validation.maximum.length", Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Town)]);
// Address Province - optional.
if (Province != null)
{
responseData.SetControlValue(ControlNameSuffix + "Province", Province);
if (!StringUtil.IsEmpty(Province))
{
if (StringUtil.GetLength(Province) > Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Province))
responseData.SetControlError(ControlNameSuffix + "Province", Model.Localiser["msg.validation.maximum.length", Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Province)]);
}
}
// Address Country - optional.
if (Country != null)
{
responseData.SetControlValue(ControlNameSuffix + "Country", Country);
if (!StringUtil.IsEmpty(Country))
{
if (StringUtil.GetLength(Country) > Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Country))
responseData.SetControlError(ControlNameSuffix + "Country", Model.Localiser["msg.validation.maximum.length", Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Country)]);
}
}
// Address PostalCode - optional.
if (PostalCode != null)
{
responseData.SetControlValue(ControlNameSuffix + "PostalCode", PostalCode);
if (!StringUtil.IsEmpty(PostalCode))
{
if (StringUtil.GetLength(PostalCode) > Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_PostalCode))
responseData.SetControlError(ControlNameSuffix + "PostalCode", Model.Localiser["msg.validation.maximum.length", Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_PostalCode)]);
}
}
return !responseData.HasControlErrors();
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -0,0 +1,38 @@
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Helpers;
using Sarand.Net.Standard.Base.Utils;
using Saxonite.Base.App;
using Saxonite.Net.Core.Web.Base.App;
using Saxonite.Net.Core.Web.Base.Controllers;
using Saxonite.Net.Standard.Base.App;
using Saxonite.Net.Standard.Base.Bus;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Saxonite.Net.Core.Web.Online.Models
{
//=======================================================================
/// <summary>
/// Online model data.
/// </summary>
public class ModelData_Online
{
//-------------------------------------------------------------------
// Construction.
public ModelData_Online(SaxModel_Online model)
{
this.Model = model;
}
//-------------------------------------------------------------------
// Properties.
public SaxModel_Online Model { get; }
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -0,0 +1,116 @@
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Helpers;
using Sarand.Net.Standard.Base.Utils;
using Saxonite.Base.App;
using Saxonite.Net.Core.Web.Base.App;
using Saxonite.Net.Core.Web.Base.Controllers;
using Saxonite.Net.Standard.Base.App;
using Saxonite.Net.Standard.Base.Bus;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Saxonite.Net.Core.Web.Online.Models
{
//=======================================================================
/// <summary>
/// Organisation model data properties.
/// </summary>
public class ModelData_Organisation : ModelData_Online
{
//-------------------------------------------------------------------
// Construction.
public ModelData_Organisation(SaxModel_Online model, String controlNameSuffix = "Organisation") : base(model)
{
this.ControlNameSuffix = StringUtil.EmptyOnNull(controlNameSuffix);
Address = new ModelData_Address(model, ControlNameSuffix);
}
//-------------------------------------------------------------------
// Properties.
private String ControlNameSuffix { get; }
// Organisation properties.
public String Id { get; set; }
public String Name { get; set; }
public String Type { get; set; }
public Sax.OrganisationType GetOrganisationType() { return (Sax.OrganisationType)Model.OrganisationTypeCodes.GetTypeForCode(Type); }
public String Category { get; set; }
public Sax.OrganisationCategory GetOrganisationCategory() { return (Sax.OrganisationCategory)Model.OrganisationCategoryCodes.GetTypeForCode(Category); }
public String SportId { get; set; }
public String RegionIdCountry { get; set; }
public String PhoneMain { get; set; }
// Address.
public ModelData_Address Address { get; }
//-------------------------------------------------------------------
// Validation.
//-------------------------------------------------------------------
// Organisation.
public bool ValidateOrganisationData(SaxController_Base.AjaxResponse_Data responseData)
{
// Name - mandatory.
responseData.SetControlValue(ControlNameSuffix + "Name", Name);
if (StringUtil.IsEmpty(Name))
responseData.SetControlError(ControlNameSuffix + "Name", Model.Localiser["msg.validation.mandatory.value"]);
else if (StringUtil.GetLength(Name) > Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.Organisation_Name))
responseData.SetControlError(ControlNameSuffix + "Name", Model.Localiser["msg.validation.maximum.length", Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.Organisation_Name)]);
else if (SysId.IsValid(Model.ExtractSysId(RegionIdCountry)))
{
// Ensure that the organisation name is unique within the country.
SaxOrganisation.Params prmOrganisation = new SaxOrganisation.Params();
if (SysId.IsValid(Model.ExtractSysId(Id)))
prmOrganisation.IdsExcluded.Add(Model.ExtractSysId(Id));
prmOrganisation.NameFull = Name;
prmOrganisation.RegionIdsIncluded.Add(Model.ExtractSysId(RegionIdCountry));
prmOrganisation.StatusCat = SaxOrganisation.StatusCat.Any;
if (Model.AccountMgr.GetOrganisationCount(prmOrganisation) > 0)
responseData.SetControlError(ControlNameSuffix + "Name", Model.Localiser["msg.validation.duplicate.value"]);
}
// Organisation Category - mandatory.
if (StringUtil.IsEmpty(Category))
responseData.SetControlError(ControlNameSuffix + "Category", Model.Localiser["msg.validation.mandatory.value"]);
// Organisation Type - mandatory.
if (StringUtil.IsEmpty(Type))
responseData.SetControlError(ControlNameSuffix + "Type", Model.Localiser["msg.validation.mandatory.value"]);
// Sport - mandatory for certain organisation categories.
if (StringUtil.IsEmpty(SportId) && SaxOrganisation.IsSportMandatory(GetOrganisationCategory()))
responseData.SetControlError(ControlNameSuffix + "SportId", Model.Localiser["msg.validation.mandatory.value"]);
else if (!StringUtil.IsEmpty(SportId) && !SysId.IsValid(Model.ExtractSysId(SportId)))
responseData.SetControlError(ControlNameSuffix + "SportId", Model.Localiser["msg.validation.invalid.value"]);
// Region Country - mandatory.
if (StringUtil.IsEmpty(RegionIdCountry))
responseData.SetControlError(ControlNameSuffix + "RegionIdCountry", Model.Localiser["msg.validation.mandatory.value"]);
else if (!SysId.IsValid(Model.ExtractSysId(RegionIdCountry)))
responseData.SetControlError(ControlNameSuffix + "RegionIdCountry", Model.Localiser["msg.validation.invalid.value"]);
// Phone Main - optional.
if (PhoneMain != null)
{
responseData.SetControlValue(ControlNameSuffix + "PhoneMain", PhoneMain);
if (!StringUtil.IsEmpty(PhoneMain))
{
if (!SacsDataValidationHelper.IsValidPhone(PhoneMain))
responseData.SetControlError(ControlNameSuffix + "PhoneMain", Model.Localiser["msg.validation.invalid.value"]);
else if (StringUtil.GetLength(PhoneMain) > Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.Organisation_PhoneMain))
responseData.SetControlError(ControlNameSuffix + "PhoneMain", Model.Localiser["msg.validation.maximum.length", Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.Organisation_PhoneMain)]);
}
}
// Address.
Address.ValidateAddressData(responseData);
return !responseData.HasControlErrors();
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -23,6 +23,10 @@ namespace Saxonite.Net.Core.Web.Online.Models
public Model_Account(SaxLocaliser localiser) :
base(localiser)
{
// Model data.
Organisation = new ModelData_Organisation(this);
// Page includes.
AdditionalFiles_CSS.Add("css/sax-account.css");
AdditionalFiles_JS.Add("js/sax-account.js");
AdditionalFiles_JS.Add("js/sax-usr-pro.js");
@@ -74,7 +78,13 @@ namespace Saxonite.Net.Core.Web.Online.Models
public String ProfileSportAbout { get; set; }
//-------------------------------------------------------------------
// Validate users's contact details.
// Organisation properties.
public ModelData_Organisation Organisation { get; }
//-------------------------------------------------------------------
// Validate modela data.
//-------------------------------------------------------------------
// Validate contact details.
public bool ValidateContactDetails(SaxController_Base.AjaxResponse_Data responseData)
{
//---------------------------------------------------------------
@@ -166,6 +176,7 @@ namespace Saxonite.Net.Core.Web.Online.Models
}
//-------------------------------------------------------------------
// Validate Sport data.
public bool ValidateProfileSportData(SaxController_Base.AjaxResponse_Data responseData)
{
// Sport.
@@ -190,6 +201,15 @@ namespace Saxonite.Net.Core.Web.Online.Models
return !responseData.HasControlErrors();
}
//-------------------------------------------------------------------
// Validate Organisation data.
public bool ValidateProfileOrganisationData(SaxController_Base.AjaxResponse_Data responseData)
{
Organisation.ValidateOrganisationData(responseData);
return !responseData.HasControlErrors();
}
//-------------------------------------------------------------------
}
//=======================================================================
@@ -23,6 +23,10 @@ namespace Saxonite.Net.Core.Web.Online.Models
public Model_Organisation(SaxLocaliser localiser) :
base(localiser)
{
// Model data.
Organisation = new ModelData_Organisation(this);
// Page includes.
//AdditionalFiles_CSS.Add("css/sax-org.css");
AdditionalFiles_JS.Add("js/sax-org.js");
}
@@ -39,23 +43,7 @@ namespace Saxonite.Net.Core.Web.Online.Models
//-------------------------------------------------------------------
// Organisation properties.
public String OrganisationName { get; set; }
public String OrganisationType { get; set; }
public Sax.OrganisationType GetOrganisationType() { return (Sax.OrganisationType)OrganisationTypeCodes.GetTypeForCode(OrganisationType); }
public String OrganisationCategory { get; set; }
public Sax.OrganisationCategory GetOrganisationCategory() { return (Sax.OrganisationCategory)OrganisationCategoryCodes.GetTypeForCode(OrganisationCategory); }
public String OrganisationSportId { get; set; }
public String OrganisationRegionIdCountry { get; set; }
public String OrganisationPhoneMain { get; set; }
// Organisation address
public String OrganisationAddressLine1 { get; set; }
public String OrganisationAddressLine2 { get; set; }
public String OrganisationAddressLine3 { get; set; }
public String OrganisationAddressTown { get; set; }
public String OrganisationAddressProvince { get; set; }
public String OrganisationAddressRegionIdProvince { get; set; }
public String OrganisationAddressCountry { get; set; }
public String OrganisationAddressPostalCode { get; set; }
public ModelData_Organisation Organisation { get; set; }
// User - for organisation request.
public String ContactEmailAddress { get; set; }
public String ContactFirstName { get; set; }
@@ -101,124 +89,8 @@ namespace Saxonite.Net.Core.Web.Online.Models
responseData.SetControlError(nameof(ContactLastName), Localiser["msg.validation.maximum.length", GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.UserAccount_LastName)]);
}
// Organisation Name - mandatory.
responseData.SetControlValue(nameof(OrganisationName), OrganisationName);
if (StringUtil.IsEmpty(OrganisationName))
responseData.SetControlError(nameof(OrganisationName), Localiser["msg.validation.mandatory.value"]);
else if (StringUtil.GetLength(OrganisationName) > GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.Organisation_Name))
responseData.SetControlError(nameof(OrganisationName), Localiser["msg.validation.maximum.length", GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.Organisation_Name)]);
else if (SysId.IsValid(ExtractSysId(OrganisationRegionIdCountry)))
{
// Ensure that the organisation name is unique within the country.
SaxOrganisation.Params prmOrganisation = new SaxOrganisation.Params();
prmOrganisation.NameFull = OrganisationName;
prmOrganisation.RegionIdsIncluded.Add(ExtractSysId(OrganisationRegionIdCountry));
prmOrganisation.StatusCat = SaxOrganisation.StatusCat.Any;
if (AccountMgr.GetOrganisationCount(prmOrganisation) > 0)
responseData.SetControlError(nameof(OrganisationName), Localiser["msg.validation.duplicate.value"]);
}
// Organisation Category - mandatory.
if (StringUtil.IsEmpty(OrganisationCategory))
responseData.SetControlError(nameof(OrganisationCategory), Localiser["msg.validation.mandatory.value"]);
// Organisation Type - mandatory.
if (StringUtil.IsEmpty(OrganisationType))
responseData.SetControlError(nameof(OrganisationType), Localiser["msg.validation.mandatory.value"]);
// Organisation Sport - mandatory for certain organisation categories.
if (StringUtil.IsEmpty(OrganisationSportId) && SaxOrganisation.IsSportMandatory(GetOrganisationCategory()))
responseData.SetControlError(nameof(OrganisationSportId), Localiser["msg.validation.mandatory.value"]);
else if (!StringUtil.IsEmpty(OrganisationSportId) && !SysId.IsValid(ExtractSysId(OrganisationSportId)))
responseData.SetControlError(nameof(OrganisationSportId), Localiser["msg.validation.invalid.value"]);
// Organisation Region Country - mandatory.
if (StringUtil.IsEmpty(OrganisationRegionIdCountry))
responseData.SetControlError(nameof(OrganisationRegionIdCountry), Localiser["msg.validation.mandatory.value"]);
else if (!SysId.IsValid(ExtractSysId(OrganisationRegionIdCountry)))
responseData.SetControlError(nameof(OrganisationRegionIdCountry), Localiser["msg.validation.invalid.value"]);
// Organisation Address Line 1 - mandatory.
responseData.SetControlValue(nameof(OrganisationAddressLine1), OrganisationAddressLine1);
if (StringUtil.IsEmpty(OrganisationAddressLine1))
responseData.SetControlError(nameof(OrganisationAddressLine1), Localiser["msg.validation.mandatory.value"]);
else if (StringUtil.GetLength(OrganisationAddressLine1) > GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line1))
responseData.SetControlError(nameof(OrganisationAddressLine1), Localiser["msg.validation.maximum.length", GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line1)]);
// Organisation Address Line 2 - optional.
if (OrganisationAddressLine2 != null)
{
responseData.SetControlValue(nameof(OrganisationAddressLine2), OrganisationAddressLine2);
if (!StringUtil.IsEmpty(OrganisationAddressLine2))
{
if (StringUtil.GetLength(OrganisationAddressLine2) > GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line2))
responseData.SetControlError(nameof(OrganisationAddressLine2), Localiser["msg.validation.maximum.length", GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line2)]);
}
}
// Organisation Address Line 3 - optional.
if (OrganisationAddressLine3 != null)
{
responseData.SetControlValue(nameof(OrganisationAddressLine3), OrganisationAddressLine3);
if (!StringUtil.IsEmpty(OrganisationAddressLine3))
{
if (StringUtil.GetLength(OrganisationAddressLine3) > GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line3))
responseData.SetControlError(nameof(OrganisationAddressLine3), Localiser["msg.validation.maximum.length", GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line3)]);
}
}
// Organisation Address Town - mandatory.
responseData.SetControlValue(nameof(OrganisationAddressTown), OrganisationAddressTown);
if (StringUtil.IsEmpty(OrganisationAddressTown))
responseData.SetControlError(nameof(OrganisationAddressTown), Localiser["msg.validation.mandatory.value"]);
else if (StringUtil.GetLength(OrganisationAddressTown) > GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Town))
responseData.SetControlError(nameof(OrganisationAddressTown), Localiser["msg.validation.maximum.length", GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Town)]);
// Organisation Address Province - optional.
if (OrganisationAddressProvince != null)
{
responseData.SetControlValue(nameof(OrganisationAddressProvince), OrganisationAddressProvince);
if (!StringUtil.IsEmpty(OrganisationAddressProvince))
{
if (StringUtil.GetLength(OrganisationAddressProvince) > GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Province))
responseData.SetControlError(nameof(OrganisationAddressProvince), Localiser["msg.validation.maximum.length", GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Province)]);
}
}
// Organisation Address Country - optional.
if (OrganisationAddressCountry != null)
{
responseData.SetControlValue(nameof(OrganisationAddressCountry), OrganisationAddressCountry);
if (!StringUtil.IsEmpty(OrganisationAddressCountry))
{
if (StringUtil.GetLength(OrganisationAddressCountry) > GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Country))
responseData.SetControlError(nameof(OrganisationAddressCountry), Localiser["msg.validation.maximum.length", GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Country)]);
}
}
// Organisation Address PostalCode - optional.
if (OrganisationAddressPostalCode != null)
{
responseData.SetControlValue(nameof(OrganisationAddressPostalCode), OrganisationAddressPostalCode);
if (!StringUtil.IsEmpty(OrganisationAddressPostalCode))
{
if (StringUtil.GetLength(OrganisationAddressPostalCode) > GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_PostalCode))
responseData.SetControlError(nameof(OrganisationAddressPostalCode), Localiser["msg.validation.maximum.length", GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_PostalCode)]);
}
}
// Organisation Phone Main - optional.
if (OrganisationPhoneMain != null)
{
responseData.SetControlValue(nameof(OrganisationPhoneMain), OrganisationPhoneMain);
if (!StringUtil.IsEmpty(OrganisationPhoneMain))
{
if (!SacsDataValidationHelper.IsValidPhone(OrganisationPhoneMain))
responseData.SetControlError(nameof(OrganisationPhoneMain), Localiser["msg.validation.invalid.value"]);
else if (StringUtil.GetLength(OrganisationPhoneMain) > GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.Organisation_PhoneMain))
responseData.SetControlError(nameof(OrganisationPhoneMain), Localiser["msg.validation.maximum.length", GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.Organisation_PhoneMain)]);
}
}
// Organisation properties.
Organisation.ValidateOrganisationData(responseData);
return !responseData.HasControlErrors();
}
@@ -0,0 +1,120 @@
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils;
using Saxonite.Base.App;
using Saxonite.Net.Core.Web.Base.App;
using Saxonite.Net.Core.Web.Base.Controllers;
using Saxonite.Net.Standard.Base.Bus;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Saxonite.Net.Core.Web.Online.Models
{
//=======================================================================
public class Model_Organisation_Events : SaxModel_Online
{
//-------------------------------------------------------------------
// Construction.
public Model_Organisation_Events(SaxLocaliser localiser) :
base(localiser)
{
//AdditionalFiles_CSS.Add("css/sax-org-evt.css");
AdditionalFiles_JS.Add("js/sax-org-evt.js");
}
//-------------------------------------------------------------------
// List configuration.
public class EventFilterData
{
public String OrganisationId { get; set; }
public String OrganisationCaption { get; set; }
public String Event { get; set; }
}
public EventFilterData Filter { get; } = new EventFilterData();
//-------------------------------------------------------------------
// Event properties.
public String EventId { get; set; }
public String EventExists { get; set; }
// Event properties.
public String EventOrganisationId { get; set; }
// Sport.
public String EventSportIdPrimary { get; set; }
// Region.
public String EventRegionIdCountry { get; set; }
// Event Content.
public String EventDate { get; set; }
public String EventTime { get; set; }
public String EventTypeCode { get; set; }
public String EventAbout { get; set; }
public String EventStatusCode { get; set; }
public SaStatus EventStatus { get { return SacsSystem.GetStatusForCode(EventStatusCode); } }
//-------------------------------------------------------------------
// Validation.
//-------------------------------------------------------------------
// Event.
public bool ValidateEventData(SaxController_Base.AjaxResponse_Data responseData)
{
// Event type.
if (EventTypeCode != null)
{
if (StringUtil.IsEmpty(EventTypeCode))
responseData.SetControlError(nameof(EventTypeCode), Localiser["msg.validation.mandatory.value"]);
}
// Event date.
if (EventDate != null)
{
}
// Event time.
if (EventTime != null)
{
}
// Event about.
if (EventAbout != null)
{
responseData.SetControlValue(nameof(EventAbout), EventAbout);
if (StringUtil.IsEmpty(EventAbout))
responseData.SetControlError(nameof(EventAbout), Localiser["msg.validation.mandatory.value"]);
else if (StringUtil.GetLength(EventAbout) > GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_About))
responseData.SetControlError(nameof(EventAbout), Localiser["msg.validation.maximum.length", GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_About)]);
}
// Event sport.
if (EventSportIdPrimary != null)
{
SysId articleSportId = ExtractSysId(EventSportIdPrimary);
if (!SysId.IsValid(articleSportId))
responseData.SetControlError(nameof(EventSportIdPrimary), Localiser["msg.validation.mandatory.value"]);
}
// Event region.
if (EventRegionIdCountry != null)
{
SysId articleRegionId = ExtractSysId(EventRegionIdCountry);
if (!SysId.IsValid(articleRegionId))
responseData.SetControlError(nameof(EventRegionIdCountry), Localiser["msg.validation.mandatory.value"]);
}
// Event status.
if (EventStatusCode != null)
{
if (StringUtil.IsEmpty(EventStatusCode))
responseData.SetControlError(nameof(EventStatusCode), Localiser["msg.validation.mandatory.value"]);
else if (!SaxOrganisationEvent.ValidStatuses.Contains(EventStatus))
responseData.SetControlError(nameof(EventStatusCode), Localiser["msg.validation.invalid.value"]);
}
return !responseData.HasControlErrors();
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -34,13 +34,19 @@ namespace Saxonite.Net.Core.Web.Online.Models
}
//-------------------------------------------------------------------
// Session.
// Properties.
//-------------------------------------------------------------------
// Session.
public SaxSessionData_Online SessionData_Online { get { return SessionData as SaxSessionData_Online; } }
public SysId UserAccountId { get { return SessionData_Online?.User?.UserAccountId ?? null; } }
//-------------------------------------------------------------------
// Menu options.
public bool MembersAllowed { get { return UserCanManageOrganisationMembers; } }
public bool ArticlesAllowed { get { return UserIsJournalist || UserCanManageOrganisationArticles; } }
public bool OpportunitiesAllowed { get { return UserCanManageOrganisationOpportunities; } }
//-------------------------------------------------------------------
// Security profile.
public bool UserIsJournalist { get { return SessionData != null && SessionData.User != null && SessionData.User.IsJournalist; } }
public bool UserCanManageOrganisationMembers
@@ -50,7 +56,7 @@ namespace Saxonite.Net.Core.Web.Online.Models
if (userCanManageOrganisationMembers == null && ValidUserSession)
{
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
prmUserOrganisation.UserAccountIdsIncluded.Add(SessionData.User.UserAccountId);
prmUserOrganisation.UserAccountIdsIncluded.Add(UserAccountId);
prmUserOrganisation.OrganisationMembersOnly = true;
prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.Admin);
prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.MemberAdmin);
@@ -67,7 +73,7 @@ namespace Saxonite.Net.Core.Web.Online.Models
if (userCanManageOrganisationOpportunities == null && ValidUserSession)
{
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
prmUserOrganisation.UserAccountIdsIncluded.Add(SessionData.User.UserAccountId);
prmUserOrganisation.UserAccountIdsIncluded.Add(UserAccountId);
prmUserOrganisation.OrganisationMembersOnly = true;
prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.Admin);
prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.OpportunityAdmin);
@@ -84,7 +90,7 @@ namespace Saxonite.Net.Core.Web.Online.Models
if (userCanManageOrganisationSchedule == null && ValidUserSession)
{
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
prmUserOrganisation.UserAccountIdsIncluded.Add(SessionData.User.UserAccountId);
prmUserOrganisation.UserAccountIdsIncluded.Add(UserAccountId);
prmUserOrganisation.OrganisationMembersOnly = true;
prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.Admin);
prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.ScheduleAdmin);
@@ -101,7 +107,7 @@ namespace Saxonite.Net.Core.Web.Online.Models
if (userCanManageOrganisationArticles == null && ValidUserSession)
{
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
prmUserOrganisation.UserAccountIdsIncluded.Add(SessionData.User.UserAccountId);
prmUserOrganisation.UserAccountIdsIncluded.Add(UserAccountId);
prmUserOrganisation.OrganisationMembersOnly = true;
prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.Admin);
prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.ArticleAdmin);
@@ -1,14 +1,17 @@
@model Model_Account
@inject SaxLocaliser Localiser
@* Profile Organisations *@
<div class="sax-panel-section ProfileOrganisations sax-populating">
<div class="sax-panel-info">
@* Panel caption and burger menu *@
<div class="sax-header">
<div class="row">
<div class="col"><div class="sax-caption">@Localiser["account.caption.profile.organisations"]</div></div>
<div class="fixed">
@* Burger menu *@
<ul class="nav navbar-nav navbar-light navbar-right sax-burger">
<li class="dropdown-toggle caret-off">
<a href="#" class="dropdown" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="navbar-toggler-icon"></span></a>
@@ -17,24 +20,43 @@
</ul>
</li>
</ul>
@* Filter item templates *@
<div class="sax-panel-item-template">
@* Filter Burger dropdown template - ul is ignored *@
<ul class="sax-dropdown-menu ProfileOrganisations">
<li class="sax-dropdown-item sax-action"><div class="sax-label">...</div></li>
</ul>
</div>
</div>
</div>
</div>
<div class="sax-content">
<div class="sax-panel-results Organisations">
</div>
@* Profile Organisations list *@
<div class="sax-panel-results Organisations"></div>
</div>
@* Item templates *@
<div class="sax-panel-item-template">
@* Organisation template *@
<div class="sax-panel-item Organisation">
<div class="sax-header">
<div class="OrganisationName"></div>
<div class="sax-header row">
<div class="col"><div class="sax-caption"><div class="sax-action OrganisationName"></div></div></div>
<div class="fixed">
@* Burger menu *@
<ul class="nav navbar-nav navbar-light navbar-right sax-burger">
<li class="dropdown-toggle caret-off">
<a href="#" class="dropdown" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="navbar-toggler-icon"></span></a>
<ul class="dropdown-menu dropdown-menu-right sax-dropdown-menu">
</ul>
</li>
</ul>
</div>
</div>
<div class="sax-content">
<div class="row">
<div class="col-sm-6"><div class="OrganisationSport sax-note"></div></div>
<div class="col-sm-6 text-sm-right"><div class="OrganisationRegion sax-note"></div></div>
<div class="col-sm-6 text-sm-right"><div class="OrganisationRegionCountry sax-note"></div></div>
</div>
<div class="row">
<div class="col-sm-6"><div class="OrganisationMemberCount sax-note sa-action">@Localiser["label.members"]:&nbsp;<span class="MemberCount"></span></div></div>
@@ -42,30 +64,34 @@
</div>
</div>
</div>
@* Organisation Burger dropdown template - ul is ignored *@
<ul class="sax-dropdown-menu ProfileOrganisation">
<li class="sax-dropdown-item sax-action"><div class="sax-label">...</div></li>
</ul>
</div>
</div>
<div class="sax-panel-form">
<div class="sax-header">
<div class="row">
<div class="col"><div class="sax-caption">@Localiser["account.caption.profile.organisations"]</div></div>
<div class="fixed">
</div>
</div>
</div>
<div class="sax-content">
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmProfileOrganisations", @class = "sax-form", @onSubmit = "return false;" }))
@* Profile Organisation Id form *@
@using (Html.BeginForm(FormMethod.Post, new { @id = "frmProfileOrganisationId", @class = "sax-form", @onSubmit = "return false;" }))
{
@Html.HiddenFor(model => model.Organisation.Id, new { @id = "", @class = "OrganisationId" })
}
</div>
</div>
@* Profile Organisation dialog *@
<div id="dlgProfileOrganisation" class="sax-dialog" title="@Localiser["label.organisation"]">
<div class="spacer"></div>
@using (Html.BeginForm(FormMethod.Post, new { @id = "frmProfileOrganisation", @class = "sax-form", @onSubmit = "return false;" }))
{
@Html.HiddenFor(model => model.Organisation.Id, new { @id = "", @class = "OrganisationId" })
@Html.HiddenFor(model => model.Organisation.Address.Id, new { @id = "", @class = "OrganisationAddressId" })
<partial name="~/Views/Common/OrganisationControls.cshtml" />
}
<div class="spacer"></div>
</div>
<partial name="~/Views/Common/OrganisationRequest.cshtml" />
@@ -0,0 +1,208 @@
@model SaxModel_Online
@inject SaxLocaliser Localiser
<div class="sax-form-control">
<div class="sax-caption">
<label for=""><span>@Localiser["label.organsiation.details"]</span></label>
</div>
</div>
@* Organisation name *@
<div class="sax-form-control OrganisationName">
<div class="row">
<div class="col-sm-4">
<div class="sax-label">
<label for=""><span>@Localiser["label.name"]</span><span class="required">&nbsp;*</span></label>
</div>
</div>
<div class="col-sm">
<div class="sax-control">
<input type="text" name="Organisation.Name" class="OrganisationName sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.Organisation_Name)" />
</div>
<div class="sax-message"></div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-4"></div>
<div class="col-sm row">
@* Organisation category *@
<div class="col-sm-6">
<div class="sax-form-control OrganisationCategory pr4">
<div class="sax-label">
<label for=""><span>@Localiser["label.category"]</span><span class="required">&nbsp;*</span></label>
</div>
<div class="sax-control">
@Html.DropDownList("", Model.OrganisationCategoriesForSelect, Localiser["label.select"], new { @id = "", @name = "Organisation.Category", @class = "OrganisationCategory sax-select" })
</div>
<div class="sax-message"></div>
</div>
</div>
@* Organisation type *@
<div class="col-sm-6">
<div class="sax-form-control OrganisationType">
<div class="sax-label">
<label for=""><span>@Localiser["label.type"]</span><span class="required">&nbsp;*</span></label>
</div>
<div class="sax-control">
@Html.DropDownList("", Model.OrganisationTypesForSelect, Localiser["label.select"], new { @id = "", @name = "Organisation.Type", @class = "OrganisationType sax-select" })
</div>
<div class="sax-message"></div>
</div>
</div>
</div>
</div>
@* Organisation sport *@
<div class="sax-form-control OrganisationSportId">
<div class="row">
<div class="col-sm-4">
<div class="sax-label">
<label for=""><span>@Localiser["label.sport"]</span><span class="required">&nbsp;(*)</span></label>
</div>
</div>
<div class="col-sm">
<div class="sax-control row">
<input type="hidden" name="Organisation.SportId" OrganisationSportId"" class="OrganisationSportId" />
<div class="col"><input type="text" class="OrganisationSportCaption sax-input" readonly="readonly" /> </div>
<div class="fixed"><button class="SelectSport sax-button" style="min-width:auto;margin-left:4px;padding:4px 6px">@Localiser["label.select"]</button></div>
</div>
<div class="sax-message"></div>
</div>
</div>
</div>
@* Organisation country *@
<div class="sax-form-control OrganisationRegionIdCountry">
<div class="row">
<div class="col-sm-4">
<div class="sax-label">
<label for=""><span>@Localiser["label.country"]</span><span class="required">&nbsp;*</span></label>
</div>
</div>
<div class="col-sm">
<div class="sax-control row">
<input type="hidden" name="Organisation.RegionIdCountry" OrganisationRegionIdCountry"" class="OrganisationRegionIdCountry" />
<div class="col"><input type="text" class="OrganisationRegionCaptionCountry sax-input" readonly="readonly" /> </div>
<div class="fixed"><button class="SelectRegionCountry sax-button" style="min-width:auto;margin-left:4px;padding:4px 6px">@Localiser["label.select"]</button></div>
</div>
<div class="sax-message"></div>
</div>
</div>
</div>
@* Organisation PhoneMain *@
<div class="sax-form-control OrganisationPhoneMain">
<div class="row">
<div class="col-sm-4">
<div class="sax-label">
<label for=""><span>@Localiser["label.phone"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sax-control row">
<div class="col"><input type="text" name="Organisation.PhoneMain" class="OrganisationPhoneMain sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.Organisation_PhoneMain)" /> </div>
</div>
<div class="sax-message"></div>
</div>
</div>
</div>
@* Organisation address - Line 1 *@
<div class="sax-form-control OrganisationAddressLine1">
<div class="row">
<div class="col-sm-4">
<div class="sax-caption">
<label for=""><span>@Localiser["label.organisation.address"]</span><span class="required">&nbsp;*</span></label>
</div>
</div>
<div class="col-sm">
<div class="sax-control row">
<div class="col"><input type="text" name="Organisation.Address.Line1" class="OrganisationAddressLine1 sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line1)" /> </div>
</div>
<div class="sax-message"></div>
</div>
</div>
</div>
@* Organisation address - Line 2 *@
<div class="sax-form-control OrganisationAddressLine2">
<div class="row">
<div class="col-sm-4"></div>
<div class="col-sm">
<div class="sax-control row">
<div class="col"><input type="text" name="Organisation.Address.Line2" class="OrganisationAddressLine2 sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line2)" /> </div>
</div>
<div class="sax-message"></div>
</div>
</div>
</div>
@* Organisation address - Line 3 *@
<div class="sax-form-control OrganisationAddressLine3">
<div class="row">
<div class="col-sm-4"></div>
<div class="col-sm">
<div class="sax-control row">
<div class="col"><input type="text" name="Organisation.Address.Line3" class="OrganisationAddressLine3 sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line3)" /> </div>
</div>
<div class="sax-message"></div>
</div>
</div>
</div>
@* Organisation address - Town *@
<div class="sax-form-control OrganisationAddressTown">
<div class="row">
<div class="col-sm-4">
<div class="sax-label">
<label for=""><span>@Localiser["label.town"]</span><span class="required">&nbsp;*</span></label>
</div>
</div>
<div class="col-sm">
<div class="sax-control row">
<div class="col"><input type="text" name="Organisation.Address.Town" class="OrganisationAddressTown sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Town)" /> </div>
</div>
<div class="sax-message"></div>
</div>
</div>
</div>
@* Organisation address - Province *@
<div class="sax-form-control OrganisationAddressProvince">
<div class="row">
<div class="col-sm-4">
<div class="sax-label">
<label for=""><span>@Localiser["label.province"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sax-control row">
<div class="col"><input type="text" name="Organisation.Address.Province" class="OrganisationAddressProvince sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Province)" /> </div>
</div>
<div class="sax-message"></div>
</div>
</div>
</div>
@* Organisation address - PostalCode *@
<div class="sax-form-control OrganisationAddressPostalCode">
<div class="row">
<div class="col-sm-4">
<div class="sax-label">
<label for=""><span>@Localiser["label.postalCode"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sax-control row">
<div class="col"><input type="text" name="Organisation.Address.PostalCode" class="OrganisationAddressPostalCode sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_PostalCode)" /> </div>
</div>
<div class="sax-message"></div>
</div>
</div>
</div>
@@ -1,7 +1,7 @@
@model SaxModel_Online
@inject SaxLocaliser Localiser
@{
String regionIdCountry = Model.ValidUserSession ? Model.SessionData.User.RegionIdCountry.ToString() : "";
Microsoft.AspNetCore.Html.HtmlString regionIdCountry = new Microsoft.AspNetCore.Html.HtmlString(Model.ValidUserSession ? Model.GetEncryptedRegionId(Model.SessionData.User.RegionIdCountry) : "");
String regionNameCountry = Model.ValidUserSession ? Localiser.EscapeJavascriptText(Model.GetRegionCaption(Model.SessionData.User.RegionIdCountry)) : "";
}
<script type="text/javascript">
@@ -78,210 +78,7 @@
}
<div class="sax-form-control">
<div class="sax-caption">
<label for=""><span>@Localiser["label.organsiation.details"]</span></label>
</div>
</div>
@* Organisation name *@
<div class="sax-form-control OrganisationName">
<div class="row">
<div class="col-sm-4">
<div class="sax-label">
<label for="ifOrganisationName"><span>@Localiser["label.name"]</span><span class="required">&nbsp;*</span></label>
</div>
</div>
<div class="col-sm">
<div class="sax-control">
<input type="text" id="ifOrganisationName" name="OrganisationName" class="OrganisationName sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.Organisation_Name)" />
</div>
<div class="sax-message"></div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-4"></div>
<div class="col-sm row">
@* Organisation category *@
<div class="col-sm-6">
<div class="sax-form-control OrganisationCategory pr4">
<div class="sax-label">
<label for="cbOrganisationCategory"><span>@Localiser["label.category"]</span><span class="required">&nbsp;*</span></label>
</div>
<div class="sax-control">
@Html.DropDownList("", Model.OrganisationCategoriesForSelect, Localiser["label.select"], new { @id = "cbOrganisationCategory", @name = "OrganisationCategory", @class = "OrganisationCategory sax-select" })
</div>
<div class="sax-message"></div>
</div>
</div>
@* Organisation type *@
<div class="col-sm-6">
<div class="sax-form-control OrganisationType">
<div class="sax-label">
<label for="cbOrganisationType"><span>@Localiser["label.type"]</span><span class="required">&nbsp;*</span></label>
</div>
<div class="sax-control">
@Html.DropDownList("", Model.OrganisationTypesForSelect, Localiser["label.select"], new { @id = "cbOrganisationType", @name = "OrganisationType", @class = "OrganisationType sax-select" })
</div>
<div class="sax-message"></div>
</div>
</div>
</div>
</div>
@* Organisation sport *@
<div class="sax-form-control OrganisationSportId">
<div class="row">
<div class="col-sm-4">
<div class="sax-label">
<label for="ifOrganisationSportCaption"><span>@Localiser["label.sport"]</span><span class="required">&nbsp;(*)</span></label>
</div>
</div>
<div class="col-sm">
<div class="sax-control row">
<input type="hidden" id="ifOrganisationSportId" name="OrganisationSportId" OrganisationSportId"" class="OrganisationSportId" />
<div class="col"><input type="text" id="ifOrganisationSportCaption" class="OrganisationSportCaption sax-input" readonly="readonly" ondblclick="sax.selectSport()" /> </div>
<div class="fixed"><button class="SelectSport sax-button" style="min-width:auto;margin-left:4px;padding:4px 6px" onclick="sax.selectOrgSport()">@Localiser["label.select"]</button></div>
</div>
<div class="sax-message"></div>
</div>
</div>
</div>
@* Organisation country *@
<div class="sax-form-control OrganisationRegionIdCountry">
<div class="row">
<div class="col-sm-4">
<div class="sax-label">
<label for="ifOrganisationRegionCaption"><span>@Localiser["label.country"]</span><span class="required">&nbsp;*</span></label>
</div>
</div>
<div class="col-sm">
<div class="sax-control row">
<input type="hidden" id="ifOrganisationRegionIdCountry" name="OrganisationRegionIdCountry" OrganisationRegionIdCountry"" class="OrganisationRegionIdCountry" />
<div class="col"><input type="text" id="ifOrganisationRegionCaptionCountry" class="OrganisationRegionCaptionCountry sax-input" readonly="readonly" ondblclick="sax.selectRegion()" /> </div>
<div class="fixed"><button class="SelectRegion sax-button" style="min-width:auto;margin-left:4px;padding:4px 6px" onclick="sax.selectOrgRegion()">@Localiser["label.select"]</button></div>
</div>
<div class="sax-message"></div>
</div>
</div>
</div>
@* Organisation address - Line 1 *@
<div class="sax-form-control OrganisationAddressLine1">
<div class="row">
<div class="col-sm-4">
<div class="sax-caption">
<label for="ifOrganisationAddressLine1"><span>@Localiser["label.organisation.address"]</span><span class="required">&nbsp;*</span></label>
</div>
</div>
<div class="col-sm">
<div class="sax-control row">
<div class="col"><input type="text" id="ifOrganisationAddressLine1" name="OrganisationAddressLine1" class="OrganisationAddressLine1 sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line1)" /> </div>
</div>
<div class="sax-message"></div>
</div>
</div>
</div>
@* Organisation address - Line 2 *@
<div class="sax-form-control OrganisationAddressLine2">
<div class="row">
<div class="col-sm-4"></div>
<div class="col-sm">
<div class="sax-control row">
<div class="col"><input type="text" id="ifOrganisationAddressLine2" name="OrganisationAddressLine2" class="OrganisationAddressLine2 sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line2)" /> </div>
</div>
<div class="sax-message"></div>
</div>
</div>
</div>
@* Organisation address - Line 3 *@
<div class="sax-form-control OrganisationAddressLine3">
<div class="row">
<div class="col-sm-4"></div>
<div class="col-sm">
<div class="sax-control row">
<div class="col"><input type="text" id="ifOrganisationAddressLine3" name="OrganisationAddressLine3" class="OrganisationAddressLine3 sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line3)" /> </div>
</div>
<div class="sax-message"></div>
</div>
</div>
</div>
@* Organisation address - Town *@
<div class="sax-form-control OrganisationAddressTown">
<div class="row">
<div class="col-sm-4">
<div class="sax-label">
<label for="ifOrganisationAddressTown"><span>@Localiser["label.town"]</span><span class="required">&nbsp;*</span></label>
</div>
</div>
<div class="col-sm">
<div class="sax-control row">
<div class="col"><input type="text" id="ifOrganisationAddressTown" name="OrganisationAddressTown" class="OrganisationAddressTown sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Town)" /> </div>
</div>
<div class="sax-message"></div>
</div>
</div>
</div>
@* Organisation address - Province *@
<div class="sax-form-control OrganisationAddressProvince">
<div class="row">
<div class="col-sm-4">
<div class="sax-label">
<label for="ifOrganisationAddressProvince"><span>@Localiser["label.province"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sax-control row">
<div class="col"><input type="text" id="ifOrganisationAddressProvince" name="OrganisationAddressProvince" class="OrganisationAddressProvince sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Province)" /> </div>
</div>
<div class="sax-message"></div>
</div>
</div>
</div>
@* Organisation address - PostalCode *@
<div class="sax-form-control OrganisationAddressPostalCode">
<div class="row">
<div class="col-sm-4">
<div class="sax-label">
<label for="ifOrganisationAddressPostalCode"><span>@Localiser["label.postalCode"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sax-control row">
<div class="col"><input type="text" id="ifOrganisationAddressPostalCode" name="OrganisationAddressPostalCode" class="OrganisationAddressPostalCode sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_PostalCode)" /> </div>
</div>
<div class="sax-message"></div>
</div>
</div>
</div>
@* Organisation PhoneMain *@
<div class="sax-form-control OrganisationPhoneMain">
<div class="row">
<div class="col-sm-4">
<div class="sax-label">
<label for="ifOrganisationPhoneMain"><span>@Localiser["label.phone"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sax-control row">
<div class="col"><input type="text" id="ifOrganisationPhoneMain" name="OrganisationPhoneMain" class="OrganisationPhoneMain sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.Organisation_PhoneMain)" /> </div>
</div>
<div class="sax-message"></div>
</div>
</div>
</div>
<partial name="~/Views/Common/OrganisationControls.cshtml" />
}
@@ -1,7 +1,7 @@
@model SaxModel_Online
@inject SaxLocaliser Localiser
<script src="~/js/sax-resultsPaging.js?@Model.HrefVersion"></script>
<script src="~/js/sax-res-pag.js?@Model.HrefVersion"></script>
<script type="text/javascript">
sax.mdl.resultsPaging.msg.pageInfo = '@Localiser.GetJavascriptText("label.page.info","{0}","{1}")';
</script>
@@ -20,13 +20,13 @@
}
or.fn.storeOrganisation = function ()
{
//sax.debug('refreshResults');
//sax.debug('storeOrganisation');
or.ajax.registerOrg = or.ajax.registerOrg || { url: sax.url.base + 'Organisation/Ajax/Request', formId: 'frmOrganisationRequest', callbackFn: or.fn.handleRequestOrganisationResponse };
sax.doAjaxRequest(or.ajax.registerOrg, 50);
}
or.fn.handleRequestOrganisationResponse = function (response)
{
//sax.debug('or.handleRequestOrganisationResponse', response);
//sax.debug('handleRequestOrganisationResponse', response);
if (!response) return;
sax.refreshControlValues(response.controlValues, or.$frm);
if (!response.success) return;
@@ -38,22 +38,23 @@
}
//--------------------------------------------------------------
sax.selectOrgSport = function ()
or.selectOrgSport = function ()
{
sax.mdl.selectSport.fn.selectSport({ caption: sax.dlg.title.selectSport, sportId: $('.OrganisationSportId', or.$frm).val(), fnCallback: sax.onSelectOrgSport })
sax.mdl.selectSport.fn.selectSport({ caption: sax.dlg.title.selectSport, sportId: $('.OrganisationSportId', or.$frm).val(), fnCallback: or.onSelectOrgSport })
}
sax.onSelectOrgSport = function (sport)
or.onSelectOrgSport = function (sport)
{
sax.clearControlError($('.OrganisationSportId', or.$frm).val(sport.id));
$('.OrganisationSportCaption', or.$frm).val(sport ? sport.name : '');
}
//--------------------------------------------------------------
sax.selectOrgRegion = function ()
or.selectOrgRegionCountry = function ()
{
sax.mdl.selectRegion.fn.selectRegion({ caption: sax.dlg.title.selectRegion, regionId: $('.OrganisationRegionIdCountry', or.$frm).val(), typesInc:[30], fnCallback: sax.onSelectOrgRegion })
sax.debug($('.OrganisationRegionIdCountry', or.$frm).val());
sax.mdl.selectRegion.fn.selectRegion({ caption: sax.dlg.title.selectRegion, regionId: $('.OrganisationRegionIdCountry', or.$frm).val(), typesInc: [30], fnCallback: or.onSelectOrgRegionCountry })
}
sax.onSelectOrgRegion = function (region)
or.onSelectOrgRegionCountry = function (region)
{
sax.clearControlError($('.OrganisationRegionIdCountry', or.$frm).val(region.id));
$('.OrganisationRegionCaptionCountry', or.$frm).val(region ? region.name : '');
@@ -69,6 +70,8 @@
opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); or.fn.cleanUp(); };
or.$dlg = $('#dlgOrganisationRequest').dialog(opt);
or.$frm = $('#frmOrganisationRequest', or.$dlg);
or.$frm.on('dblclick', 'input.OrganisationSportCaption', or.selectOrgSport).on('click', 'button.SelectSport', or.selectOrgSport);
or.$frm.on('dblclick', 'input.OrganisationRegionCaptionCountry', or.selectOrgRegionCountry).on('click', 'button.SelectRegionCountry', or.selectOrgRegionCountry);
$('.sax-input, .sax-textarea', or.$frm).on('input', function () { sax.clearControlError(this); });
$('.sax-select', or.$frm).on('change', function () { sax.clearControlError(this); });
}
+133 -13
View File
@@ -26,36 +26,156 @@
}
po.onRefreshProfileOrganisationsInfo = function (response)
{
sax.debug('onRefreshProfileOrganisationsInfo', response);
//sax.debug('onRefreshProfileOrganisationsInfo', response);
if (!response || !response.success) return;
$('.sax-message', $pnl.section).stop(true, false).fadeOut(200).empty();
let items = response.organisations;
if (!items) return;
let $items = $('.sax-panel-results.Organisations', $pnl.section).empty();
let $tmpl = $('.sax-panel-item-template .sax-panel-item.Organisation', $pnl.section);
for (let itemIdx = 0; itemIdx < items.length; itemIdx++)
{
let item = items[itemIdx];
let $item = $tmpl.clone().prop('id', 'ProOrg_' + item.id);
$('.OrganisationName', $item).text(item.name);
$('.OrganisationSport', $item).text(item.sportName);
$('.OrganisationRegion', $item).text(item.regionName);
$('.OrganisationMemberCount', $item).toggle(!!item.memberCount).find('.MemberCount').text(item.memberCount);
$('.OrganisationOpportunityCount', $item).toggle(!!item.opportunityCount).find('.MemberCount').text(item.opportunityCount);
$items.append($item);
}
$items.show();
$items.append(po.populateItem(po.getItemTemplate(), items[itemIdx]));
$items.fadeIn(50);
sax.showNoInfoMsg($pnl.section);
$pnl.section.removeClass('sax-populating');
}
po.populateItem = function ($item, item)
{
if (!item) return;
$('.OrganisationName', $item).text(item.name);
$('.OrganisationSport', $item).text(item.sportName);
$('.OrganisationRegionCountry', $item).text(item.regionNameCountry);
$('.OrganisationMemberCount', $item).toggle(!!item.memberCount).find('.MemberCount').text(item.memberCount);
$('.OrganisationOpportunityCount', $item).toggle(!!item.opportunityCount).find('.MemberCount').text(item.opportunityCount);
let $bgr = $('.sax-burger', $item);
let $mnu = $('ul.sax-dropdown-menu', $bgr).empty();
if (item.admin)
{
let fnUpd = function () { po.updateOrganisation($item, item); };
$mnu.append(po.getItemMenuOption(sax.lbl.edit, fnUpd, 'sax-edit'));
$('.sax-caption .sax-action', $item).off('click').on('click', fnUpd);
$item.off('dblclick').on('dblclick', fnUpd);
}
else $('.sax-caption .sax-action', $item).removeClass('sax-action');
$bgr.toggle(!!$('.sax-dropdown-menu .sax-dropdown-item', $item).length);
return $item;
}
//--------------------------------------------------------------
po.getHeaderDropdownTemplate = function ()
{
return $('.sax-panel-item-template .sax-dropdown-menu.ProfileOrganisations li.sax-dropdown-item', $pnl.section).clone();
}
po.getItemTemplate = function ()
{
return $('.sax-panel-item-template .sax-panel-item.Organisation', $pnl.section).clone();
}
po.getItemDropdownTemplate = function ()
{
return $('.sax-panel-item-template .sax-dropdown-menu.ProfileOrganisation li.sax-dropdown-item', $pnl.section).clone();
}
po.getHeaderMenuOption = function (lbl, fn, cls)
{
return po.getMenuOption(po.getHeaderDropdownTemplate(), lbl, fn, cls);
}
po.getItemMenuOption = function (lbl, fn, cls)
{
return po.getMenuOption(po.getItemDropdownTemplate(), lbl, fn, cls);
}
po.getMenuOption = function ($opt, lbl, fn, cls)
{
return $opt.find('div.sax-label').text(lbl).end().on('click', fn).addClass(cls);
}
//--------------------------------------------------------------
po.updateOrganisation = function ($item, item)
{
//sax.debug('po.updateOrganisation', $item, item);
$('.OrganisationId', $frm.orgId).val(item.id);
sax.ajax.profileOrganisation = sax.ajax.profileOrganisation || { url: sax.url.base + 'Account/Ajax/GetProfileOrganisation', formId: 'frmProfileOrganisationId', callbackFn: po.doUpdateOrganisation };
sax.doAjaxRequest(sax.ajax.profileOrganisation, 50);
}
po.doUpdateOrganisation = function (response)
{
//sax.debug('doUpdateOrganisation', response);
if (!response || !response.success) return;
let item = response.organisation;
if (!item) return;
$('.OrganisationId', $frm.org).val(item.id);
$('.OrganisationName', $frm.org).val(item.name);
$('.OrganisationCategory', $frm.org).val(item.categoryCode);
$('.OrganisationType', $frm.org).val(item.typeCode);
$('.OrganisationSportId', $frm.org).val(item.sportId);
$('.OrganisationSportCaption', $frm.org).val(item.sportName);
$('.OrganisationRegionIdCountry', $frm.org).val(item.regionIdCountry);
$('.OrganisationRegionCaptionCountry', $frm.org).val(item.regionNameCountry);
let address = item.address || {};
$('input.OrganisationAddressId', $frm.org).val(address.id);
$('input.OrganisationAddressLine1', $frm.org).val(address.line1);
$('input.OrganisationAddressLine2', $frm.org).val(address.line2);
$('input.OrganisationAddressLine3', $frm.org).val(address.line3);
$('input.OrganisationAddressTown', $frm.org).val(address.town);
$('input.OrganisationAddressProvince', $frm.org).val(address.province);
$('input.OrganisationAddressCountry', $frm.org).val(address.country);
$('input.OrganisationAddressPostalCode', $frm.org).val(address.postalCode);
sax.openDialog($dlg.org, 600, 600);
}
po.storeOrganisation = function ()
{
let fn = function (response)
{
//sax.debug('handleStoreOrganisationResponse', response);
if (!response) return;
sax.refreshControlValues(response.controlValues, $frm.org);
if (!response.success) return;
$dlg.org.dialog('close');
po.cleanUp();
}
or.ajax.storeOrg = or.ajax.storeOrg || { url: sax.url.base + 'Account/Ajax/StoreProfileOrganisation', formId: 'frmProfileOrganisation', callbackFn: fn };
sax.doAjaxRequest(or.ajax.storeOrg, 50);
}
po.cleanUp = function ()
{
}
//--------------------------------------------------------------
po.selectOrgSport = function ()
{
sax.mdl.selectSport.fn.selectSport({ caption: sax.dlg.title.selectSport, sportId: $('.OrganisationSportId', $frm.org).val(), fnCallback: po.onSelectOrgSport })
}
po.onSelectOrgSport = function (sport)
{
sax.clearControlError($('.OrganisationSportId', $frm.org).val(sport.id));
$('.OrganisationSportCaption', $frm.org).val(sport ? sport.name : '');
}
//--------------------------------------------------------------
po.selectOrgRegionCountry = function ()
{
sax.mdl.selectRegion.fn.selectRegion({ caption: sax.dlg.title.selectRegion, regionId: $('.OrganisationRegionIdCountry', $frm.org).val(), typesInc: [30], fnCallback: po.onSelectOrgRegionCountry })
}
po.onSelectOrgRegionCountry = function (region)
{
sax.clearControlError($('.OrganisationRegionIdCountry', $frm.org).val(region.id));
$('.OrganisationRegionCaptionCountry', $frm.org).val(region ? region.name : '');
}
//--------------------------------------------------------------
$(function ()
{
$pnl.section = $('.sax-panel-section.ProfileOrganisations');
$frm.orgId = $('#frmProfileOrganisationId', $pnl.section);
var opt = sax.dlgOpts();
opt.buttons[sax.dlg.btn.ok] = function () { po.storeOrganisation(); };
opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); };
$dlg.org = $('#dlgProfileOrganisation').dialog(opt);
$frm.org = $('#frmProfileOrganisation', $dlg.org);
$frm.org.on('dblclick', 'input.OrganisationSportCaption', po.selectOrgSport).on('click', 'button.SelectSport', po.selectOrgSport);
$frm.org.on('dblclick', 'input.OrganisationRegionCaptionCountry', po.selectOrgRegionCountry).on('click', 'button.SelectRegionCountry', po.selectOrgRegionCountry);
});
//--------------------------------------------------------------
+3 -1
View File
@@ -18,7 +18,7 @@ namespace Saxonite.Net.Standard.Base.App
//-------------------------------------------------------------------
public static class Version
{
private static String version { get; } = "1.2.0.0";
private static String version { get; } = "1.2.1.1";
// Retrieve version.
public static String GetFullVersion () { return version; }
public static String GetAppVersion ()
@@ -40,6 +40,8 @@ namespace Saxonite.Net.Standard.Base.App
//-------------------------------------------------------------------
// Version history.
//-------------------------------------------------------------------
// 1.2.1 20-Nov-2021 Online Profile.
// - Online Organisation edit.
// 1.2.0 1-Nov-2021 'Admin' Organisation role
// - 'Admin' Organisation role
// - Azure App Service configuration.
+12
View File
@@ -30,6 +30,7 @@ namespace Saxonite.Net.Standard.Base.App
OrganisationCategory,
OrganisationRole,
AddressType,
EventType,
OpportunityType,
ActivityReaction,
};
@@ -250,6 +251,17 @@ namespace Saxonite.Net.Standard.Base.App
Delivery = 60,
}
//-------------------------------------------------------------------
/// <summary>Event Type</summary>
public enum EventType
{
Unknown = 0,
/* Do not change the values or codes - tied to database. */
Playing,
Training,
Social,
}
//-------------------------------------------------------------------
/// <summary>Opportunity Type</summary>
public enum OpportunityType
+122 -82
View File
@@ -6,7 +6,7 @@ using System.Collections.Generic;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 26-Aug-2021 12:36:27
// Code generated by Sarand Database Utilities Sat 20-Nov-2021 14:44:06
//---------------------------------------------------------------------------
namespace Saxonite.Base.App
{
@@ -23,6 +23,7 @@ namespace Saxonite.Base.App
ItemImage,
ItemSport,
Organisation,
OrganisationEvent,
OrganisationOpportunity,
Region,
Sport,
@@ -158,6 +159,25 @@ namespace Saxonite.Base.App
Organisation_UpdateOn,
Organisation_UpdateBy,
Organisation_UpdateHost,
OrganisationEvent_Id,
OrganisationEvent_OrganisationId,
OrganisationEvent_SportIdPrimary,
OrganisationEvent_RegionIdCountry,
OrganisationEvent_EventAt,
OrganisationEvent_EventTypeCode,
OrganisationEvent_About,
OrganisationEvent_EventData,
OrganisationEvent_PublishedAt,
OrganisationEvent_ExpiresAt,
OrganisationEvent_Notes,
OrganisationEvent_Flags,
OrganisationEvent_Status,
OrganisationEvent_CreateOn,
OrganisationEvent_CreateBy,
OrganisationEvent_CreateHost,
OrganisationEvent_UpdateOn,
OrganisationEvent_UpdateBy,
OrganisationEvent_UpdateHost,
OrganisationOpportunity_Id,
OrganisationOpportunity_OrganisationId,
OrganisationOpportunity_SportIdPrimary,
@@ -335,8 +355,8 @@ namespace Saxonite.Base.App
//-------------------------------------------------------------------
// Data members.
private static readonly int tableCount = 16;
private static readonly int columnCount = 291;
private static readonly int tableCount = 17;
private static readonly int columnCount = 310;
private static ulong maxTextLen = 0;
//-------------------------------------------------------------------
@@ -488,6 +508,7 @@ namespace Saxonite.Base.App
"ItemImage",
"ItemSport",
"Organisation",
"OrganisationEvent",
"OrganisationOpportunity",
"Region",
"Sport",
@@ -645,11 +666,11 @@ namespace Saxonite.Base.App
new ColumnDfn(7,"Id",4,4,true,10),
new ColumnDfn(7,"OrganisationId",4,4,false,10),
new ColumnDfn(7,"SportIdPrimary",4,4,false,10),
new ColumnDfn(7,"RegionIdPrimary",4,4,false,10),
new ColumnDfn(7,"OpportunityTypeCode",0,12,false,3),
new ColumnDfn(7,"Position",0,-9,false,200),
new ColumnDfn(7,"Outline",0,-9,false,2000),
new ColumnDfn(7,"OpportunityData",0,-9,false,0),
new ColumnDfn(7,"RegionIdCountry",4,4,false,10),
new ColumnDfn(7,"EventAt",9,93,false,16),
new ColumnDfn(7,"EventTypeCode",0,12,false,3),
new ColumnDfn(7,"About",0,-9,false,2000),
new ColumnDfn(7,"EventData",0,-9,false,0),
new ColumnDfn(7,"PublishedAt",9,93,false,16),
new ColumnDfn(7,"ExpiresAt",9,93,false,16),
new ColumnDfn(7,"Notes",0,-9,false,2000),
@@ -662,12 +683,15 @@ namespace Saxonite.Base.App
new ColumnDfn(7,"UpdateBy",4,4,false,10),
new ColumnDfn(7,"UpdateHost",0,12,false,100),
new ColumnDfn(8,"Id",4,4,true,10),
new ColumnDfn(8,"RegionType",3,5,false,5),
new ColumnDfn(8,"CountryIso2Code",0,12,false,2),
new ColumnDfn(8,"Name",0,-9,false,100),
new ColumnDfn(8,"Latitude",8,3,false,9),
new ColumnDfn(8,"Longitude",8,3,false,9),
new ColumnDfn(8,"RegionIdParent",4,4,false,10),
new ColumnDfn(8,"OrganisationId",4,4,false,10),
new ColumnDfn(8,"SportIdPrimary",4,4,false,10),
new ColumnDfn(8,"RegionIdPrimary",4,4,false,10),
new ColumnDfn(8,"OpportunityTypeCode",0,12,false,3),
new ColumnDfn(8,"Position",0,-9,false,200),
new ColumnDfn(8,"Outline",0,-9,false,2000),
new ColumnDfn(8,"OpportunityData",0,-9,false,0),
new ColumnDfn(8,"PublishedAt",9,93,false,16),
new ColumnDfn(8,"ExpiresAt",9,93,false,16),
new ColumnDfn(8,"Notes",0,-9,false,2000),
new ColumnDfn(8,"Flags",3,5,false,5),
new ColumnDfn(8,"Status",0,12,false,3),
@@ -678,8 +702,12 @@ namespace Saxonite.Base.App
new ColumnDfn(8,"UpdateBy",4,4,false,10),
new ColumnDfn(8,"UpdateHost",0,12,false,100),
new ColumnDfn(9,"Id",4,4,true,10),
new ColumnDfn(9,"RegionType",3,5,false,5),
new ColumnDfn(9,"CountryIso2Code",0,12,false,2),
new ColumnDfn(9,"Name",0,-9,false,100),
new ColumnDfn(9,"SpecialityLabel",3,5,false,5),
new ColumnDfn(9,"Latitude",8,3,false,9),
new ColumnDfn(9,"Longitude",8,3,false,9),
new ColumnDfn(9,"RegionIdParent",4,4,false,10),
new ColumnDfn(9,"Notes",0,-9,false,2000),
new ColumnDfn(9,"Flags",3,5,false,5),
new ColumnDfn(9,"Status",0,12,false,3),
@@ -690,28 +718,8 @@ namespace Saxonite.Base.App
new ColumnDfn(9,"UpdateBy",4,4,false,10),
new ColumnDfn(9,"UpdateHost",0,12,false,100),
new ColumnDfn(10,"Id",4,4,true,10),
new ColumnDfn(10,"EmailAddress",0,-9,false,200),
new ColumnDfn(10,"Title",0,-9,false,20),
new ColumnDfn(10,"FirstName",0,-9,false,100),
new ColumnDfn(10,"Initials",0,-9,false,10),
new ColumnDfn(10,"LastName",0,-9,false,100),
new ColumnDfn(10,"About",0,-9,false,2000),
new ColumnDfn(10,"PhoneMain",0,-9,false,50),
new ColumnDfn(10,"PhoneMobile",0,-9,false,50),
new ColumnDfn(10,"PhoneAlt",0,-9,false,50),
new ColumnDfn(10,"Gender",2,-6,false,3),
new ColumnDfn(10,"DateOfBirthDay",2,-6,false,3),
new ColumnDfn(10,"DateOfBirthMonth",2,-6,false,3),
new ColumnDfn(10,"DateOfBirthYear",3,5,false,5),
new ColumnDfn(10,"RegionIdCountry",4,4,false,10),
new ColumnDfn(10,"RegionIdProvince",4,4,false,10),
new ColumnDfn(10,"PasswordToken",0,12,false,32),
new ColumnDfn(10,"PasswordHashed",0,-9,false,100),
new ColumnDfn(10,"PasswordHistory",0,-9,false,0),
new ColumnDfn(10,"PasswordChangedAt",9,93,false,16),
new ColumnDfn(10,"LastLoginAt",9,93,false,16),
new ColumnDfn(10,"LastInvalidLoginAt",9,93,false,16),
new ColumnDfn(10,"InvalidLoginCount",3,5,false,5),
new ColumnDfn(10,"Name",0,-9,false,100),
new ColumnDfn(10,"SpecialityLabel",3,5,false,5),
new ColumnDfn(10,"Notes",0,-9,false,2000),
new ColumnDfn(10,"Flags",3,5,false,5),
new ColumnDfn(10,"Status",0,12,false,3),
@@ -721,19 +729,29 @@ namespace Saxonite.Base.App
new ColumnDfn(10,"UpdateOn",9,93,false,23),
new ColumnDfn(10,"UpdateBy",4,4,false,10),
new ColumnDfn(10,"UpdateHost",0,12,false,100),
new ColumnDfn(11,"Id",5,-5,true,19),
new ColumnDfn(11,"UserAccountId",4,4,false,10),
new ColumnDfn(11,"ItemType",3,5,false,5),
new ColumnDfn(11,"ItemId",5,-5,false,19),
new ColumnDfn(11,"CurrentlyListed",1,-7,false,1),
new ColumnDfn(11,"ListedAtFirst",9,93,false,16),
new ColumnDfn(11,"ListedAtLast",9,93,false,16),
new ColumnDfn(11,"ViewedAtFirst",9,93,false,16),
new ColumnDfn(11,"ViewedAtLast",9,93,false,16),
new ColumnDfn(11,"Reaction",3,5,false,5),
new ColumnDfn(11,"ReactedAtFirst",9,93,false,16),
new ColumnDfn(11,"ReactedAtLast",9,93,false,16),
new ColumnDfn(11,"UserActivityData",0,-9,false,0),
new ColumnDfn(11,"Id",4,4,true,10),
new ColumnDfn(11,"EmailAddress",0,-9,false,200),
new ColumnDfn(11,"Title",0,-9,false,20),
new ColumnDfn(11,"FirstName",0,-9,false,100),
new ColumnDfn(11,"Initials",0,-9,false,10),
new ColumnDfn(11,"LastName",0,-9,false,100),
new ColumnDfn(11,"About",0,-9,false,2000),
new ColumnDfn(11,"PhoneMain",0,-9,false,50),
new ColumnDfn(11,"PhoneMobile",0,-9,false,50),
new ColumnDfn(11,"PhoneAlt",0,-9,false,50),
new ColumnDfn(11,"Gender",2,-6,false,3),
new ColumnDfn(11,"DateOfBirthDay",2,-6,false,3),
new ColumnDfn(11,"DateOfBirthMonth",2,-6,false,3),
new ColumnDfn(11,"DateOfBirthYear",3,5,false,5),
new ColumnDfn(11,"RegionIdCountry",4,4,false,10),
new ColumnDfn(11,"RegionIdProvince",4,4,false,10),
new ColumnDfn(11,"PasswordToken",0,12,false,32),
new ColumnDfn(11,"PasswordHashed",0,-9,false,100),
new ColumnDfn(11,"PasswordHistory",0,-9,false,0),
new ColumnDfn(11,"PasswordChangedAt",9,93,false,16),
new ColumnDfn(11,"LastLoginAt",9,93,false,16),
new ColumnDfn(11,"LastInvalidLoginAt",9,93,false,16),
new ColumnDfn(11,"InvalidLoginCount",3,5,false,5),
new ColumnDfn(11,"Notes",0,-9,false,2000),
new ColumnDfn(11,"Flags",3,5,false,5),
new ColumnDfn(11,"Status",0,12,false,3),
@@ -745,10 +763,17 @@ namespace Saxonite.Base.App
new ColumnDfn(11,"UpdateHost",0,12,false,100),
new ColumnDfn(12,"Id",5,-5,true,19),
new ColumnDfn(12,"UserAccountId",4,4,false,10),
new ColumnDfn(12,"OrganisationId",4,4,false,10),
new ColumnDfn(12,"OrganisationRoleCodes",0,12,false,256),
new ColumnDfn(12,"OrganisationRoleCount",2,-6,false,3),
new ColumnDfn(12,"AdminComment",0,-9,false,2000),
new ColumnDfn(12,"ItemType",3,5,false,5),
new ColumnDfn(12,"ItemId",5,-5,false,19),
new ColumnDfn(12,"CurrentlyListed",1,-7,false,1),
new ColumnDfn(12,"ListedAtFirst",9,93,false,16),
new ColumnDfn(12,"ListedAtLast",9,93,false,16),
new ColumnDfn(12,"ViewedAtFirst",9,93,false,16),
new ColumnDfn(12,"ViewedAtLast",9,93,false,16),
new ColumnDfn(12,"Reaction",3,5,false,5),
new ColumnDfn(12,"ReactedAtFirst",9,93,false,16),
new ColumnDfn(12,"ReactedAtLast",9,93,false,16),
new ColumnDfn(12,"UserActivityData",0,-9,false,0),
new ColumnDfn(12,"Notes",0,-9,false,2000),
new ColumnDfn(12,"Flags",3,5,false,5),
new ColumnDfn(12,"Status",0,12,false,3),
@@ -760,7 +785,10 @@ namespace Saxonite.Base.App
new ColumnDfn(12,"UpdateHost",0,12,false,100),
new ColumnDfn(13,"Id",5,-5,true,19),
new ColumnDfn(13,"UserAccountId",4,4,false,10),
new ColumnDfn(13,"UserRoleCode",0,12,false,16),
new ColumnDfn(13,"OrganisationId",4,4,false,10),
new ColumnDfn(13,"OrganisationRoleCodes",0,12,false,256),
new ColumnDfn(13,"OrganisationRoleCount",2,-6,false,3),
new ColumnDfn(13,"AdminComment",0,-9,false,2000),
new ColumnDfn(13,"Notes",0,-9,false,2000),
new ColumnDfn(13,"Flags",3,5,false,5),
new ColumnDfn(13,"Status",0,12,false,3),
@@ -770,42 +798,31 @@ namespace Saxonite.Base.App
new ColumnDfn(13,"UpdateOn",9,93,false,23),
new ColumnDfn(13,"UpdateBy",4,4,false,10),
new ColumnDfn(13,"UpdateHost",0,12,false,100),
new ColumnDfn(14,"Id",5,-5,true,19),
new ColumnDfn(14,"UserAccountId",4,4,false,10),
new ColumnDfn(14,"ActivityIndexIds",0,-9,false,0),
new ColumnDfn(14,"UserSessionData",0,-9,false,0),
new ColumnDfn(14,"UserRoleCode",0,12,false,16),
new ColumnDfn(14,"Notes",0,-9,false,2000),
new ColumnDfn(14,"Flags",3,5,false,5),
new ColumnDfn(14,"Status",0,12,false,3),
new ColumnDfn(14,"CreateOn",9,93,false,23),
new ColumnDfn(14,"CreateBy",4,4,false,10),
new ColumnDfn(14,"CreateHost",0,12,false,100),
new ColumnDfn(14,"UpdateOn",9,93,false,23),
new ColumnDfn(15,"Id",5,-5,true,19),
new ColumnDfn(14,"UpdateBy",4,4,false,10),
new ColumnDfn(14,"UpdateHost",0,12,false,100),
new ColumnDfn(15,"UserAccountId",4,4,false,10),
new ColumnDfn(15,"SportId",4,4,false,10),
new ColumnDfn(15,"About",0,-9,false,2000),
new ColumnDfn(15,"Participation",3,5,false,5),
new ColumnDfn(15,"Officiating",3,5,false,5),
new ColumnDfn(15,"UserSportData",0,-9,false,0),
new ColumnDfn(15,"Notes",0,-9,false,2000),
new ColumnDfn(15,"ActivityIndexIds",0,-9,false,0),
new ColumnDfn(15,"UserSessionData",0,-9,false,0),
new ColumnDfn(15,"Flags",3,5,false,5),
new ColumnDfn(15,"Status",0,12,false,3),
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,"UserSportId",5,-5,false,19),
new ColumnDfn(16,"PeriodFrom",9,93,false,16),
new ColumnDfn(16,"PeriodTo",9,93,false,16),
new ColumnDfn(16,"OrganisationId",4,4,false,10),
new ColumnDfn(16,"OrganisationName",0,-9,false,200),
new ColumnDfn(16,"Summary",0,-9,false,2000),
new ColumnDfn(16,"Team",0,-9,false,64),
new ColumnDfn(16,"League",0,-9,false,64),
new ColumnDfn(16,"Speciality",0,-9,false,64),
new ColumnDfn(16,"SpecialitiesOther",0,-9,false,1000),
new ColumnDfn(16,"RegionIdNation",4,4,false,10),
new ColumnDfn(16,"RegionIdProvince",4,4,false,10),
new ColumnDfn(16,"UserSportExperienceData",0,-9,false,0),
new ColumnDfn(16,"UserAccountId",4,4,false,10),
new ColumnDfn(16,"SportId",4,4,false,10),
new ColumnDfn(16,"About",0,-9,false,2000),
new ColumnDfn(16,"Participation",3,5,false,5),
new ColumnDfn(16,"Officiating",3,5,false,5),
new ColumnDfn(16,"UserSportData",0,-9,false,0),
new ColumnDfn(16,"Notes",0,-9,false,2000),
new ColumnDfn(16,"Flags",3,5,false,5),
new ColumnDfn(16,"Status",0,12,false,3),
@@ -815,6 +832,29 @@ namespace Saxonite.Base.App
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,"Id",5,-5,true,19),
new ColumnDfn(17,"UserSportId",5,-5,false,19),
new ColumnDfn(17,"PeriodFrom",9,93,false,16),
new ColumnDfn(17,"PeriodTo",9,93,false,16),
new ColumnDfn(17,"OrganisationId",4,4,false,10),
new ColumnDfn(17,"OrganisationName",0,-9,false,200),
new ColumnDfn(17,"Summary",0,-9,false,2000),
new ColumnDfn(17,"Team",0,-9,false,64),
new ColumnDfn(17,"League",0,-9,false,64),
new ColumnDfn(17,"Speciality",0,-9,false,64),
new ColumnDfn(17,"SpecialitiesOther",0,-9,false,1000),
new ColumnDfn(17,"RegionIdNation",4,4,false,10),
new ColumnDfn(17,"RegionIdProvince",4,4,false,10),
new ColumnDfn(17,"UserSportExperienceData",0,-9,false,0),
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),
};
//-------------------------------------------------------------------
@@ -99,6 +99,7 @@ namespace Saxonite.Net.Standard.Base.App
public List<TypeCodeDesc> OrganisationCategoryCodes { get { return GetCodesOfType(Sax.CodeType.OrganisationCategory); } }
public List<TypeCodeDesc> OrganisationRoleCodes { get { return GetCodesOfType(Sax.CodeType.OrganisationRole); } }
public List<TypeCodeDesc> AddressTypeCodes { get { return GetCodesOfType(Sax.CodeType.AddressType); } }
public List<TypeCodeDesc> EventTypeCodes { get { return GetCodesOfType(Sax.CodeType.EventType); } }
public List<TypeCodeDesc> OpportunityTypeCodes { get { return GetCodesOfType(Sax.CodeType.OpportunityType); } }
public List<TypeCodeDesc> ActivityReactionCodes { get { return GetCodesOfType(Sax.CodeType.ActivityReaction); } }
public List<TypeCodeDesc> GetCodesOfType(Sax.CodeType codeType)
@@ -28,6 +28,7 @@ namespace Saxonite.Net.Standard.Base.App
private static readonly List<TypeCodeDesc> organisationCategoryCodes = new List<TypeCodeDesc>();
private static readonly List<TypeCodeDesc> organisationRoleCodes = new List<TypeCodeDesc>();
private static readonly List<TypeCodeDesc> addressTypeCodes = new List<TypeCodeDesc>();
private static readonly List<TypeCodeDesc> eventTypeCodes = new List<TypeCodeDesc>();
private static readonly List<TypeCodeDesc> opportunityTypeCodes = new List<TypeCodeDesc>();
private static readonly List<TypeCodeDesc> activityReactionCodes = new List<TypeCodeDesc>();
@@ -150,6 +151,12 @@ namespace Saxonite.Net.Standard.Base.App
organisationRoleCodes.Add(Sax.OrganisationRole.OpportunityAdmin, "OPA", "Opportunities");
organisationRoleCodes.Add(Sax.OrganisationRole.ArticleAdmin, "ARA", "Articles");
//---------------------------------------------------------------
// Event types.
eventTypeCodes.Add(Sax.EventType.Playing, "PLG", "Playing");
eventTypeCodes.Add(Sax.EventType.Playing, "TRN", "Training");
eventTypeCodes.Add(Sax.EventType.Playing, "SCL", "Social");
//---------------------------------------------------------------
// Opportunity types.
opportunityTypeCodes.Add(Sax.OpportunityType.Playing, "PLG", "Playing");
@@ -64,6 +64,8 @@ namespace Saxonite.Net.Standard.Base.App
return new List<TypeCodeDesc>(organisationRoleCodes);
case Sax.CodeType.AddressType:
return new List<TypeCodeDesc>(addressTypeCodes);
case Sax.CodeType.EventType:
return new List<TypeCodeDesc>(eventTypeCodes);
case Sax.CodeType.OpportunityType:
return new List<TypeCodeDesc>(opportunityTypeCodes);
case Sax.CodeType.ActivityReaction:
@@ -303,6 +303,8 @@ namespace Saxonite.Net.Standard.Base.Bus
{
return new ItemId((short)Sax.DataItemType.ItemAddress, Id);
}
// Address types.
public static Sax.AddressType DefaultOrganisationAddressType { get { return Sax.AddressType.Office; } }
//-------------------------------------------------------------------
// Properties.
@@ -0,0 +1,312 @@
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.Text;
namespace Saxonite.Net.Standard.Base.Bus
{
//=======================================================================
// Organisation Event.
//=======================================================================
public abstract class SaxOrganisationEvent : SacsHierarchyItem
{
//-------------------------------------------------------------------
// Columns.
public enum Column
{
Pos,
Id,
// Organisation.
OrganisationId,
Organisation_Name,
// Sport.
SportIdPrimary,
Sport_Name,
// Region.
RegionIdCountry,
Region_Name,
// Event.
EventAt_Date,
EventAt_DateTime,
EventTypeCode,
EventType_Desc,
About,
PublishedAt_Date,
PublishedAt_DateTime,
ExpiresAt_Date,
ExpiresAt_DateTime,
// Associated data.
// Common.
Notes,
Flags,
Status,
Status_Desc,
Status_Ind,
CreateOn_Date,
UpdateOn_Date,
}
//-------------------------------------------------------------------
/// <summary>Properties other than common.</summary>
public class DataProperties
{
public SysId OrganisationId { get; set; }
public SysId SportIdPrimary { get; set; }
public SysId RegionIdCountry { get; set; }
public DateTime EventAt { get; set; }
public Sax.EventType EventType { get; set; }
public String About { get; set; } = String.Empty;
public String EventData { get; set; } = String.Empty;
public DateTime PublishedAt { get; set; }
public DateTime ExpiresAt { get; set; }
}
//-------------------------------------------------------------------
// Data.
public new class Data : SacsHierarchyItem.Data
{
// Data members.
private readonly DataProperties data = new DataProperties();
// Construction.
public Data()
{
Status = DefaultStatus;
}
// Properties.
public SysId OrganisationId
{
get { return data.OrganisationId; }
set { CheckChanged(data.OrganisationId, value); data.OrganisationId = value; }
}
public SysId SportIdPrimary
{
get { return data.SportIdPrimary; }
set { CheckChanged(data.SportIdPrimary, value); data.SportIdPrimary = value; }
}
public SysId RegionIdCountry
{
get { return data.RegionIdCountry; }
set { CheckChanged(data.RegionIdCountry, value); data.RegionIdCountry = value; }
}
public DateTime EventAt
{
get { return data.EventAt; }
set { CheckChanged(data.EventAt, value); data.EventAt = value; }
}
public Sax.EventType EventType
{
get { return data.EventType; }
set { CheckChanged((int)data.EventType, (int)value); data.EventType = value; }
}
public String About
{
get { return data.About; }
set { CheckChanged(data.About, value); data.About = value; }
}
public String EventData
{
get { return data.EventData; }
set { CheckChanged(data.EventData, value); data.EventData = value; }
}
public DateTime PublishedAt
{
get { return data.PublishedAt; }
set { CheckChanged(data.PublishedAt, value); data.PublishedAt = value; }
}
public DateTime ExpiresAt
{
get { return data.ExpiresAt; }
set { CheckChanged(data.ExpiresAt, value); data.ExpiresAt = value; }
}
// Population.
internal void PopulateFrom(Data data)
{
OrganisationId = data.OrganisationId;
SportIdPrimary = data.SportIdPrimary;
RegionIdCountry = data.RegionIdCountry;
EventAt = data.EventAt;
EventType = data.EventType;
About = data.About;
EventData = data.EventData;
PublishedAt = data.PublishedAt;
ExpiresAt = data.ExpiresAt;
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 OrganisationId { get; set; } = ValidValue.Valid;
public ValidValue SportIdPrimary { get; set; } = ValidValue.Valid;
public ValidValue RegionIdCountry { get; set; } = ValidValue.Valid;
public ValidValue EventAt { get; set; } = ValidValue.Valid;
public ValidValue EventType { get; set; } = ValidValue.Valid;
public ValidValue About { get; set; } = ValidValue.Valid;
public ValidValue EventData { get; set; } = ValidValue.Valid;
public ValidValue PublishedAt { get; set; } = ValidValue.Valid;
public ValidValue ExpiresAt { get; set; } = ValidValue.Valid;
}
//-------------------------------------------------------------------
// Data members.
private readonly Data data = new Data();
//-------------------------------------------------------------------
// Construction.
protected SaxOrganisationEvent(SysId id, SysId OrganisationId) : base(id)
{
base.SetData(data);
this.OrganisationId = OrganisationId;
Status = DefaultStatus;
}
//-------------------------------------------------------------------
// Status.
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
{
SaStatus.Active,
SaStatus.Inactive,
SaStatus.Deleted,
};
public static SaStatus DefaultStatus { get { return SaStatus.Active; } }
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
{
if (status == SaStatus.Active) return DataValue.TriStateType.Green;
if (status == SaStatus.Inactive) return DataValue.TriStateType.Red;
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
return DataValue.TriStateType.Unknown;
}
//-------------------------------------------------------------------
// Utilities.
public ItemId GetItemId()
{
return new ItemId((short)Sax.DataItemType.OrganisationEvent, Id);
}
//-------------------------------------------------------------------
// Properties.
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(OrganisationId) && SysId.ToInt(OrganisationId) != SysId.ToInt(data.OrganisationId))
throw new NotSupportedException(fn + " Organisation Id cannot be changed");
this.data.PopulateFrom(data);
}
public SysId OrganisationId
{
get { return data.OrganisationId; }
protected set { data.OrganisationId = value; }
}
public SysId SportIdPrimary
{
get { return data.SportIdPrimary; }
set { data.SportIdPrimary = value; }
}
public SysId RegionIdCountry
{
get { return data.RegionIdCountry; }
set { data.RegionIdCountry = value; }
}
public DateTime EventAt
{
get { return data.EventAt; }
set { data.EventAt = value; }
}
public Sax.EventType EventType
{
get { return data.EventType; }
set { data.EventType = value; }
}
public String About
{
get { return data.About; }
set { data.About = value; }
}
public String EventData
{
get { return data.EventData; }
set { data.EventData = value; }
}
public DateTime PublishedAt
{
get { return data.PublishedAt; }
set { data.PublishedAt = value; }
}
public DateTime ExpiresAt
{
get { return data.ExpiresAt; }
set { data.ExpiresAt = 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.
public enum StatusCat
{
Any,
ActiveOnly,
InactiveOnly,
NotDeleted,
DeletedOnly,
}
/// <summary>
/// Item list parameters.
/// </summary>
public new class Params : SacsHierarchyItem.Params
{
// List filtering.
public List<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
/// <summary>Restrict to User Account via User Organisations and Organisations.</summary>
public List<SysId> UserAccountIdsIncluded { get; } = new List<SysId>();
public List<SysId> OrganisationIdsIncluded { get; } = new List<SysId>();
public List<SysId> SportIdsIncluded { get; set; } = new List<SysId>();
public List<SysId> RegionIdsIncluded { get; } = new List<SysId>();
public DateTime EventFrom { get; set; }
public DateTime EventTo{ get; set; }
public String AboutPartial { get; set; }
/// <summary>General filter value - position, outline, sport, body etc. </summary>
public String EventFilter { get; set; }
public String NotesPartial { get; set; }
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
// Table aliases - blank if not linked.
public String Alias_Organisation { get; set; }
public String Alias_UserOrganisation { get; set; }
public String Alias_UserAccount { get; set; }
}
//-------------------------------------------------------------------
}
//=======================================================================
// Item list extension methods.
public static class SaxOrganisationEventList
{
}
//=======================================================================
}
@@ -36,6 +36,8 @@ namespace Saxonite.Net.Standard.Base.Bus
User_Status_Desc,
// Organisation.
Organisation_Name,
Organisation_Category,
Organisation_Type,
Organisation_RegionId,
Organisation_Region_Name,
Organisation_SportId,
@@ -0,0 +1,246 @@
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 Sarand.Net.Standard.Base.Utils;
using Saxonite.Base.App;
using Saxonite.Net.Standard.Base.Bus;
using System;
using System.Collections.Generic;
using System.Text;
namespace Saxonite.Net.Standard.Base.Mgr
{
//=======================================================================
partial class SaxActivityMgr
{
//*******************************************************************
// Activity Mgr - Organisation Event
//*******************************************************************
// Utilities.
//-------------------------------------------------------------------
// Create item.
public abstract SaxOrganisationEvent CreateOrganisationEvent(SysId organisationId);
//-------------------------------------------------------------------
// Item exists.
public bool OrganisationEventExistsById(SysId id)
{
ClearErrorState();
if (!SysId.IsValid(id)) return false;
SaxOrganisationEvent.Params prmOrganisationEvent = new SaxOrganisationEvent.Params();
prmOrganisationEvent.IdsIncluded.Add(id);
prmOrganisationEvent.StatusCat = SaxOrganisationEvent.StatusCat.Any;
return GetOrganisationEventCount(prmOrganisationEvent) == 1;
}
//-------------------------------------------------------------------
// Retrieve individual items.
public abstract SaxOrganisationEvent GetOrganisationEvent(SaxOrganisationEvent.Params prmOrganisationEvent);
public SaxOrganisationEvent GetOrganisationEventById(SysId id)
{
ClearErrorState();
if (!SysId.IsValid(id)) return null;
SaxOrganisationEvent.Params prmOrganisationEvent = new SaxOrganisationEvent.Params();
prmOrganisationEvent.IdsIncluded.Add(id);
prmOrganisationEvent.StatusCat = SaxOrganisationEvent.StatusCat.Any;
return GetOrganisationEvent(prmOrganisationEvent);
}
//-------------------------------------------------------------------
// Validate item data.
public bool IsValidOrganisationEvent(SaxOrganisationEvent organisationEvent)
{
ClearErrorState();
if (organisationEvent == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
return IsValidOrganisationEventData(organisationEvent.GetData(), new SaxOrganisationEvent.ErrField());
}
public virtual bool IsValidOrganisationEventData(SaxOrganisationEvent.Data data, SaxOrganisationEvent.ErrField errField)
{
ClearErrorState();
// Organisation.
if (errField.OrganisationId != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.OrganisationId))
{
errField.OrganisationId = SacsHierarchyItem.ValidValue.Invalid;
return SetErrorState("Organisation must be specified");
}
// Primary Sport.
if (errField.SportIdPrimary != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.SportIdPrimary))
{
errField.SportIdPrimary = SacsHierarchyItem.ValidValue.Invalid;
return SetErrorState("Sport must be specified");
}
// Country Region.
if (errField.RegionIdCountry != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.RegionIdCountry))
{
errField.RegionIdCountry = SacsHierarchyItem.ValidValue.Invalid;
return SetErrorState("Country Region must be specified");
}
// Event date and time.
if (errField.EventAt != SacsHierarchyItem.ValidValue.Ignore && !DateUtil.IsValid(data.EventAt))
{
errField.EventType = SacsHierarchyItem.ValidValue.Invalid;
return SetErrorState("Event data and time must be specified.");
}
// Event type.
if (errField.EventType != SacsHierarchyItem.ValidValue.Ignore && data.EventType <= 0)
{
errField.EventType = SacsHierarchyItem.ValidValue.Invalid;
return SetErrorState("Event type must be specified.");
}
// About.
if (errField.About != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.About, "outline", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_About), true))
{
errField.About = SacsHierarchyItem.ValidValue.Invalid;
return false;
}
// Common properties.
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_Notes)))
{
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
return false;
}
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
{
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_Status), true, true))
{
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
return false;
}
if (!SaxOrganisationEvent.ValidStatuses.Contains(data.Status))
{
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
return SetErrorState(ErrorMessage.InvalidStatus);
}
}
//---------------------------------------------------------------
// Associated data - ignore for deleted items.
if (!data.IsStatusDeleted)
{
// Organisation.
if (errField.OrganisationId != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.OrganisationId))
{
SaxOrganisation.Params prmOrganisation = new SaxOrganisation.Params();
prmOrganisation.IdsIncluded.Add(data.OrganisationId);
prmOrganisation.StatusCat = SaxOrganisation.StatusCat.NotDeleted;
if (AccountMgr.GetOrganisationCount(prmOrganisation) < 1)
{
errField.OrganisationId = SacsHierarchyItem.ValidValue.Invalid;
return SetErrorState("Invalid organisation specified");
}
}
// Primary Sport.
if (errField.SportIdPrimary != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.SportIdPrimary))
{
SaxSport.Params prmSport = new SaxSport.Params();
prmSport.IdsIncluded.Add(data.SportIdPrimary);
prmSport.StatusCat = SaxSport.StatusCat.NotDeleted;
if (ReferenceMgr.GetSportCount(prmSport) < 1)
{
errField.SportIdPrimary = SacsHierarchyItem.ValidValue.Invalid;
return SetErrorState("Invalid sport specified");
}
}
// Country Region.
if (errField.RegionIdCountry != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.RegionIdCountry))
{
SaxRegion.Params prmRegion = new SaxRegion.Params();
prmRegion.IdsIncluded.Add(data.RegionIdCountry);
prmRegion.StatusCat = SaxRegion.StatusCat.NotDeleted;
if (ReferenceMgr.GetRegionCount(prmRegion) < 1)
{
errField.RegionIdCountry = SacsHierarchyItem.ValidValue.Invalid;
return SetErrorState("Invalid region specified");
}
}
}
//---------------------------------------------------------------
return true;
}
//-------------------------------------------------------------------
// OrganisationEvent database interface.
public abstract bool InsertOrganisationEvent(SaxOrganisationEvent organisationEvent, DbUpdateInfo dbUpdateInfo);
public abstract bool UpdateOrganisationEvent(SaxOrganisationEvent organisationEvent, DbUpdateInfo dbUpdateInfo);
public virtual bool OrganisationEventCanBeDeleted(SaxOrganisationEvent organisationEvent)
{
ClearErrorState();
return true;
}
public abstract bool DeleteOrganisationEvent(SaxOrganisationEvent organisationEvent, DbUpdateInfo dbUpdateInfo);
//-------------------------------------------------------------------
// OrganisationEvent list:
public abstract ColumnDfn GetOrganisationEventColumnDfn(SaxOrganisationEvent.Column columnId, String caption = "", int width = 0);
public abstract List<String> GetOrganisationEventQueryFilter(SaxOrganisationEvent.Params prmOrganisationEvent);
public abstract long GetOrganisationEventCount(SaxOrganisationEvent.Params prmOrganisationEvent);
public abstract List<SaxOrganisationEvent> GetOrganisationEventList(SaxOrganisationEvent.Params prmOrganisationEvent);
public abstract DbResultSet ExecuteOrganisationEventQuery(List<ColumnDfn> columns, SaxOrganisationEvent.Params prmOrganisationEvent);
//-------------------------------------------------------------------
/// <summary>
/// Extract and format result set data value where specific handling is required.
/// <para>Where response is an invalid data value, format value using column.FormatValue(values).</para>
/// </summary>
public virtual DataValue GetOrganisationEventDataValue(ColumnDfn column, NamedValue.Map values)
{
DataValue value = new DataValue();
switch ((SaxOrganisationEvent.Column)column.Id)
{
//-----------------------------------------------------------
// Event type desc.
case SaxOrganisationEvent.Column.EventType_Desc:
{
String code = values.GetValue(column.DataName).ToString();
value = new DataValue(EventTypeCodes.GetDescForCode(code, code));
}
break;
//-----------------------------------------------------------
// Summary - limit to 200 chars.
case SaxOrganisationEvent.Column.About:
{
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
}
break;
//-----------------------------------------------------------
// Notes - limit to 200 chars.
case SaxOrganisationEvent.Column.Notes:
{
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
}
break;
//-----------------------------------------------------------
// Status.
case SaxOrganisationEvent.Column.Status_Desc:
case SaxOrganisationEvent.Column.Status_Ind:
{
String statusCode = values.GetValue(column.DataName).ToString();
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
if (column.Id == (int)SaxOrganisationEvent.Column.Status_Desc)
value = new DataValue(SacsSystem.GetStatusDesc(status));
else if (column.Id == (int)SaxOrganisationEvent.Column.Status_Ind)
value = new DataValue(SaxOrganisationEvent.GetStatusTriState(status));
}
break;
//-----------------------------------------------------------
}
return value;
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -82,7 +82,7 @@ namespace Saxonite.Net.Standard.Base.Mgr
// Opportunity type.
if (errField.OpportunityType != SacsHierarchyItem.ValidValue.Ignore && data.OpportunityType <= 0)
{
errField.Position = SacsHierarchyItem.ValidValue.Invalid;
errField.OpportunityType = SacsHierarchyItem.ValidValue.Invalid;
return SetErrorState("Opportunity type must be specified.");
}
// Position.
@@ -76,6 +76,7 @@ namespace Saxonite.Net.Standard.Base.Mgr
public List<TypeCodeDesc> OrganisationCategoryCodes { get { return Internals.OrganisationCategoryCodes; } }
public List<TypeCodeDesc> OrganisationRoleCodes { get { return Internals.OrganisationRoleCodes; } }
public List<TypeCodeDesc> AddressTypeCodes { get { return Internals.AddressTypeCodes; } }
public List<TypeCodeDesc> EventTypeCodes { get { return Internals.EventTypeCodes; } }
public List<TypeCodeDesc> OpportunityTypeCodes { get { return Internals.OpportunityTypeCodes; } }
public List<TypeCodeDesc> ActivityReactionCodes { get { return Internals.ActivityReactionCodes; } }
@@ -0,0 +1,32 @@
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Dbas;
using Saxonite.Net.Standard.Base.Bus;
using System;
using System.Collections.Generic;
using System.Text;
namespace Saxonite.Net.Standard.Dbas.Bus
{
//=======================================================================
public class SaxOrganisationEvent_Dbas : SaxOrganisationEvent
{
//-------------------------------------------------------------------
// Data members.
private ISacsDatabase database;
//-------------------------------------------------------------------
// Construction.
public SaxOrganisationEvent_Dbas(ISacsDatabase database, SysId id, SysId organisationId, UInt16 flags) :
base(id, organisationId)
{
this.database = database;
Flags = flags;
}
//-------------------------------------------------------------------
// Associated data.
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 26-Aug-2021 12:36:27
// Code generated by Sarand Database Utilities Sat 20-Nov-2021 14:44:06
//---------------------------------------------------------------------------
namespace Saxonite.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 26-Aug-2021 12:36:27
// Code generated by Sarand Database Utilities Sat 20-Nov-2021 14:44:06
//---------------------------------------------------------------------------
namespace Saxonite.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 26-Aug-2021 12:36:27
// Code generated by Sarand Database Utilities Sat 20-Nov-2021 14:44:06
//---------------------------------------------------------------------------
namespace Saxonite.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 26-Aug-2021 12:36:27
// Code generated by Sarand Database Utilities Sat 20-Nov-2021 14:44:06
//---------------------------------------------------------------------------
namespace Saxonite.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 26-Aug-2021 12:36:27
// Code generated by Sarand Database Utilities Sat 20-Nov-2021 14:44:06
//---------------------------------------------------------------------------
namespace Saxonite.Net.Standard.Dbas.Internal
{
@@ -0,0 +1,254 @@
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 Sat 20-Nov-2021 14:44:06
//---------------------------------------------------------------------------
namespace Saxonite.Net.Standard.Dbas.Internal
{
internal class OrganisationEvent_Db : SaxDbDataItem
{
//-------------------------------------------------------------------
// Column definitions.
public class ColumnsData
{
public ColumnDataInt32 _Id { get; } = new ColumnDataInt32("Id", true);
public ColumnDataInt32 _OrganisationId { get; } = new ColumnDataInt32("OrganisationId");
public ColumnDataInt32 _SportIdPrimary { get; } = new ColumnDataInt32("SportIdPrimary");
public ColumnDataInt32 _RegionIdCountry { get; } = new ColumnDataInt32("RegionIdCountry");
public ColumnDataDateTime _EventAt { get; } = new ColumnDataDateTime("EventAt");
public ColumnDataString _EventTypeCode { get; } = new ColumnDataString("EventTypeCode");
public ColumnDataString _About { get; } = new ColumnDataString("About");
public ColumnDataString _EventData { get; } = new ColumnDataString("EventData");
public ColumnDataDateTime _PublishedAt { get; } = new ColumnDataDateTime("PublishedAt");
public ColumnDataDateTime _ExpiresAt { get; } = new ColumnDataDateTime("ExpiresAt");
public ColumnDataString _Notes { get; } = new ColumnDataString("Notes");
public ColumnDataInt16 _Flags { get; } = new ColumnDataInt16("Flags");
public ColumnDataString _Status { get; } = new ColumnDataString("Status");
public ColumnDataDateTime _CreateOn { get; } = new ColumnDataDateTime("CreateOn");
public ColumnDataInt32 _CreateBy { get; } = new ColumnDataInt32("CreateBy");
public ColumnDataString _CreateHost { get; } = new ColumnDataString("CreateHost");
public ColumnDataDateTime _UpdateOn { get; } = new ColumnDataDateTime("UpdateOn");
public ColumnDataInt32 _UpdateBy { get; } = new ColumnDataInt32("UpdateBy");
public ColumnDataString _UpdateHost { get; } = new ColumnDataString("UpdateHost");
}
//-------------------------------------------------------------------
// Data members.
protected static List<String> fields { get; } = new List<String>()
{
"Id",
"OrganisationId",
"SportIdPrimary",
"RegionIdCountry",
"EventAt",
"EventTypeCode",
"About",
"EventData",
"PublishedAt",
"ExpiresAt",
"Notes",
"Flags",
"Status",
"CreateOn",
"CreateBy",
"CreateHost",
"UpdateOn",
"UpdateBy",
"UpdateHost",
};
protected static List<String> fieldsId { get; } = new List<String>()
{
"Id",
};
protected static List<String> fieldsPrimary { get; } = new List<String>()
{
"Id",
};
protected static List<String> fieldsIgnoreOnUpdate { get; } = new List<String>()
{
"CreateOn",
"CreateBy",
"CreateHost",
};
//-------------------------------------------------------------------
// Construction.
internal OrganisationEvent_Db (IDatabaseInfo dbInfo) : base(dbInfo)
{
}
//-------------------------------------------------------------------
// Properties.
public override String SchemaName { get; } = "dbo";
public override String TableName { get; } = "OrganisationEvent";
public String TableNameFmt { get { return (!String.IsNullOrEmpty(SchemaName) ? "[" + SchemaName + "]." : "") + "[" + TableName + "]"; } }
public static List<String> Fields { get { return new List<String>(fields); } }
public static List<String> FieldsId { get { return new List<String>(fieldsId); } }
public static List<String> FieldsNonId { get { return fields.FindAll(item => !fieldsId.ContainsCI(item)); } }
// Columns.
public ColumnsData Cols { get; } = new ColumnsData();
public Int32 _Id { get { return Cols._Id.Value; } set { Cols._Id.Value = value; } }
public Int32 _OrganisationId { get { return Cols._OrganisationId.Value; } set { Cols._OrganisationId.Value = value; } }
public Int32 _SportIdPrimary { get { return Cols._SportIdPrimary.Value; } set { Cols._SportIdPrimary.Value = value; } }
public Int32 _RegionIdCountry { get { return Cols._RegionIdCountry.Value; } set { Cols._RegionIdCountry.Value = value; } }
public DateTime _EventAt { get { return Cols._EventAt.Value; } set { Cols._EventAt.Value = value; } }
public String _EventTypeCode { get { return Cols._EventTypeCode.Value; } set { Cols._EventTypeCode.Value = value; } }
public String _About { get { return Cols._About.Value; } set { Cols._About.Value = value; } }
public String _EventData { get { return Cols._EventData.Value; } set { Cols._EventData.Value = value; } }
public DateTime _PublishedAt { get { return Cols._PublishedAt.Value; } set { Cols._PublishedAt.Value = value; } }
public DateTime _ExpiresAt { get { return Cols._ExpiresAt.Value; } set { Cols._ExpiresAt.Value = value; } }
public String _Notes { get { return Cols._Notes.Value; } set { Cols._Notes.Value = value; } }
public Int16 _Flags { get { return Cols._Flags.Value; } set { Cols._Flags.Value = value; } }
public String _Status { get { return Cols._Status.Value; } set { Cols._Status.Value = value; } }
public DateTime _CreateOn { get { return Cols._CreateOn.Value; } set { Cols._CreateOn.Value = value; } }
public Int32 _CreateBy { get { return Cols._CreateBy.Value; } set { Cols._CreateBy.Value = value; } }
public String _CreateHost { get { return Cols._CreateHost.Value; } set { Cols._CreateHost.Value = value; } }
public DateTime _UpdateOn { get { return Cols._UpdateOn.Value; } set { Cols._UpdateOn.Value = value; } }
public Int32 _UpdateBy { get { return Cols._UpdateBy.Value; } set { Cols._UpdateBy.Value = value; } }
public String _UpdateHost { get { return Cols._UpdateHost.Value; } set { Cols._UpdateHost.Value = value; } }
// Existing columns - confirmed on database if table exists.
public List<String> ExistingColumnNames { get { return GetExistingColumnNames(Fields); } }
public List<String> 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 = GetFieldInt32(dbDataReader, "Id", _Id);
_OrganisationId = GetFieldInt32(dbDataReader, "OrganisationId", _OrganisationId);
_SportIdPrimary = GetFieldInt32(dbDataReader, "SportIdPrimary", _SportIdPrimary);
_RegionIdCountry = GetFieldInt32(dbDataReader, "RegionIdCountry", _RegionIdCountry);
_EventAt = GetFieldDateTime(dbDataReader, "EventAt", _EventAt);
_EventTypeCode = GetFieldString(dbDataReader, "EventTypeCode", _EventTypeCode);
_About = GetFieldString(dbDataReader, "About", _About);
_EventData = GetFieldString(dbDataReader, "EventData", _EventData);
_PublishedAt = GetFieldDateTime(dbDataReader, "PublishedAt", _PublishedAt);
_ExpiresAt = GetFieldDateTime(dbDataReader, "ExpiresAt", _ExpiresAt);
_Notes = GetFieldString(dbDataReader, "Notes", _Notes);
_Flags = GetFieldInt16(dbDataReader, "Flags", _Flags);
_Status = GetFieldString(dbDataReader, "Status", _Status);
_CreateOn = GetFieldDateTime(dbDataReader, "CreateOn", _CreateOn);
_CreateBy = GetFieldInt32(dbDataReader, "CreateBy", _CreateBy);
_CreateHost = GetFieldString(dbDataReader, "CreateHost", _CreateHost);
_UpdateOn = GetFieldDateTime(dbDataReader, "UpdateOn", _UpdateOn);
_UpdateBy = GetFieldInt32(dbDataReader, "UpdateBy", _UpdateBy);
_UpdateHost = GetFieldString(dbDataReader, "UpdateHost", _UpdateHost);
}
//-------------------------------------------------------------------
// Insert command.
public override bool ExecuteInsertCommand (DbCommand dbCommand)
{
List<String> 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("OrganisationId")) AddCommandParameter(dbCommand, "@OrganisationId", _OrganisationId);
if (columnNames.ContainsCI("SportIdPrimary")) AddCommandParameter(dbCommand, "@SportIdPrimary", _SportIdPrimary);
if (columnNames.ContainsCI("RegionIdCountry")) AddCommandParameter(dbCommand, "@RegionIdCountry", _RegionIdCountry);
if (columnNames.ContainsCI("EventAt")) AddCommandParameter(dbCommand, "@EventAt", _EventAt);
if (columnNames.ContainsCI("EventTypeCode")) AddCommandParameter(dbCommand, "@EventTypeCode", _EventTypeCode);
if (columnNames.ContainsCI("About")) AddCommandParameter(dbCommand, "@About", _About);
if (columnNames.ContainsCI("EventData")) AddCommandParameter(dbCommand, "@EventData", _EventData);
if (columnNames.ContainsCI("PublishedAt")) AddCommandParameter(dbCommand, "@PublishedAt", _PublishedAt);
if (columnNames.ContainsCI("ExpiresAt")) AddCommandParameter(dbCommand, "@ExpiresAt", _ExpiresAt);
if (columnNames.ContainsCI("Notes")) AddCommandParameter(dbCommand, "@Notes", _Notes);
if (columnNames.ContainsCI("Flags")) AddCommandParameter(dbCommand, "@Flags", _Flags);
if (columnNames.ContainsCI("Status")) AddCommandParameter(dbCommand, "@Status", _Status);
if (columnNames.ContainsCI("CreateOn")) AddCommandParameter(dbCommand, "@CreateOn", _CreateOn);
if (columnNames.ContainsCI("CreateBy")) AddCommandParameter(dbCommand, "@CreateBy", _CreateBy);
if (columnNames.ContainsCI("CreateHost")) AddCommandParameter(dbCommand, "@CreateHost", _CreateHost);
if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn);
if (columnNames.ContainsCI("UpdateBy")) AddCommandParameter(dbCommand, "@UpdateBy", _UpdateBy);
if (columnNames.ContainsCI("UpdateHost")) AddCommandParameter(dbCommand, "@UpdateHost", _UpdateHost);
// Execute insert command.
bool commandSuccess = false;
int executeNonQuery = dbCommand.ExecuteNonQuery();
if (executeNonQuery == 1)
{
dbCommand.CommandText = "SELECT Max(Id) FROM " + TableNameFmt + ";";
_Id = (Int32)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<String> 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("OrganisationId")) AddCommandParameter(dbCommand, "@OrganisationId", _OrganisationId);
if (columnNames.ContainsCI("SportIdPrimary")) AddCommandParameter(dbCommand, "@SportIdPrimary", _SportIdPrimary);
if (columnNames.ContainsCI("RegionIdCountry")) AddCommandParameter(dbCommand, "@RegionIdCountry", _RegionIdCountry);
if (columnNames.ContainsCI("EventAt")) AddCommandParameter(dbCommand, "@EventAt", _EventAt);
if (columnNames.ContainsCI("EventTypeCode")) AddCommandParameter(dbCommand, "@EventTypeCode", _EventTypeCode);
if (columnNames.ContainsCI("About")) AddCommandParameter(dbCommand, "@About", _About);
if (columnNames.ContainsCI("EventData")) AddCommandParameter(dbCommand, "@EventData", _EventData);
if (columnNames.ContainsCI("PublishedAt")) AddCommandParameter(dbCommand, "@PublishedAt", _PublishedAt);
if (columnNames.ContainsCI("ExpiresAt")) AddCommandParameter(dbCommand, "@ExpiresAt", _ExpiresAt);
if (columnNames.ContainsCI("Notes")) AddCommandParameter(dbCommand, "@Notes", _Notes);
if (columnNames.ContainsCI("Flags")) AddCommandParameter(dbCommand, "@Flags", _Flags);
if (columnNames.ContainsCI("Status")) AddCommandParameter(dbCommand, "@Status", _Status);
if (columnNames.ContainsCI("UpdateOn")) AddCommandParameter(dbCommand, "@UpdateOn", _UpdateOn);
if (columnNames.ContainsCI("UpdateBy")) AddCommandParameter(dbCommand, "@UpdateBy", _UpdateBy);
if (columnNames.ContainsCI("UpdateHost")) AddCommandParameter(dbCommand, "@UpdateHost", _UpdateHost);
AddCommandParameter(dbCommand, "@Id", _Id);
int executeNonQueryResult = dbCommand.ExecuteNonQuery();
return (executeNonQueryResult == 1);
}
//-------------------------------------------------------------------
}
}
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 26-Aug-2021 12:36:27
// Code generated by Sarand Database Utilities Sat 20-Nov-2021 14:44:06
//---------------------------------------------------------------------------
namespace Saxonite.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 26-Aug-2021 12:36:27
// Code generated by Sarand Database Utilities Sat 20-Nov-2021 14:44:06
//---------------------------------------------------------------------------
namespace Saxonite.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 26-Aug-2021 12:36:27
// Code generated by Sarand Database Utilities Sat 20-Nov-2021 14:44:06
//---------------------------------------------------------------------------
namespace Saxonite.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 26-Aug-2021 12:36:27
// Code generated by Sarand Database Utilities Sat 20-Nov-2021 14:44:06
//---------------------------------------------------------------------------
namespace Saxonite.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 26-Aug-2021 12:36:27
// Code generated by Sarand Database Utilities Sat 20-Nov-2021 14:44:06
//---------------------------------------------------------------------------
namespace Saxonite.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 26-Aug-2021 12:36:27
// Code generated by Sarand Database Utilities Sat 20-Nov-2021 14:44:06
//---------------------------------------------------------------------------
namespace Saxonite.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 26-Aug-2021 12:36:27
// Code generated by Sarand Database Utilities Sat 20-Nov-2021 14:44:06
//---------------------------------------------------------------------------
namespace Saxonite.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 26-Aug-2021 12:36:27
// Code generated by Sarand Database Utilities Sat 20-Nov-2021 14:44:06
//---------------------------------------------------------------------------
namespace Saxonite.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 26-Aug-2021 12:36:27
// Code generated by Sarand Database Utilities Sat 20-Nov-2021 14:44:06
//---------------------------------------------------------------------------
namespace Saxonite.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 26-Aug-2021 12:36:27
// Code generated by Sarand Database Utilities Sat 20-Nov-2021 14:44:06
//---------------------------------------------------------------------------
namespace Saxonite.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Thu 26-Aug-2021 12:36:27
// Code generated by Sarand Database Utilities Sat 20-Nov-2021 14:44:06
//---------------------------------------------------------------------------
namespace Saxonite.Net.Standard.Dbas.Internal
{
@@ -348,6 +348,14 @@ namespace Saxonite.Net.Standard.Dbas.Mgr
SetUserOrganisationColDfn(columnDfn, "Organisation", 160, SaxDbDfn_Core.ColumnIdx.Organisation_Name, ColumnAlignment.Left, DataValue.DataType.String, aliasUserOrganisation_Organisation, prefixUserOrganisation_Organisation);
columnDfn.ReadOnly = true;
break;
case SaxUserOrganisation.Column.Organisation_Category:
SetUserOrganisationColDfn(columnDfn, "Category", 60, SaxDbDfn_Core.ColumnIdx.Organisation_OrganisationCategory, ColumnAlignment.Center, DataValue.DataType.Long, aliasUserOrganisation_Organisation, prefixUserOrganisation_Organisation);
columnDfn.ReadOnly = true;
break;
case SaxUserOrganisation.Column.Organisation_Type:
SetUserOrganisationColDfn(columnDfn, "Type", 60, SaxDbDfn_Core.ColumnIdx.Organisation_OrganisationType, ColumnAlignment.Center, DataValue.DataType.Long, aliasUserOrganisation_Organisation, prefixUserOrganisation_Organisation);
columnDfn.ReadOnly = true;
break;
case SaxUserOrganisation.Column.Organisation_RegionId:
SetUserOrganisationColDfn(columnDfn, "Organisation region Id", 80, SaxDbDfn_Core.ColumnIdx.Organisation_RegionIdPrimary, ColumnAlignment.Right, DataValue.DataType.Long, aliasUserOrganisation_Organisation, prefixUserOrganisation_Organisation);
columnDfn.ReadOnly = true;
@@ -693,6 +701,8 @@ namespace Saxonite.Net.Standard.Dbas.Mgr
query.Joins.Add(joinOrganisation);
List<SaxDbDfn_Core.ColumnIdx> OrganisationCols = new List<SaxDbDfn_Core.ColumnIdx>();
OrganisationCols.Add(SaxDbDfn_Core.ColumnIdx.Organisation_Name);
OrganisationCols.Add(SaxDbDfn_Core.ColumnIdx.Organisation_OrganisationCategory);
OrganisationCols.Add(SaxDbDfn_Core.ColumnIdx.Organisation_OrganisationType);
OrganisationCols.Add(SaxDbDfn_Core.ColumnIdx.Organisation_RegionIdPrimary);
OrganisationCols.Add(SaxDbDfn_Core.ColumnIdx.Organisation_SportIdPrimary);
foreach (var col in OrganisationCols)
@@ -0,0 +1,689 @@
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.App;
using Saxonite.Net.Standard.Base.Bus;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Text;
using Sarand.Net.Standard.Base.Utils;
using System.Linq;
namespace Saxonite.Net.Standard.Dbas.Mgr
{
//=======================================================================
partial class SaxActivityMgr_Dbas
{
//*******************************************************************
// Activity Mgr - Organisation Event
//*******************************************************************
// Utilities.
private List<StringPair> GetLogProperties(SaxOrganisationEvent organisationEvent)
{
return new List<StringPair>()
{
new StringPair("Id", SysId.ToString(organisationEvent.Id)),
new StringPair("OrganisationId", SysId.ToString(organisationEvent.OrganisationId)),
new StringPair("Event at", DateUtil.Format(organisationEvent.EventAt, "d-MMM-yyyy HH:mm")),
new StringPair("Event type", EventTypeCodes.GetDescForType(organisationEvent.EventType)),
new StringPair("Status", organisationEvent.StatusCode)
};
}
//-------------------------------------------------------------------
// Create item.
public override SaxOrganisationEvent CreateOrganisationEvent(SysId userAccountIdJournalist)
{
ClearErrorState();
return new SaxOrganisationEvent_Dbas(CoreDatabase, null, userAccountIdJournalist, 0);
}
private SaxOrganisationEvent_Dbas CreateOrganisationEvent(OrganisationEvent_Db dbOrganisationEvent)
{
ClearErrorState();
SaxOrganisationEvent_Dbas organisationEvent = new SaxOrganisationEvent_Dbas(CoreDatabase, new SysId(dbOrganisationEvent._Id), new SysId(dbOrganisationEvent._OrganisationId), (UInt16)dbOrganisationEvent._Flags);
PopulateFrom(dbOrganisationEvent, organisationEvent);
return organisationEvent;
}
//-------------------------------------------------------------------
// Get item.
public override SaxOrganisationEvent GetOrganisationEvent(SaxOrganisationEvent.Params prm)
{
ClearErrorState();
return GetOrganisationEvent(GetOrganisationEventQueryFilter(prm).Concat(" And ", "(", ")"));
}
private SaxOrganisationEvent GetOrganisationEvent(String filter)
{
ClearErrorState();
long count = GetOrganisationEventCount(filter);
if (count == 0) return null;
if (count != 1)
{
SetErrorState("Multiple items found");
return null;
}
SaxOrganisationEvent organisationEvent = null;
// Query data.
using (var dbConnection = CoreDatabase.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
{
dbConnection.Open();
OrganisationEvent_Db dbOrganisationEvent = new OrganisationEvent_Db(CoreDbInfo);
dbOrganisationEvent.PopulateFrom(dbCommand, aliasOrganisationEvent, filter);
organisationEvent = CreateOrganisationEvent(dbOrganisationEvent);
}
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetOrganisationEvent\n\tQuery: " + dbCommand.CommandText + "\n\t" + ExceptionUtil.GetLogMessage(exc));
}
}
return organisationEvent;
}
//-------------------------------------------------------------------
// Validate item.
public override bool IsValidOrganisationEventData(SaxOrganisationEvent.Data data, SaxOrganisationEvent.ErrField errField)
{
ClearErrorState();
if (!base.IsValidOrganisationEventData(data, errField)) return false;
return true;
}
//-------------------------------------------------------------------
// Insert item.
public override bool InsertOrganisationEvent(SaxOrganisationEvent organisationEvent, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".InsertOrganisationEvent";
ClearErrorState();
if (!IsValidOrganisationEvent(organisationEvent)) return false;
if (SysId.IsValid(organisationEvent.Id)) return SetErrorState(ErrorMessage.ValiditemId);
using (var dbConnection = CoreDatabase.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
{
dbConnection.Open();
OrganisationEvent_Db dbOrganisationEvent = new OrganisationEvent_Db(CoreDbInfo);
PopulateTo(dbOrganisationEvent, organisationEvent, dbUpdateInfo);
if (OrganisationEvent_Db.FieldsNonId.Contains("Id"))
{
// Generate next Id.
// ToDo dbOrganisationEvent._Id = CoreDatabase.GetNextIdFromTable("OrganisationEvent");
}
dbOrganisationEvent.ExecuteInsertCommand(dbCommand);
organisationEvent.Id = new SysId(dbOrganisationEvent._Id);
organisationEvent.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(organisationEvent).Concat(": ").Concat("", "\n\t"));
}
catch (Exception exc) { SetErrorState(exc.Message); }
}
return !HasErrorState();
}
//-------------------------------------------------------------------
// Update item.
public override bool UpdateOrganisationEvent(SaxOrganisationEvent organisationEvent, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".UpdateOrganisationEvent";
ClearErrorState();
if (!IsValidOrganisationEvent(organisationEvent)) return false;
if (!SysId.IsValid(organisationEvent.Id)) return SetErrorState(ErrorMessage.InvalidItemId);
if (!organisationEvent.Changed)
{
if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(organisationEvent).Concat(": ").Concat("", "\n\t"));
return true;
}
using (var dbConnection = CoreDatabase.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
{
// Retrieve item.
dbConnection.Open();
OrganisationEvent_Db dbOrganisationEvent = new OrganisationEvent_Db(CoreDbInfo);
dbOrganisationEvent.PopulateFrom(dbCommand, aliasOrganisationEvent, "Id=" + SysId.ToString(organisationEvent.Id));
// ToDo SaxUpdateLogItemMonitor_OrganisationEvent updateLogMonitor = new SaxUpdateLogItemMonitor_OrganisationEvent(SessionContext, CreateOrganisationEvent(dbOrganisationEvent), dbUpdateInfo);
// Update item.
PopulateTo(dbOrganisationEvent, organisationEvent, dbUpdateInfo);
dbOrganisationEvent.ExecuteUpdateCommand(dbCommand);
organisationEvent.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(organisationEvent).Concat(": ").Concat("", "\n\t"));
// Record updates.
// ToDo updateLogMonitor.RecordUpdatedValues(organisationEvent);
// ToDo updateLogMonitor.LogUpdates();
}
catch (Exception exc) { SetErrorState(exc.Message); }
}
return !HasErrorState();
}
//-------------------------------------------------------------------
// Delete item.
public override bool OrganisationEventCanBeDeleted(SaxOrganisationEvent organisationEvent)
{
ClearErrorState();
if (!base.OrganisationEventCanBeDeleted(organisationEvent)) return false;
return true;
}
public override bool DeleteOrganisationEvent(SaxOrganisationEvent organisationEvent, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".DeleteOrganisationEvent";
ClearErrorState();
if (!OrganisationEventCanBeDeleted(organisationEvent)) return false;
// Organisation Events are logically deleted by changing the status.
organisationEvent.Status = SaStatus.Deleted;
return UpdateOrganisationEvent(organisationEvent, dbUpdateInfo);
/*
* Physical deletion.
using (var dbConnection = CoreDatabase.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
{
// Retrieve item.
dbConnection.Open();
OrganisationEvent_Db dbOrganisationEvent = new OrganisationEvent_Db(CoreDbInfo);
dbOrganisationEvent.PopulateFrom(dbCommand, aliasOrganisationEvent, "Id=" + organisationEvent.Id.ToString());
// Delete item.
dbCommand.CommandType = System.Data.CommandType.Text;
dbCommand.CommandText = "DELETE FROM " + SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.OrganisationEvent) + " WHERE Id=" + SysId.ToString(organisationEvent.Id) + ";";
dbCommand.ExecuteNonQuery();
organisationEvent.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(organisationEvent).Concat(": ").Concat("", "\n\t"));
}
catch (Exception exc) { SetErrorState(exc.Message); }
}
return !HasErrorState();
*/
}
//-------------------------------------------------------------------
// Copy data properties to and from database.
private void PopulateTo(OrganisationEvent_Db dbOrganisationEvent, SaxOrganisationEvent organisationEvent, DbUpdateInfo dbUpdateInfo)
{
dbOrganisationEvent._Id = SysId.ToInt(organisationEvent.Id);
dbOrganisationEvent._OrganisationId = SysId.ToInt(organisationEvent.OrganisationId);
dbOrganisationEvent._SportIdPrimary = SysId.ToInt(organisationEvent.SportIdPrimary);
dbOrganisationEvent._RegionIdCountry = SysId.ToInt(organisationEvent.RegionIdCountry);
dbOrganisationEvent._EventAt = organisationEvent.EventAt;
dbOrganisationEvent._EventTypeCode = EventTypeCodes.GetCodeForType(organisationEvent.EventType);
dbOrganisationEvent._About = organisationEvent.About;
dbOrganisationEvent._EventData = organisationEvent.EventData;
dbOrganisationEvent._PublishedAt = organisationEvent.PublishedAt;
dbOrganisationEvent._ExpiresAt = organisationEvent.ExpiresAt;
dbOrganisationEvent._Notes = organisationEvent.Notes;
dbOrganisationEvent._Status = SacsSystem.GetStatusCode(organisationEvent.Status);
dbOrganisationEvent._Flags = (short)organisationEvent.Flags;
if (!SysId.IsValid(organisationEvent.Id))
{
dbOrganisationEvent._CreateOn = DateTime.Now;
dbOrganisationEvent._CreateBy = dbUpdateInfo.UserId.ToInt();
dbOrganisationEvent._CreateHost = dbUpdateInfo.Host;
}
dbOrganisationEvent._UpdateOn = DateTime.Now;
dbOrganisationEvent._UpdateBy = dbUpdateInfo.UserId.ToInt();
dbOrganisationEvent._UpdateHost = dbUpdateInfo.Host;
}
private void PopulateFrom(OrganisationEvent_Db dbOrganisationEvent, SaxOrganisationEvent organisationEvent)
{
//organisationEvent.Id = new SysId(dbOrganisationEvent._Id);
//organisationEvent.OrganisationId = new SysId(dbOrganisationEvent._OrganisationId);
organisationEvent.SportIdPrimary = new SysId(dbOrganisationEvent._SportIdPrimary);
organisationEvent.RegionIdCountry = new SysId(dbOrganisationEvent._RegionIdCountry);
organisationEvent.EventAt = dbOrganisationEvent._EventAt;
organisationEvent.EventType = (Sax.EventType)EventTypeCodes.GetTypeForCode(dbOrganisationEvent._EventTypeCode);
organisationEvent.About = dbOrganisationEvent._About;
organisationEvent.EventData = dbOrganisationEvent._EventData;
organisationEvent.PublishedAt = dbOrganisationEvent._PublishedAt;
organisationEvent.ExpiresAt = dbOrganisationEvent._ExpiresAt;
organisationEvent.Notes = dbOrganisationEvent._Notes;
organisationEvent.Status = SacsSystem.GetStatusForCode(dbOrganisationEvent._Status);
organisationEvent.SetCreateStamp(dbOrganisationEvent._CreateOn, new SysId(dbOrganisationEvent._CreateBy), dbOrganisationEvent._CreateHost);
organisationEvent.SetUpdateStamp(dbOrganisationEvent._UpdateOn, new SysId(dbOrganisationEvent._UpdateBy), dbOrganisationEvent._UpdateHost);
organisationEvent.AcceptChanges();
}
//-------------------------------------------------------------------
// Item column definitions.
private static readonly String aliasOrganisationEvent = "Sprt";
private static readonly String aliasOrganisationEvent_Organisation = "OrgOpp_Org";
private static readonly String prefixOrganisationEvent_Organisation = "OrgOpp_Org_";
private static readonly String aliasOrganisationEvent_Organisation_UserOrganisation = "OrgOpp_Org_UsrOrg";
private static readonly String aliasOrganisationEvent_Sport = "OrgOpp_Spt";
private static readonly String prefixOrganisationEvent_Sport = "OrgOpp_Spt_";
private static readonly String aliasOrganisationEvent_Region = "OrgOpp_Rgn";
private static readonly String prefixOrganisationEvent_Region = "OrgOpp_Rgn_";
private void SetOrganisationEventColDfn
(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.OrganisationEvent)
alias = aliasOrganisationEvent;
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 GetOrganisationEventColumnDfn(SaxOrganisationEvent.Column columnId, string caption = "", int width = 0)
{
ColumnDfn columnDfn = new ColumnDfn((int)columnId, caption, width);
switch (columnId)
{
//-----------------------------------------------------------
case SaxOrganisationEvent.Column.Pos:
SetOrganisationEventColDfn(columnDfn, "Pos", 60, SaxDbDfn_Core.ColumnIdx.Unknown, ColumnAlignment.Right);
columnDfn.SortMode = ColumnDfn.ColumnSortMode.Off;
columnDfn.ReadOnly = true;
columnDfn.Resizable = false;
break;
case SaxOrganisationEvent.Column.Id:
SetOrganisationEventColDfn(columnDfn, "Id", 80, SaxDbDfn_Core.ColumnIdx.OrganisationEvent_Id, ColumnAlignment.Right, DataValue.DataType.Long);
columnDfn.ReadOnly = true;
break;
//-----------------------------------------------------------
// Organisation.
case SaxOrganisationEvent.Column.OrganisationId:
SetOrganisationEventColDfn(columnDfn, "Organisation Id", 80, SaxDbDfn_Core.ColumnIdx.OrganisationEvent_OrganisationId, ColumnAlignment.Right, DataValue.DataType.Long);
columnDfn.ReadOnly = true;
break;
case SaxOrganisationEvent.Column.Organisation_Name:
SetOrganisationEventColDfn(columnDfn, "Organisation", 160, SaxDbDfn_Core.ColumnIdx.Organisation_Name, ColumnAlignment.Left, DataValue.DataType.String, aliasOrganisationEvent_Organisation, prefixOrganisationEvent_Organisation);
columnDfn.ReadOnly = true;
break;
//-----------------------------------------------------------
// Sport.
case SaxOrganisationEvent.Column.SportIdPrimary:
SetOrganisationEventColDfn(columnDfn, "Sport Id", 80, SaxDbDfn_Core.ColumnIdx.OrganisationEvent_SportIdPrimary, ColumnAlignment.Right, DataValue.DataType.Long);
columnDfn.ReadOnly = true;
break;
case SaxOrganisationEvent.Column.Sport_Name:
SetOrganisationEventColDfn(columnDfn, "Sport", 100, SaxDbDfn_Core.ColumnIdx.Sport_Name, ColumnAlignment.Left, DataValue.DataType.String, aliasOrganisationEvent_Sport, prefixOrganisationEvent_Sport);
columnDfn.ReadOnly = true;
break;
//-----------------------------------------------------------
// Region.
case SaxOrganisationEvent.Column.RegionIdCountry:
SetOrganisationEventColDfn(columnDfn, "Region Id", 80, SaxDbDfn_Core.ColumnIdx.OrganisationEvent_RegionIdCountry, ColumnAlignment.Right, DataValue.DataType.Long);
columnDfn.ReadOnly = true;
break;
case SaxOrganisationEvent.Column.Region_Name:
SetOrganisationEventColDfn(columnDfn, "Region", 100, SaxDbDfn_Core.ColumnIdx.Region_Name, ColumnAlignment.Left, DataValue.DataType.String, aliasOrganisationEvent_Region, prefixOrganisationEvent_Region);
columnDfn.ReadOnly = true;
break;
//-----------------------------------------------------------
// Event.
case SaxOrganisationEvent.Column.EventAt_Date:
SetOrganisationEventColDfn(columnDfn, "Event", 80, SaxDbDfn_Core.ColumnIdx.OrganisationEvent_EventAt, ColumnAlignment.Center, DataValue.DataType.Date);
columnDfn.ReadOnly = true;
break;
case SaxOrganisationEvent.Column.EventAt_DateTime:
SetOrganisationEventColDfn(columnDfn, "Event", 100, SaxDbDfn_Core.ColumnIdx.OrganisationEvent_EventAt, ColumnAlignment.Center, DataValue.DataType.DateTime);
columnDfn.ReadOnly = true;
break;
case SaxOrganisationEvent.Column.EventTypeCode:
SetOrganisationEventColDfn(columnDfn, "Type", 90, SaxDbDfn_Core.ColumnIdx.OrganisationEvent_EventTypeCode, ColumnAlignment.Center);
break;
case SaxOrganisationEvent.Column.EventType_Desc:
SetOrganisationEventColDfn(columnDfn, "Type", 120, SaxDbDfn_Core.ColumnIdx.OrganisationEvent_EventTypeCode, ColumnAlignment.Center);
break;
case SaxOrganisationEvent.Column.About:
SetOrganisationEventColDfn(columnDfn, "About", 200, SaxDbDfn_Core.ColumnIdx.OrganisationEvent_About);
break;
case SaxOrganisationEvent.Column.PublishedAt_Date:
SetOrganisationEventColDfn(columnDfn, "Published", 80, SaxDbDfn_Core.ColumnIdx.OrganisationEvent_PublishedAt, ColumnAlignment.Center, DataValue.DataType.Date);
columnDfn.ReadOnly = true;
break;
case SaxOrganisationEvent.Column.PublishedAt_DateTime:
SetOrganisationEventColDfn(columnDfn, "Published", 100, SaxDbDfn_Core.ColumnIdx.OrganisationEvent_PublishedAt, ColumnAlignment.Center, DataValue.DataType.DateTime);
columnDfn.ReadOnly = true;
break;
case SaxOrganisationEvent.Column.ExpiresAt_Date:
SetOrganisationEventColDfn(columnDfn, "Expires", 80, SaxDbDfn_Core.ColumnIdx.OrganisationEvent_ExpiresAt, ColumnAlignment.Center, DataValue.DataType.Date);
columnDfn.ReadOnly = true;
break;
case SaxOrganisationEvent.Column.ExpiresAt_DateTime:
SetOrganisationEventColDfn(columnDfn, "Expires", 100, SaxDbDfn_Core.ColumnIdx.OrganisationEvent_ExpiresAt, ColumnAlignment.Center, DataValue.DataType.DateTime);
columnDfn.ReadOnly = true;
break;
//-----------------------------------------------------------
// Derived properties.
//-----------------------------------------------------------
// Common properties.
case SaxOrganisationEvent.Column.Notes:
SetOrganisationEventColDfn(columnDfn, "Notes", 240, SaxDbDfn_Core.ColumnIdx.OrganisationEvent_Notes);
break;
case SaxOrganisationEvent.Column.Flags:
SetOrganisationEventColDfn(columnDfn, "Flags", 60, SaxDbDfn_Core.ColumnIdx.OrganisationEvent_Flags, ColumnAlignment.Center, DataValue.DataType.Long);
break;
case SaxOrganisationEvent.Column.Status:
SetOrganisationEventColDfn(columnDfn, "Status", 80, SaxDbDfn_Core.ColumnIdx.OrganisationEvent_Status, ColumnAlignment.Center);
break;
case SaxOrganisationEvent.Column.Status_Desc:
SetOrganisationEventColDfn(columnDfn, "Status", 90, SaxDbDfn_Core.ColumnIdx.OrganisationEvent_Status, ColumnAlignment.Center);
break;
case SaxOrganisationEvent.Column.Status_Ind:
SetOrganisationEventColDfn(columnDfn, "Status", 80, SaxDbDfn_Core.ColumnIdx.OrganisationEvent_Status, ColumnAlignment.Center, DataValue.DataType.TriState);
columnDfn.TriStateFormat = ColumnTriStateFormat.Lights;
break;
case SaxOrganisationEvent.Column.CreateOn_Date:
SetOrganisationEventColDfn(columnDfn, "Created", 80, SaxDbDfn_Core.ColumnIdx.OrganisationEvent_CreateOn, ColumnAlignment.Center, DataValue.DataType.Date);
columnDfn.ReadOnly = true;
break;
case SaxOrganisationEvent.Column.UpdateOn_Date:
SetOrganisationEventColDfn(columnDfn, "Updated", 80, SaxDbDfn_Core.ColumnIdx.OrganisationEvent_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<string> GetOrganisationEventQueryFilter(SaxOrganisationEvent.Params prm)
{
List<String> filter = new List<String>();
// Item Ids.
String idsIncluded = prm.IdsIncluded.Concat(",");
if (!idsIncluded.IsEmpty())
filter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_Id, aliasOrganisationEvent) + " IN (" + idsIncluded + ")");
String idsExcluded = prm.IdsExcluded.Concat(",");
if (!idsExcluded.IsEmpty())
filter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_Id, aliasOrganisationEvent) + " NOT IN (" + idsExcluded + ")");
// User Account Ids.
String userAccountIdsIncluded = prm.UserAccountIdsIncluded.Concat(",");
if (!userAccountIdsIncluded.IsEmpty())
{
// User Organisation.
if (!StringUtil.IsEmpty(prm.Alias_UserOrganisation))
{
// Filter directly on the joined User Organisation table.
filter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserOrganisation_UserAccountId, prm.Alias_UserOrganisation) + " IN (" + userAccountIdsIncluded + ")");
}
else
{
// User Organisation query.
String alias_UserOrganisation = aliasOrganisationEvent_Organisation_UserOrganisation;
DbQuery queryUserOrganisation = new DbQuery(CoreDatabase.DbmsType);
queryUserOrganisation.Tables.Add(SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.UserOrganisation), alias_UserOrganisation);
queryUserOrganisation.Filters.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserOrganisation_UserAccountId, alias_UserOrganisation) + " IN (" + userAccountIdsIncluded + ")");
// Filter Organisation directly against the Organisation Event.
queryUserOrganisation.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserOrganisation_OrganisationId, alias_UserOrganisation));
filter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_OrganisationId, aliasOrganisationEvent) + " IN (" + queryUserOrganisation.BuildQuery() + ")");
}
}
// Organisation Ids.
String organisationIdsIncluded = prm.OrganisationIdsIncluded.Concat(",");
if (!organisationIdsIncluded.IsEmpty())
filter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_OrganisationId, aliasOrganisationEvent) + " IN (" + organisationIdsIncluded + ")");
// Sport Ids.
String sportIdsIncluded = prm.SportIdsIncluded.Concat(",");
if (!sportIdsIncluded.IsEmpty())
filter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_SportIdPrimary, aliasOrganisationEvent) + " IN (" + sportIdsIncluded + ")");
// Region Ids.
String regionIdsIncluded = prm.RegionIdsIncluded.Concat(",");
if (!regionIdsIncluded.IsEmpty())
filter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_RegionIdCountry, aliasOrganisationEvent) + " IN (" + regionIdsIncluded + ")");
// About.
if (!StringUtil.IsEmpty(prm.AboutPartial))
filter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_About, aliasOrganisationEvent) + " Like '%" + DbQuery.FormatForLike(prm.AboutPartial, true) + "%'");
// Article.
if (!StringUtil.IsEmpty(prm.EventFilter))
{
// Split filter into words.
List<String> filterWords = prm.EventFilter.Split((char[])null).ToList();
filterWords.RemoveDuplicatesCI();
filterWords.RemoveBlanks();
foreach (String filterWord in filterWords)
{
List<String> articleFilter = new List<String>();
articleFilter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_About, aliasOrganisationEvent) + " Like '%" + DbQuery.FormatForLike(filterWord, true) + "%'");
filter.Add(articleFilter.Concat(" OR ", "(", ")"));
}
}
// Notes.
if (!StringUtil.IsEmpty(prm.NotesPartial))
filter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_Notes, aliasOrganisationEvent) + " LIKE '%" + DbQuery.FormatForLike(prm.NotesPartial) + "%'");
// Status.
if (prm.StatusCat != SaxOrganisationEvent.StatusCat.Any)
filter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_Status, aliasOrganisationEvent) + GetOrganisationEventStatusCatFilterCondition(prm.StatusCat));
if (filter.Count < 1) filter.Add("1=1");
return filter;
}
internal static String GetOrganisationEventStatusCatFilterCondition(SaxOrganisationEvent.StatusCat statusCat)
{
if (statusCat == SaxOrganisationEvent.StatusCat.ActiveOnly)
return "='" + SacsSystem.GetStatusCode(SaStatus.Active) + "'";
if (statusCat == SaxOrganisationEvent.StatusCat.InactiveOnly)
return "='" + SacsSystem.GetStatusCode(SaStatus.Inactive) + "'";
if (statusCat == SaxOrganisationEvent.StatusCat.NotDeleted)
return "!='" + SacsSystem.GetStatusCode(SaStatus.Deleted) + "'";
if (statusCat == SaxOrganisationEvent.StatusCat.DeletedOnly)
return "='" + SacsSystem.GetStatusCode(SaStatus.Deleted) + "'";
return "";
}
// Item sort columns.
public List<String> GetOrganisationEventSortColumns(SaxOrganisationEvent.Params prm)
{
// Sort sequence:
List<String> sortColumnNames = new List<String>();
foreach (var columnDfn in prm.SortColumns)
{
// Need to ensure correct alias used for OrganisationEvent columns in case of conflict.
String sortCol = String.Empty;
if (SaxDbDfn_Core.GetTableForColumn((SaxDbDfn_Core.ColumnIdx)columnDfn.DbColumn) == SaxDbDfn_Core.TableIdx.OrganisationEvent)
{
sortCol = SaxDbDfn_Core.GetColumnNameQual((SaxDbDfn_Core.ColumnIdx)columnDfn.DbColumn, aliasOrganisationEvent);
}
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.OrganisationEvent_Id, aliasOrganisationEvent) + " ASC");
}
return sortColumnNames;
}
//-------------------------------------------------------------------
// Item count.
private long GetOrganisationEventCount(String filter)
{
ClearErrorState();
return CoreDatabase.GetRowCount(SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.OrganisationEvent) + " As " + aliasOrganisationEvent, filter);
}
public override long GetOrganisationEventCount(SaxOrganisationEvent.Params prm)
{
ClearErrorState();
return GetOrganisationEventCount(GetOrganisationEventQueryFilter(prm).Concat(" AND ", "(", ")"));
}
//-------------------------------------------------------------------
// Item list.
public override List<SaxOrganisationEvent> GetOrganisationEventList(SaxOrganisationEvent.Params prm)
{
List<SaxOrganisationEvent> userActivitys = new List<SaxOrganisationEvent>();
DbQuery qry = new DbQuery(CoreDatabase.DbmsType);
qry.Tables.Add(SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.OrganisationEvent), aliasOrganisationEvent);
OrganisationEvent_Db dbOrganisationEvent = new OrganisationEvent_Db(CoreDbInfo);
qry.Columns.AddRange(dbOrganisationEvent.ExistingColumnNames);
qry.Filters.AddRange(GetOrganisationEventQueryFilter(prm));
qry.OrderBy.AddRange(GetOrganisationEventSortColumns(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())
{
dbOrganisationEvent = new OrganisationEvent_Db(CoreDbInfo);
dbOrganisationEvent.PopulateFrom(dbDataReader);
userActivitys.Add(CreateOrganisationEvent(dbOrganisationEvent));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetOrganisationEventList\n\tQuery: " + dbCommand.CommandText + "\n\t" + ExceptionUtil.GetLogMessage(exc));
}
}
return userActivitys;
}
//-------------------------------------------------------------------
// Item query execution.
public override DbResultSet ExecuteOrganisationEventQuery(List<ColumnDfn> columns, SaxOrganisationEvent.Params prm)
{
ClearErrorState();
//---------------------------------------------------------------------
// Construct query.
DbQuery query = new DbQuery(CoreDatabase.DbmsType);
query.Tables.Add(SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.OrganisationEvent), aliasOrganisationEvent);
// Add columns as defined in query list.
if (columns.HasId(SaxOrganisationEvent.Column.Id))
query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_Id, aliasOrganisationEvent));
bool hasOrganisationCols = (columns.HasId(SaxOrganisationEvent.Column.Organisation_Name));
if (columns.HasId(SaxOrganisationEvent.Column.OrganisationId) || hasOrganisationCols)
query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_OrganisationId, aliasOrganisationEvent));
bool hasSportCols = (columns.HasId(SaxOrganisationEvent.Column.Sport_Name));
if (columns.HasId(SaxOrganisationEvent.Column.SportIdPrimary) || hasSportCols)
query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_SportIdPrimary, aliasOrganisationEvent));
bool hasRegionCols = (columns.HasId(SaxOrganisationEvent.Column.Region_Name));
if (columns.HasId(SaxOrganisationEvent.Column.RegionIdCountry) || hasRegionCols)
query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_RegionIdCountry, aliasOrganisationEvent));
if (columns.HasId(SaxOrganisationEvent.Column.EventAt_Date) || columns.HasId(SaxOrganisationEvent.Column.EventAt_DateTime))
query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_EventAt, aliasOrganisationEvent));
if (columns.HasId(SaxOrganisationEvent.Column.EventTypeCode) || columns.HasId(SaxOrganisationEvent.Column.EventType_Desc))
query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_EventTypeCode, aliasOrganisationEvent));
if (columns.HasId(SaxOrganisationEvent.Column.About))
query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_About, aliasOrganisationEvent));
if (columns.HasId(SaxOrganisationEvent.Column.PublishedAt_Date) || columns.HasId(SaxOrganisationEvent.Column.PublishedAt_DateTime))
query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_PublishedAt, aliasOrganisationEvent));
if (columns.HasId(SaxOrganisationEvent.Column.ExpiresAt_Date) || columns.HasId(SaxOrganisationEvent.Column.ExpiresAt_DateTime))
query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_ExpiresAt, aliasOrganisationEvent));
// Common properties.
if (columns.HasId(SaxOrganisationEvent.Column.Notes))
query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_Notes, aliasOrganisationEvent));
if (columns.HasId(SaxOrganisationEvent.Column.Flags))
query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_Flags, aliasOrganisationEvent));
if (columns.HasId(SaxOrganisationEvent.Column.Status) || columns.HasId(SaxOrganisationEvent.Column.Status_Desc) || columns.HasId(SaxOrganisationEvent.Column.Status_Ind))
query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_Status, aliasOrganisationEvent));
if (columns.HasId(SaxOrganisationEvent.Column.CreateOn_Date))
query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_CreateOn, aliasOrganisationEvent));
if (columns.HasId(SaxOrganisationEvent.Column.UpdateOn_Date))
query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_UpdateOn, aliasOrganisationEvent));
//---------------------------------------------------------------------
// Organisation.
if (hasOrganisationCols)
{
DbQueryJoin joinOrganisation = new DbQueryJoin(DbJoinType.LeftOuter);
joinOrganisation.Table = new StringPair(SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.Organisation), aliasOrganisationEvent_Organisation);
joinOrganisation.Filters.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.Organisation_Id, aliasOrganisationEvent_Organisation) + "=" + SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_OrganisationId, aliasOrganisationEvent));
query.Joins.Add(joinOrganisation);
List<SaxDbDfn_Core.ColumnIdx> cols = new List<SaxDbDfn_Core.ColumnIdx>();
cols.Add(SaxDbDfn_Core.ColumnIdx.Organisation_Name);
foreach (var col in cols)
query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(col, aliasOrganisationEvent_Organisation), prefixOrganisationEvent_Organisation + SaxDbDfn_Core.GetColumnName(col, false));
prm.Alias_Organisation = aliasOrganisationEvent_Organisation;
}
//---------------------------------------------------------------------
// Primary Sport.
if (hasSportCols)
{
DbQueryJoin joinSport = new DbQueryJoin(DbJoinType.LeftOuter);
joinSport.Table = new StringPair(SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.Sport), aliasOrganisationEvent_Sport);
joinSport.Filters.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.Sport_Id, aliasOrganisationEvent_Sport) + "=" + SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_SportIdPrimary, aliasOrganisationEvent));
query.Joins.Add(joinSport);
List<SaxDbDfn_Core.ColumnIdx> cols = new List<SaxDbDfn_Core.ColumnIdx>();
cols.Add(SaxDbDfn_Core.ColumnIdx.Sport_Name);
foreach (var col in cols)
query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(col, aliasOrganisationEvent_Sport), prefixOrganisationEvent_Sport + SaxDbDfn_Core.GetColumnName(col, false));
}
//---------------------------------------------------------------------
// Primary Region.
if (hasRegionCols)
{
DbQueryJoin joinRegion = new DbQueryJoin(DbJoinType.LeftOuter);
joinRegion.Table = new StringPair(SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.Region), aliasOrganisationEvent_Region);
joinRegion.Filters.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.Region_Id, aliasOrganisationEvent_Region) + "=" + SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.OrganisationEvent_RegionIdCountry, aliasOrganisationEvent));
query.Joins.Add(joinRegion);
List<SaxDbDfn_Core.ColumnIdx> cols = new List<SaxDbDfn_Core.ColumnIdx>();
cols.Add(SaxDbDfn_Core.ColumnIdx.Region_Name);
foreach (var col in cols)
query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(col, aliasOrganisationEvent_Region), prefixOrganisationEvent_Region + SaxDbDfn_Core.GetColumnName(col, false));
}
//---------------------------------------------------------------------
// Populate filter.
query.Filters.AddRange(GetOrganisationEventQueryFilter(prm));
if (prm.IdsIncluded.Count != 1)
{
// Configure sort sequence.
foreach (String sortColumn in GetOrganisationEventSortColumns(prm))
query.OrderBy.Add(sortColumn);
}
//---------------------------------------------------------------------
//return new DbResultSet_DataTableReader(db, query.BuildQuery(prm.ResultsPaging));
return DbResultSet_DataReader.ExecuteQuery(CoreDatabase, query.BuildQuery(prm.ResultsPaging));
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -30,6 +30,7 @@ namespace Saxonite.Net.Standard.Dbas.Mgr
{
new StringPair("Id", SysId.ToString(organisationOpportunity.Id)),
new StringPair("OrganisationId", SysId.ToString(organisationOpportunity.OrganisationId)),
new StringPair("Opportunity type", OpportunityTypeCodes.GetDescForType(organisationOpportunity.OpportunityType)),
new StringPair("Position", StringUtil.Left(organisationOpportunity.Position,32)),
new StringPair("Status", organisationOpportunity.StatusCode)
};
@@ -327,10 +328,10 @@ namespace Saxonite.Net.Standard.Dbas.Mgr
//-----------------------------------------------------------
// Opportunity.
case SaxOrganisationOpportunity.Column.OpportunityTypeCode:
SetOrganisationOpportunityColDfn(columnDfn, "Opportunity", 90, SaxDbDfn_Core.ColumnIdx.OrganisationOpportunity_OpportunityTypeCode, ColumnAlignment.Center);
SetOrganisationOpportunityColDfn(columnDfn, "Type", 90, SaxDbDfn_Core.ColumnIdx.OrganisationOpportunity_OpportunityTypeCode, ColumnAlignment.Center);
break;
case SaxOrganisationOpportunity.Column.OpportunityType_Desc:
SetOrganisationOpportunityColDfn(columnDfn, "Opportunbity", 120, SaxDbDfn_Core.ColumnIdx.OrganisationOpportunity_OpportunityTypeCode, ColumnAlignment.Center);
SetOrganisationOpportunityColDfn(columnDfn, "Type", 120, SaxDbDfn_Core.ColumnIdx.OrganisationOpportunity_OpportunityTypeCode, ColumnAlignment.Center);
break;
case SaxOrganisationOpportunity.Column.Position:
SetOrganisationOpportunityColDfn(columnDfn, "Position", 200, SaxDbDfn_Core.ColumnIdx.OrganisationOpportunity_Position);
@@ -256,7 +256,7 @@
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>1</Pages>
<UniqueValues>9</UniqueValues>
<UniqueValues>11</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
@@ -666,7 +666,7 @@
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>2</Pages>
<UniqueValues>11</UniqueValues>
<UniqueValues>13</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
@@ -1289,7 +1289,7 @@
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>1</Pages>
<UniqueValues>3</UniqueValues>
<UniqueValues>9</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
@@ -1717,7 +1717,7 @@
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>1</Pages>
<UniqueValues>11</UniqueValues>
<UniqueValues>12</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
@@ -2449,7 +2449,7 @@
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>1</Pages>
<UniqueValues>7</UniqueValues>
<UniqueValues>11</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
@@ -2526,6 +2526,418 @@
</DbDfnIndex>
</Indices>
</DbDfnTable>
<DbDfnTable>
<Schema>dbo</Schema>
<Name>OrganisationEvent</Name>
<Remarks />
<Columns>
<DbDfnColumn>
<Schema>dbo</Schema>
<Table>OrganisationEvent</Table>
<Pos>1</Pos>
<Name>Id</Name>
<DataType>Int</DataType>
<DataTypeName />
<DataTypeNative>4</DataTypeNative>
<DataTypeNameNative>int</DataTypeNameNative>
<IsIdentity>true</IsIdentity>
<Size>10</Size>
<BufferLen>4</BufferLen>
<DecimalDigits>0</DecimalDigits>
<Nullable>NoNulls</Nullable>
<IsNullable>false</IsNullable>
<Remarks />
</DbDfnColumn>
<DbDfnColumn>
<Schema>dbo</Schema>
<Table>OrganisationEvent</Table>
<Pos>2</Pos>
<Name>OrganisationId</Name>
<DataType>Int</DataType>
<DataTypeName />
<DataTypeNative>4</DataTypeNative>
<DataTypeNameNative>int</DataTypeNameNative>
<IsIdentity>false</IsIdentity>
<Size>10</Size>
<BufferLen>4</BufferLen>
<DecimalDigits>0</DecimalDigits>
<Nullable>NoNulls</Nullable>
<IsNullable>false</IsNullable>
<Remarks />
</DbDfnColumn>
<DbDfnColumn>
<Schema>dbo</Schema>
<Table>OrganisationEvent</Table>
<Pos>3</Pos>
<Name>SportIdPrimary</Name>
<DataType>Int</DataType>
<DataTypeName />
<DataTypeNative>4</DataTypeNative>
<DataTypeNameNative>int</DataTypeNameNative>
<IsIdentity>false</IsIdentity>
<Size>10</Size>
<BufferLen>4</BufferLen>
<DecimalDigits>0</DecimalDigits>
<Nullable>NoNulls</Nullable>
<IsNullable>false</IsNullable>
<Remarks />
</DbDfnColumn>
<DbDfnColumn>
<Schema>dbo</Schema>
<Table>OrganisationEvent</Table>
<Pos>4</Pos>
<Name>RegionIdCountry</Name>
<DataType>Int</DataType>
<DataTypeName />
<DataTypeNative>4</DataTypeNative>
<DataTypeNameNative>int</DataTypeNameNative>
<IsIdentity>false</IsIdentity>
<Size>10</Size>
<BufferLen>4</BufferLen>
<DecimalDigits>0</DecimalDigits>
<Nullable>NoNulls</Nullable>
<IsNullable>false</IsNullable>
<Remarks />
</DbDfnColumn>
<DbDfnColumn>
<Schema>dbo</Schema>
<Table>OrganisationEvent</Table>
<Pos>5</Pos>
<Name>EventAt</Name>
<DataType>DateTime</DataType>
<DataTypeName />
<DataTypeNative>93</DataTypeNative>
<DataTypeNameNative>smalldatetime</DataTypeNameNative>
<IsIdentity>false</IsIdentity>
<Size>16</Size>
<BufferLen>16</BufferLen>
<DecimalDigits>0</DecimalDigits>
<Nullable>NoNulls</Nullable>
<IsNullable>false</IsNullable>
<Remarks />
</DbDfnColumn>
<DbDfnColumn>
<Schema>dbo</Schema>
<Table>OrganisationEvent</Table>
<Pos>6</Pos>
<Name>EventTypeCode</Name>
<DataType>VarChar</DataType>
<DataTypeName />
<DataTypeNative>12</DataTypeNative>
<DataTypeNameNative>varchar</DataTypeNameNative>
<IsIdentity>false</IsIdentity>
<Size>3</Size>
<BufferLen>3</BufferLen>
<DecimalDigits>0</DecimalDigits>
<Nullable>NoNulls</Nullable>
<IsNullable>false</IsNullable>
<Remarks />
</DbDfnColumn>
<DbDfnColumn>
<Schema>dbo</Schema>
<Table>OrganisationEvent</Table>
<Pos>7</Pos>
<Name>About</Name>
<DataType>VarChar</DataType>
<DataTypeName />
<DataTypeNative>-9</DataTypeNative>
<DataTypeNameNative>nvarchar</DataTypeNameNative>
<IsIdentity>false</IsIdentity>
<Size>2000</Size>
<BufferLen>4000</BufferLen>
<DecimalDigits>0</DecimalDigits>
<Nullable>NoNulls</Nullable>
<IsNullable>false</IsNullable>
<Remarks />
</DbDfnColumn>
<DbDfnColumn>
<Schema>dbo</Schema>
<Table>OrganisationEvent</Table>
<Pos>8</Pos>
<Name>EventData</Name>
<DataType>VarChar</DataType>
<DataTypeName />
<DataTypeNative>-9</DataTypeNative>
<DataTypeNameNative>nvarchar</DataTypeNameNative>
<IsIdentity>false</IsIdentity>
<Size>0</Size>
<BufferLen>0</BufferLen>
<DecimalDigits>0</DecimalDigits>
<Nullable>NoNulls</Nullable>
<IsNullable>false</IsNullable>
<Remarks />
</DbDfnColumn>
<DbDfnColumn>
<Schema>dbo</Schema>
<Table>OrganisationEvent</Table>
<Pos>9</Pos>
<Name>PublishedAt</Name>
<DataType>DateTime</DataType>
<DataTypeName />
<DataTypeNative>93</DataTypeNative>
<DataTypeNameNative>smalldatetime</DataTypeNameNative>
<IsIdentity>false</IsIdentity>
<Size>16</Size>
<BufferLen>16</BufferLen>
<DecimalDigits>0</DecimalDigits>
<Nullable>Nullable</Nullable>
<IsNullable>true</IsNullable>
<Remarks />
</DbDfnColumn>
<DbDfnColumn>
<Schema>dbo</Schema>
<Table>OrganisationEvent</Table>
<Pos>10</Pos>
<Name>ExpiresAt</Name>
<DataType>DateTime</DataType>
<DataTypeName />
<DataTypeNative>93</DataTypeNative>
<DataTypeNameNative>smalldatetime</DataTypeNameNative>
<IsIdentity>false</IsIdentity>
<Size>16</Size>
<BufferLen>16</BufferLen>
<DecimalDigits>0</DecimalDigits>
<Nullable>Nullable</Nullable>
<IsNullable>true</IsNullable>
<Remarks />
</DbDfnColumn>
<DbDfnColumn>
<Schema>dbo</Schema>
<Table>OrganisationEvent</Table>
<Pos>11</Pos>
<Name>Notes</Name>
<DataType>VarChar</DataType>
<DataTypeName />
<DataTypeNative>-9</DataTypeNative>
<DataTypeNameNative>nvarchar</DataTypeNameNative>
<IsIdentity>false</IsIdentity>
<Size>2000</Size>
<BufferLen>4000</BufferLen>
<DecimalDigits>0</DecimalDigits>
<Nullable>NoNulls</Nullable>
<IsNullable>false</IsNullable>
<Remarks />
</DbDfnColumn>
<DbDfnColumn>
<Schema>dbo</Schema>
<Table>OrganisationEvent</Table>
<Pos>12</Pos>
<Name>Flags</Name>
<DataType>SmallInt</DataType>
<DataTypeName />
<DataTypeNative>5</DataTypeNative>
<DataTypeNameNative>smallint</DataTypeNameNative>
<IsIdentity>false</IsIdentity>
<Size>5</Size>
<BufferLen>2</BufferLen>
<DecimalDigits>0</DecimalDigits>
<Nullable>NoNulls</Nullable>
<IsNullable>false</IsNullable>
<Remarks />
</DbDfnColumn>
<DbDfnColumn>
<Schema>dbo</Schema>
<Table>OrganisationEvent</Table>
<Pos>13</Pos>
<Name>Status</Name>
<DataType>VarChar</DataType>
<DataTypeName />
<DataTypeNative>12</DataTypeNative>
<DataTypeNameNative>varchar</DataTypeNameNative>
<IsIdentity>false</IsIdentity>
<Size>3</Size>
<BufferLen>3</BufferLen>
<DecimalDigits>0</DecimalDigits>
<Nullable>NoNulls</Nullable>
<IsNullable>false</IsNullable>
<Remarks />
</DbDfnColumn>
<DbDfnColumn>
<Schema>dbo</Schema>
<Table>OrganisationEvent</Table>
<Pos>14</Pos>
<Name>CreateOn</Name>
<DataType>DateTime</DataType>
<DataTypeName />
<DataTypeNative>93</DataTypeNative>
<DataTypeNameNative>datetime</DataTypeNameNative>
<IsIdentity>false</IsIdentity>
<Size>23</Size>
<BufferLen>16</BufferLen>
<DecimalDigits>3</DecimalDigits>
<Nullable>NoNulls</Nullable>
<IsNullable>false</IsNullable>
<Remarks />
</DbDfnColumn>
<DbDfnColumn>
<Schema>dbo</Schema>
<Table>OrganisationEvent</Table>
<Pos>15</Pos>
<Name>CreateBy</Name>
<DataType>Int</DataType>
<DataTypeName />
<DataTypeNative>4</DataTypeNative>
<DataTypeNameNative>int</DataTypeNameNative>
<IsIdentity>false</IsIdentity>
<Size>10</Size>
<BufferLen>4</BufferLen>
<DecimalDigits>0</DecimalDigits>
<Nullable>NoNulls</Nullable>
<IsNullable>false</IsNullable>
<Remarks />
</DbDfnColumn>
<DbDfnColumn>
<Schema>dbo</Schema>
<Table>OrganisationEvent</Table>
<Pos>16</Pos>
<Name>CreateHost</Name>
<DataType>VarChar</DataType>
<DataTypeName />
<DataTypeNative>12</DataTypeNative>
<DataTypeNameNative>varchar</DataTypeNameNative>
<IsIdentity>false</IsIdentity>
<Size>100</Size>
<BufferLen>100</BufferLen>
<DecimalDigits>0</DecimalDigits>
<Nullable>NoNulls</Nullable>
<IsNullable>false</IsNullable>
<Remarks />
</DbDfnColumn>
<DbDfnColumn>
<Schema>dbo</Schema>
<Table>OrganisationEvent</Table>
<Pos>17</Pos>
<Name>UpdateOn</Name>
<DataType>DateTime</DataType>
<DataTypeName />
<DataTypeNative>93</DataTypeNative>
<DataTypeNameNative>datetime</DataTypeNameNative>
<IsIdentity>false</IsIdentity>
<Size>23</Size>
<BufferLen>16</BufferLen>
<DecimalDigits>3</DecimalDigits>
<Nullable>NoNulls</Nullable>
<IsNullable>false</IsNullable>
<Remarks />
</DbDfnColumn>
<DbDfnColumn>
<Schema>dbo</Schema>
<Table>OrganisationEvent</Table>
<Pos>18</Pos>
<Name>UpdateBy</Name>
<DataType>Int</DataType>
<DataTypeName />
<DataTypeNative>4</DataTypeNative>
<DataTypeNameNative>int</DataTypeNameNative>
<IsIdentity>false</IsIdentity>
<Size>10</Size>
<BufferLen>4</BufferLen>
<DecimalDigits>0</DecimalDigits>
<Nullable>NoNulls</Nullable>
<IsNullable>false</IsNullable>
<Remarks />
</DbDfnColumn>
<DbDfnColumn>
<Schema>dbo</Schema>
<Table>OrganisationEvent</Table>
<Pos>19</Pos>
<Name>UpdateHost</Name>
<DataType>VarChar</DataType>
<DataTypeName />
<DataTypeNative>12</DataTypeNative>
<DataTypeNameNative>varchar</DataTypeNameNative>
<IsIdentity>false</IsIdentity>
<Size>100</Size>
<BufferLen>100</BufferLen>
<DecimalDigits>0</DecimalDigits>
<Nullable>NoNulls</Nullable>
<IsNullable>false</IsNullable>
<Remarks />
</DbDfnColumn>
</Columns>
<Indices>
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>OrganisationEvent</Table>
<Name>PK_OrganisationEvent</Name>
<IndexType>1</IndexType>
<Unique>true</Unique>
<Primary>false</Primary>
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>0</Pages>
<UniqueValues>0</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
<Seq>1</Seq>
<Name>Id</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>OrganisationEvent</Table>
<Name>IDX_OrganisationEvent_Country</Name>
<IndexType>3</IndexType>
<Unique>false</Unique>
<Primary>false</Primary>
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>0</Pages>
<UniqueValues>0</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
<Seq>1</Seq>
<Name>RegionIdCountry</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>OrganisationEvent</Table>
<Name>IDX_OrganisationEvent_Organisation</Name>
<IndexType>3</IndexType>
<Unique>false</Unique>
<Primary>false</Primary>
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>0</Pages>
<UniqueValues>0</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
<Seq>1</Seq>
<Name>OrganisationId</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>OrganisationEvent</Table>
<Name>IDX_OrganisationEvent_Sport</Name>
<IndexType>3</IndexType>
<Unique>false</Unique>
<Primary>false</Primary>
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>0</Pages>
<UniqueValues>0</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
<Seq>1</Seq>
<Name>SportIdPrimary</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
</Columns>
</DbDfnIndex>
</Indices>
</DbDfnTable>
<DbDfnTable>
<Schema>dbo</Schema>
<Name>OrganisationOpportunity</Name>
@@ -2866,7 +3278,7 @@
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>1</Pages>
<UniqueValues>4</UniqueValues>
<UniqueValues>5</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
@@ -2891,7 +3303,7 @@
<Columns>
<DbDfnIndexColumn>
<Seq>1</Seq>
<Name>SportIdPrimary</Name>
<Name>RegionIdPrimary</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
</Columns>
@@ -2919,7 +3331,7 @@
<DbDfnIndex>
<Schema>dbo</Schema>
<Table>OrganisationOpportunity</Table>
<Name>IDX_OrganisationOpportunity_Region</Name>
<Name>IDX_OrganisationOpportunity_Sport</Name>
<IndexType>3</IndexType>
<Unique>false</Unique>
<Primary>false</Primary>
@@ -2931,7 +3343,7 @@
<Columns>
<DbDfnIndexColumn>
<Seq>1</Seq>
<Name>RegionIdPrimary</Name>
<Name>SportIdPrimary</Name>
<Ascend>true</Ascend>
</DbDfnIndexColumn>
</Columns>
@@ -4113,7 +4525,7 @@
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>1</Pages>
<UniqueValues>8</UniqueValues>
<UniqueValues>11</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
@@ -4576,7 +4988,7 @@
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>1</Pages>
<UniqueValues>16</UniqueValues>
<UniqueValues>18</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
@@ -4960,7 +5372,7 @@
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>1</Pages>
<UniqueValues>10</UniqueValues>
<UniqueValues>15</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>
@@ -5760,7 +6172,7 @@
<Clustered>false</Clustered>
<Nullable>false</Nullable>
<Pages>1</Pages>
<UniqueValues>9</UniqueValues>
<UniqueValues>14</UniqueValues>
<HasColumns>false</HasColumns>
<Columns>
<DbDfnIndexColumn>