v1.2.1+
This commit is contained in:
@@ -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,71 +137,80 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
|
||||
if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData);
|
||||
RefreshModel(model);
|
||||
|
||||
// Query organisations that user is a member of.
|
||||
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
|
||||
prmUserOrganisation.UserAccountIdsIncluded.Add(SessionData.User.UserAccountId);
|
||||
prmUserOrganisation.OrganisationStatusCat = SaxOrganisation.StatusCat.ActiveOnly;
|
||||
prmUserOrganisation.OrganisationMembersOnly = true;
|
||||
prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.ActiveOnly;
|
||||
List<SaxUserOrganisation> userOrganisations = AccountMgr.GetUserOrganisationList(prmUserOrganisation);
|
||||
List<SysId> organisationIds = userOrganisations.GetOrganisationIds();
|
||||
|
||||
// Item columns.
|
||||
ColumnDfn colId = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Id);
|
||||
ColumnDfn colOrganisationId = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.OrganisationId);
|
||||
ColumnDfn colOrganisationName = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_Name);
|
||||
ColumnDfn colOrganisationSportId = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_SportId);
|
||||
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);
|
||||
ColumnDfn colStatus = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Status);
|
||||
ColumnDfn colCreatedOn = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.CreateOn_Date);
|
||||
ColumnDfn colRoleCodes = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.OrganisationRoleCodes);
|
||||
List<ColumnDfn> columns = new List<ColumnDfn>()
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposableItems = new DisposableCollection<SacsHierarchyItem>())
|
||||
{
|
||||
colId, colOrganisationId , colOrganisationName,
|
||||
colOrganisationSportId, colOrganisationSportName,
|
||||
colOrganisationRegionId, colOrganisationRegionName,
|
||||
colMemberCount, colOpportunityCount,
|
||||
colStatus, colStatus, colCreatedOn,
|
||||
colRoleCodes
|
||||
};
|
||||
|
||||
// Sort columns.
|
||||
colCreatedOn.SortAscending = false;
|
||||
prmUserOrganisation.SortColumns.Add(colOrganisationName);
|
||||
// Query organisations that user is a member of.
|
||||
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
|
||||
prmUserOrganisation.UserAccountIdsIncluded.Add(UserAccountId);
|
||||
prmUserOrganisation.OrganisationStatusCat = SaxOrganisation.StatusCat.ActiveOnly;
|
||||
prmUserOrganisation.OrganisationMembersOnly = true;
|
||||
prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.ActiveOnly;
|
||||
List<SaxUserOrganisation> userOrganisations = AccountMgr.GetUserOrganisationList(prmUserOrganisation);
|
||||
List<SysId> organisationIds = userOrganisations.GetOrganisationIds();
|
||||
|
||||
// Query items.
|
||||
using (DbResultSet resultSet = AccountMgr.ExecuteUserOrganisationQuery(columns, prmUserOrganisation))
|
||||
{
|
||||
while (resultSet != null && resultSet.HasRows && resultSet.NextRecord())
|
||||
// Item columns.
|
||||
// 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 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 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);
|
||||
ColumnDfn colStatus = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Status);
|
||||
ColumnDfn colCreatedOn = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.CreateOn_Date);
|
||||
ColumnDfn colRoleCodes = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.OrganisationRoleCodes);
|
||||
List<ColumnDfn> columns = new List<ColumnDfn>()
|
||||
{
|
||||
NamedValue.Map values = resultSet.GetRecordValues();
|
||||
List<String> roleCodes = StringListUtil.Split(values.GetString(colRoleCodes.DataName), ",");
|
||||
ProfileOrganisationData organisationData = new ProfileOrganisationData()
|
||||
colId, colOrganisationName, colOrganisationCategory, colOrganisationType,
|
||||
colOrganisationSportName, colOrganisationRegionName,
|
||||
colMemberCount, colOpportunityCount,
|
||||
colStatus, colStatus, colCreatedOn,
|
||||
colRoleCodes
|
||||
};
|
||||
|
||||
// Sort columns.
|
||||
colCreatedOn.SortAscending = false;
|
||||
prmUserOrganisation.SortColumns.Add(colOrganisationName);
|
||||
|
||||
// Query items.
|
||||
using (DbResultSet resultSet = AccountMgr.ExecuteUserOrganisationQuery(columns, prmUserOrganisation))
|
||||
{
|
||||
while (resultSet != null && resultSet.HasRows && resultSet.NextRecord())
|
||||
{
|
||||
Id = values.GetLong(colId.DataName),
|
||||
Name = values.GetString(colOrganisationName.DataName),
|
||||
SportId = values.GetLong(colOrganisationSportId.DataName),
|
||||
SportName = values.GetString(colOrganisationSportName.DataName),
|
||||
RegionId = values.GetLong(colOrganisationRegionId.DataName),
|
||||
RegionName = values.GetString(colOrganisationRegionName.DataName),
|
||||
MemberCount = values.GetLong(colMemberCount.DataName),
|
||||
OpportunityCount = values.GetLong(colOpportunityCount.DataName)
|
||||
};
|
||||
if (roleCodes.ContainsCI(OrganisationRoleCodes.GetCodeForType(Sax.OrganisationRole.Admin)))
|
||||
organisationData.Admin = true;
|
||||
if (roleCodes.ContainsCI(OrganisationRoleCodes.GetCodeForType(Sax.OrganisationRole.MemberAdmin)))
|
||||
organisationData.MemberAdmin = true;
|
||||
if (roleCodes.ContainsCI(OrganisationRoleCodes.GetCodeForType(Sax.OrganisationRole.OpportunityAdmin)))
|
||||
organisationData.OpportunitiyAdmin = true;
|
||||
if (roleCodes.ContainsCI(OrganisationRoleCodes.GetCodeForType(Sax.OrganisationRole.ScheduleAdmin)))
|
||||
organisationData.ScheduleAdmin = true;
|
||||
if (roleCodes.ContainsCI(OrganisationRoleCodes.GetCodeForType(Sax.OrganisationRole.ArticleAdmin)))
|
||||
organisationData.ArticleAdmin = true;
|
||||
responseData.Organisations.Add(organisationData);
|
||||
NamedValue.Map values = resultSet.GetRecordValues();
|
||||
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 = model.EncryptId(new SysId(values.GetLong(colId.DataName))),
|
||||
Name = values.GetString(colOrganisationName.DataName),
|
||||
CategoryDesc = Localiser.GetOrganisationCategoryCaption(organisationCategory),
|
||||
TypeDesc = Localiser.GetOrganisationTypeCaption(organisationType),
|
||||
//SportId = model.EncryptId(new SysId(values.GetLong(colOrganisationSportId.DataName))),
|
||||
SportName = values.GetString(colOrganisationSportName.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)))
|
||||
organisationData.MemberAdmin = true;
|
||||
if (roleCodes.ContainsCI(OrganisationRoleCodes.GetCodeForType(Sax.OrganisationRole.OpportunityAdmin)))
|
||||
organisationData.OpportunitiyAdmin = true;
|
||||
if (roleCodes.ContainsCI(OrganisationRoleCodes.GetCodeForType(Sax.OrganisationRole.ScheduleAdmin)))
|
||||
organisationData.ScheduleAdmin = true;
|
||||
if (roleCodes.ContainsCI(OrganisationRoleCodes.GetCodeForType(Sax.OrganisationRole.ArticleAdmin)))
|
||||
organisationData.ArticleAdmin = true;
|
||||
responseData.Organisations.Add(organisationData);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (model.Paging.IsPaged)
|
||||
@@ -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.
|
||||
|
||||
+4
-4
@@ -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);
|
||||
|
||||
+43
-40
@@ -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);
|
||||
|
||||
// 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))
|
||||
// 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.
|
||||
SaxOrganisationOpportunity opportunity = ActivityMgr.GetOrganisationOpportunityById(opportunityId);
|
||||
disposableItems.Add(opportunity);
|
||||
if (opportunity == null)
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve Organisation Opportunity for Id: '" + model.OpportunityId + "'");
|
||||
@@ -264,20 +268,19 @@ 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)
|
||||
{
|
||||
if (organisation == null || !organisation.IsStatusActive)
|
||||
{
|
||||
SaLogger.Warn(fn + " " + (organisation == null ? "Invalid" : "Inactive") + " organisation for Opportunity. OrganisationId: '" + opportunity.OrganisationId + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
|
||||
// Make a note of the selected Organisation.
|
||||
SessionData_Online.Filter.SetMemberOrganisation(organisation);
|
||||
|
||||
// Construct response.
|
||||
PopulateOpportunityResponseData(model, opportunity, responseData.Opportunity);
|
||||
SaLogger.Warn(fn + " " + (organisation == null ? "Invalid" : "Inactive") + " organisation for Opportunity. OrganisationId: '" + opportunity.OrganisationId + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
|
||||
// Make a note of the selected Organisation.
|
||||
SessionData_Online.Filter.SetMemberOrganisation(organisation);
|
||||
|
||||
// Construct response.
|
||||
PopulateOpportunityResponseData(model, opportunity, responseData.Opportunity);
|
||||
}
|
||||
|
||||
// Complete response.
|
||||
@@ -301,29 +304,29 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
|
||||
if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData);
|
||||
RefreshModel(model);
|
||||
|
||||
// Validate item properties.
|
||||
model.ValidateOpportunityData(responseData);
|
||||
if (responseData.HasControlErrors())
|
||||
return Json(responseData);
|
||||
|
||||
// Validate Opportunity against Id against 'Exists' flag.
|
||||
SysId opportunityId = model.ExtractSysId(model.OpportunityId);
|
||||
bool opportunityExists = StringUtil.ToBool(model.OpportunityExists);
|
||||
if (opportunityExists && !SysId.IsValid(opportunityId))
|
||||
{
|
||||
SaLogger.Warn(fn + " Id not specified for existing Opportunity.");
|
||||
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
if (!opportunityExists && SysId.IsValid(opportunityId))
|
||||
{
|
||||
SaLogger.Warn(fn + " Id specified for new Opportunity: '" + model.OpportunityId + "'");
|
||||
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>())
|
||||
{
|
||||
|
||||
// Validate item properties.
|
||||
model.ValidateOpportunityData(responseData);
|
||||
if (responseData.HasControlErrors())
|
||||
return Json(responseData);
|
||||
|
||||
// Validate Opportunity against Id against 'Exists' flag.
|
||||
SysId opportunityId = model.ExtractSysId(model.OpportunityId);
|
||||
bool opportunityExists = StringUtil.ToBool(model.OpportunityExists);
|
||||
if (opportunityExists && !SysId.IsValid(opportunityId))
|
||||
{
|
||||
SaLogger.Warn(fn + " Id not specified for existing Opportunity.");
|
||||
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
if (!opportunityExists && SysId.IsValid(opportunityId))
|
||||
{
|
||||
SaLogger.Warn(fn + " Id specified for new Opportunity: '" + model.OpportunityId + "'");
|
||||
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
|
||||
// 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,140 +44,163 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
|
||||
if (!ValidReferer) return Forbid();
|
||||
SaxSessionData_Online sessionData = SessionData_Online;
|
||||
|
||||
if (!model.ValidateOrganisationRequestData(responseData))
|
||||
return Json(responseData);
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposableItems = new DisposableCollection<SacsHierarchyItem>())
|
||||
{
|
||||
|
||||
// Check Regions.
|
||||
SysId regionIdCountry = model.ExtractSysId(model.OrganisationRegionIdCountry);
|
||||
SaxRegion.Data regionCountry = Internals.GetRegion(regionIdCountry);
|
||||
if (SysId.IsValid(regionIdCountry) && regionCountry == null)
|
||||
{
|
||||
SaLogger.Warn(fn + " Country region not found. Id: " + model.OrganisationRegionIdCountry + ". " + GetLogSuffix());
|
||||
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
SysId regionIdAddressProvince= model.ExtractSysId(model.OrganisationAddressRegionIdProvince);
|
||||
SaxRegion.Data regionProvince = Internals.GetRegion(regionIdAddressProvince);
|
||||
if (SysId.IsValid(regionIdAddressProvince) && regionProvince == null)
|
||||
{
|
||||
SaLogger.Warn(fn + " Province region not found. Id: " + model.OrganisationAddressRegionIdProvince + ". " + GetLogSuffix());
|
||||
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
if (!model.ValidateOrganisationRequestData(responseData))
|
||||
return Json(responseData);
|
||||
|
||||
// User does not need to be logged in, but user details must be supplied if not.
|
||||
SaxUserAccount userAccount = null;
|
||||
if (ValidUserSession)
|
||||
{
|
||||
// Check that an email address hasn't been supplied.
|
||||
// NB Shouldn't happen as contact controls aren't displayed if user is logged in,
|
||||
// hence 'System' error response and nothing more specific.
|
||||
if (!StringUtil.IsEmpty(model.ContactEmailAddress))
|
||||
// Check Regions.
|
||||
SysId regionIdCountry = model.ExtractSysId(model.Organisation.RegionIdCountry);
|
||||
SaxRegion.Data regionCountry = Internals.GetRegion(regionIdCountry);
|
||||
if (SysId.IsValid(regionIdCountry) && regionCountry == null)
|
||||
{
|
||||
SaLogger.Warn(fn + " Contact Email supplied when user logged in. " + GetLogSuffix());
|
||||
SaLogger.Warn(fn + " Country region not found. Id: " + model.Organisation.RegionIdCountry + ". " + GetLogSuffix());
|
||||
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
// Retrieve user account.
|
||||
userAccount = AccountMgr.GetUserAccountById(sessionData.User.UserAccountId);
|
||||
if (userAccount == null)
|
||||
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Double check that contact details have been supplied - validated by model above.
|
||||
if (StringUtil.IsEmpty(model.ContactEmailAddress) || StringUtil.IsEmpty(model.ContactFirstName) || StringUtil.IsEmpty(model.ContactLastName))
|
||||
SysId regionIdAddressProvince = model.ExtractSysId(model.Organisation.Address.RegionIdProvince);
|
||||
SaxRegion.Data regionProvince = Internals.GetRegion(regionIdAddressProvince);
|
||||
if (SysId.IsValid(regionIdAddressProvince) && regionProvince == null)
|
||||
{
|
||||
SaLogger.Warn(fn + " Incomplete contact details supplied.");
|
||||
SaLogger.Warn(fn + " Province region not found. Id: " + model.Organisation.Address.RegionIdProvince + ". " + GetLogSuffix());
|
||||
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
// 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);
|
||||
if (userAccount != null)
|
||||
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
|
||||
userAccount = AccountMgr.CreateUserAccount();
|
||||
userAccount.EmailAddress = model.ContactEmailAddress;
|
||||
userAccount.FirstName = model.ContactFirstName;
|
||||
userAccount.LastName = model.ContactLastName;
|
||||
if (!AccountMgr.InsertUserAccount(userAccount, DbUpdateInfo))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to insert user contact - " + AccountMgr.ErrorStateMessage);
|
||||
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
}
|
||||
|
||||
SysId organisationSportId = model.ExtractSysId(model.OrganisationSportId);
|
||||
if (SysId.IsValid(organisationSportId))
|
||||
{
|
||||
// Add User Sport if not already present.
|
||||
// NB This will also reactivate an inactive or deleted User Sport.
|
||||
SaxUserSport.Params prmUserSport = new SaxUserSport.Params();
|
||||
prmUserSport.UserAccountIdsIncluded.Add(userAccount.Id);
|
||||
prmUserSport.SportIdsIncluded.Add(organisationSportId);
|
||||
prmUserSport.StatusCat = SaxUserSport.StatusCat.Any;
|
||||
SaxUserSport userSport = AccountMgr.GetUserSport(prmUserSport);
|
||||
if (userSport == null)
|
||||
userSport = AccountMgr.CreateUserSport(userAccount.Id, organisationSportId);
|
||||
userSport.Status = SaxUserSport.DefaultStatus;
|
||||
if (!SysId.IsValid(userSport.Id))
|
||||
// User does not need to be logged in, but user details must be supplied if not.
|
||||
SaxUserAccount userAccount = null;
|
||||
if (ValidUserSession)
|
||||
{
|
||||
if (!AccountMgr.InsertUserSport(userSport, DbUpdateInfo))
|
||||
// Check that an email address hasn't been supplied.
|
||||
// NB Shouldn't happen as contact controls aren't displayed if user is logged in,
|
||||
// hence 'System' error response and nothing more specific.
|
||||
if (!StringUtil.IsEmpty(model.ContactEmailAddress))
|
||||
{
|
||||
// Logg error but don't abort the request.
|
||||
SaLogger.Warn(fn + " Failed to insert User Sport: " + AccountMgr.ErrorStateMessage);
|
||||
SaLogger.Warn(fn + " Contact Email supplied when user logged in. " + GetLogSuffix());
|
||||
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
// Retrieve user account.
|
||||
userAccount = AccountMgr.GetUserAccountById(sessionData.User.UserAccountId);
|
||||
disposableItems.Add(userAccount);
|
||||
if (userAccount == null)
|
||||
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!AccountMgr.UpdateUserSport(userSport, DbUpdateInfo))
|
||||
// Double check that contact details have been supplied - validated by model above.
|
||||
if (StringUtil.IsEmpty(model.ContactEmailAddress) || StringUtil.IsEmpty(model.ContactFirstName) || StringUtil.IsEmpty(model.ContactLastName))
|
||||
{
|
||||
// Logg error but don't abort the request.
|
||||
SaLogger.Warn(fn + " Failed to update User Sport: " + AccountMgr.ErrorStateMessage);
|
||||
SaLogger.Warn(fn + " Incomplete contact details supplied.");
|
||||
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
// 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();
|
||||
userAccount.EmailAddress = model.ContactEmailAddress;
|
||||
userAccount.FirstName = model.ContactFirstName;
|
||||
userAccount.LastName = model.ContactLastName;
|
||||
if (!AccountMgr.InsertUserAccount(userAccount, DbUpdateInfo))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to insert user contact - " + AccountMgr.ErrorStateMessage);
|
||||
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create Organisation.
|
||||
SaxOrganisation organisation = AccountMgr.CreateOrganisation();
|
||||
organisation.Name = model.OrganisationName;
|
||||
organisation.OrganisationType = model.GetOrganisationType();
|
||||
organisation.OrganisationCategory = model.GetOrganisationCategory();
|
||||
organisation.SportIdPrimary = organisationSportId;
|
||||
organisation.RegionIdPrimary = model.ExtractSysId(model.OrganisationRegionIdCountry);
|
||||
organisation.PhoneMain = model.OrganisationPhoneMain;
|
||||
organisation.Status = SaStatus.Awaiting;
|
||||
if (!AccountMgr.InsertOrganisation(organisation, DbUpdateInfo))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to insert organisation - " + AccountMgr.ErrorStateMessage);
|
||||
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
SysId organisationSportId = model.ExtractSysId(model.Organisation.SportId);
|
||||
if (SysId.IsValid(organisationSportId))
|
||||
{
|
||||
// Add User Sport if not already present.
|
||||
// NB This will also reactivate an inactive or deleted User Sport.
|
||||
SaxUserSport.Params prmUserSport = new SaxUserSport.Params();
|
||||
prmUserSport.UserAccountIdsIncluded.Add(userAccount.Id);
|
||||
prmUserSport.SportIdsIncluded.Add(organisationSportId);
|
||||
prmUserSport.StatusCat = SaxUserSport.StatusCat.Any;
|
||||
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))
|
||||
{
|
||||
if (!AccountMgr.InsertUserSport(userSport, DbUpdateInfo))
|
||||
{
|
||||
// Logg error but don't abort the request.
|
||||
SaLogger.Warn(fn + " Failed to insert User Sport: " + AccountMgr.ErrorStateMessage);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!AccountMgr.UpdateUserSport(userSport, DbUpdateInfo))
|
||||
{
|
||||
// Logg error but don't abort the request.
|
||||
SaLogger.Warn(fn + " Failed to update User Sport: " + AccountMgr.ErrorStateMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add user as member of organisation.
|
||||
SaxUserOrganisation userOrganisation = AccountMgr.CreateUserOrganisation(userAccount.Id, organisation.Id);
|
||||
userOrganisation.OrganisationRoles = new [] { Sax.OrganisationRole.Member, Sax.OrganisationRole.Admin };
|
||||
if (!AccountMgr.InsertUserOrganisation(userOrganisation, DbUpdateInfo))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to insert user organisation - " + AccountMgr.ErrorStateMessage);
|
||||
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
// Create Organisation.
|
||||
SaxOrganisation organisation = AccountMgr.CreateOrganisation();
|
||||
disposableItems.Add(organisation);
|
||||
organisation.Name = model.Organisation.Name;
|
||||
organisation.OrganisationType = model.Organisation.GetOrganisationType();
|
||||
organisation.OrganisationCategory = model.Organisation.GetOrganisationCategory();
|
||||
organisation.SportIdPrimary = organisationSportId;
|
||||
organisation.RegionIdPrimary = regionIdCountry;
|
||||
organisation.PhoneMain = model.Organisation.PhoneMain;
|
||||
organisation.Status = SaStatus.Awaiting;
|
||||
if (!AccountMgr.InsertOrganisation(organisation, DbUpdateInfo))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to insert organisation - " + AccountMgr.ErrorStateMessage);
|
||||
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
|
||||
// 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))
|
||||
{
|
||||
organisationAddress.Country = regionCountry.Name;
|
||||
organisationAddress.RegionIdCountry = regionCountry.Id;
|
||||
}
|
||||
else organisationAddress.Country = model.OrganisationAddressCountry;
|
||||
organisationAddress.PostalCode = model.OrganisationAddressPostalCode;
|
||||
if (!ItemDataMgr.InsertItemAddress(organisationAddress, DbUpdateInfo))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to insert organisation address - " + ItemDataMgr.ErrorStateMessage);
|
||||
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
|
||||
// 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))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to insert user organisation - " + AccountMgr.ErrorStateMessage);
|
||||
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
|
||||
// Create Organisation address.
|
||||
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
|
||||
{
|
||||
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.
|
||||
|
||||
@@ -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"]: <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;" }))
|
||||
{
|
||||
}
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@* 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>
|
||||
|
||||
@* 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"> *</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"> *</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"> *</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"> (*)</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"> *</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"> *</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"> *</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"> *</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"> *</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"> *</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"> (*)</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"> *</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"> *</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"> *</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); });
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
//--------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user