Files
andy 9f22b522df v1.3.0 Restructure Saxonite workspace and upgrade to .NET 10 (#1)
Move Saxonite’s projects into a dedicated `Workspace` folder and align the solution with .NET 10 and the current Common workspace. Update encryption integration, test project structure and coverage, and repository guidance and upgrade notes.

- Relocate application and library projects while retaining Git rename history.
- Split tests into Admin, Online, and Shared projects; add representative behavioral and serialization tests.
- Update Common integration, application version, and repository documentation.

Application version: 1.3.0

Reviewed-on: #1
Co-authored-by: andy <andy@sarand.com>
2026-10-16 18:24:16 +01:00

345 lines
17 KiB
C#

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.App;
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 - Ajax actions.
//=======================================================================
partial class OrganisationController
{
//-------------------------------------------------------------------
// Organisation data.
private class OrganisationListData : AjaxResponse_Data.ItemData_Base
{
public String Name { get; set; }
public String RegionId { get; set; }
public String RegionName { get; set; }
public String SportId { get; set; }
public String SportName { get; set; }
public String LogoUrl { get; set; }
}
//-------------------------------------------------------------------
// Get Organisation List ajax request.
//-------------------------------------------------------------------
private class AjaxResponse_OrganisationList : AjaxResponse_Data
{
// Construction.
public AjaxResponse_OrganisationList(SaxModel_Online model) : base(model) { }
// Organisation list.
public List<OrganisationListData> Organisations { get; } = new List<OrganisationListData>();
}
//-------------------------------------------------------------------
[HttpPost]
[Route("Organisation/Ajax/GetOrganisationList")]
public IActionResult Ajax_GetOrganisationList(Model_Organisation model)
{
String fn = GetType().Name + ".Ajax_GetOrganisationList";
String messageTitle = Localiser["organisation.caption.organisations"];
AjaxResponse_OrganisationList responseData = new AjaxResponse_OrganisationList(model);
// Validate session and referrer.
if (!ValidReferer) return Forbid();
if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData);
RefreshModel(model);
// Query columns.
ColumnDfn colOrganisationId = AccountMgr.GetOrganisationColumnDfn(SaxOrganisation.Column.Id);
ColumnDfn colOrganisationName = AccountMgr.GetOrganisationColumnDfn(SaxOrganisation.Column.Name);
ColumnDfn colRegionId = AccountMgr.GetOrganisationColumnDfn(SaxOrganisation.Column.RegionId);
ColumnDfn colRegionName = AccountMgr.GetOrganisationColumnDfn(SaxOrganisation.Column.Region_Name);
ColumnDfn colSportId = AccountMgr.GetOrganisationColumnDfn(SaxOrganisation.Column.SportId);
ColumnDfn colSportName = AccountMgr.GetOrganisationColumnDfn(SaxOrganisation.Column.Sport_Name);
ColumnDfn colLogoCount = AccountMgr.GetOrganisationColumnDfn(SaxOrganisation.Column.LogoImage_Count);
List<ColumnDfn> columns = new List<ColumnDfn>()
{
colOrganisationId, colOrganisationName,
colRegionId, colRegionName,
colSportId, colSportName,
colLogoCount
};
// Organisation filter.
SaxOrganisation.Params prmOrganisation = new SaxOrganisation.Params();
prmOrganisation.OrganisationFilter = model.Filter.Organisation;
prmOrganisation.RegionIdsIncluded.AddId(model.ExtractSysId(model.Filter.RegionId));
prmOrganisation.SportIdsIncluded.AddId(model.ExtractSysId(model.Filter.SportId));
prmOrganisation.StatusCat = SaxOrganisation.StatusCat.ActiveOnly;
prmOrganisation.SortColumns.Add(colOrganisationName);
model.Paging.ItemTotal = (ulong)AccountMgr.GetOrganisationCount(prmOrganisation);
model.PopulatePagingTo(prmOrganisation.ResultsPaging);
using (DbResultSet resultSet = AccountMgr.ExecuteOrganisationQuery(columns, prmOrganisation))
{
while (resultSet != null && resultSet.HasRows && resultSet.NextRecord())
{
NamedValue.Map values = resultSet.GetRecordValues();
SysId organisationId = new SysId(values.GetLong(colOrganisationId.DataName));
OrganisationListData organisationData = new OrganisationListData()
{
Id = model.EncryptId(organisationId),
Name = values.GetString(colOrganisationName.DataName),
RegionId = model.EncryptId(new SysId(values.GetLong(colRegionId.DataName))),
RegionName = values.GetString(colRegionName.DataName),
SportId = model.EncryptId(new SysId(values.GetLong(colSportId.DataName))),
SportName = values.GetString(colSportName.DataName),
};
// Logo.
if (values.GetLong(colLogoCount.DataName) > 0)
organisationData.LogoUrl = GetOrganisationLogoLink(organisationId, false);
// Add item to the list.
responseData.Organisations.Add(organisationData);
}
}
if (model.Paging.IsPaged)
model.Paging.ItemCount = (ushort)responseData.Organisations.Count;
// Complete response.
responseData.SetPaging(model);
responseData.Success = true;
return Json(responseData);
}
//-------------------------------------------------------------------
// Get Member Admin Organisation List ajax request.
//-------------------------------------------------------------------
private class AjaxResponse_MemberAdminOrganisationList : AjaxResponse_Data
{
// Construction.
public AjaxResponse_MemberAdminOrganisationList(SaxModel_Online model) : base(model) { }
// Organisation list.
public List<OrganisationListData> Organisations { get; } = new List<OrganisationListData>();
}
//-------------------------------------------------------------------
[HttpPost]
[Route("Organisation/Ajax/GetMemberAdminOrganisationList")]
public IActionResult Ajax_GetMemberAdminOrganisationList(Model_Organisation model)
{
String fn = GetType().Name + ".Ajax_GetMemberAdminOrganisationList";
String messageTitle = Localiser["organisation.caption.organisations"];
AjaxResponse_MemberAdminOrganisationList responseData = new AjaxResponse_MemberAdminOrganisationList(model);
// Validate session and referrer.
if (!ValidReferer) return Forbid();
if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData);
RefreshModel(model);
// Query columns.
ColumnDfn colOrganisationId = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.OrganisationId);
ColumnDfn colOrganisationName = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_Name);
ColumnDfn colRegionId = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_RegionId);
ColumnDfn colRegionName = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_Region_Name);
ColumnDfn colSportId = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_SportId);
ColumnDfn colSportName = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_Sport_Name);
List<ColumnDfn> columns = new List<ColumnDfn>()
{
colOrganisationId, colOrganisationName,
colRegionId, colRegionName,
colSportId, colSportName
};
// Organisation filter
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
prmUserOrganisation.UserAccountIdsIncluded.Add(SessionUserAccountId);
prmUserOrganisation.OrganisationStatusCat = SaxOrganisation.StatusCat.ActiveOnly;
prmUserOrganisation.OrganisationMembersOnly = true;
prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.Admin);
prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.MemberAdmin);
prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.ActiveOnly;
prmUserOrganisation.SortColumns.Add(colOrganisationName);
model.Paging.ItemTotal = (ulong)AccountMgr.GetUserOrganisationCount(prmUserOrganisation);
model.PopulatePagingTo(prmUserOrganisation.ResultsPaging);
using (DbResultSet resultSet = AccountMgr.ExecuteUserOrganisationQuery(columns, prmUserOrganisation))
{
while (resultSet != null && resultSet.HasRows && resultSet.NextRecord())
{
NamedValue.Map values = resultSet.GetRecordValues();
OrganisationListData organisationData = new OrganisationListData()
{
Id = model.EncryptId(new SysId(values.GetLong(colOrganisationId.DataName))),
Name = values.GetString(colOrganisationName.DataName),
RegionId = model.EncryptId(new SysId(values.GetLong(colRegionId.DataName))),
RegionName = values.GetString(colRegionName.DataName),
SportId = model.EncryptId(new SysId(values.GetLong(colSportId.DataName))),
SportName = values.GetString(colSportName.DataName),
};
responseData.Organisations.Add(organisationData);
}
}
if (model.Paging.IsPaged)
model.Paging.ItemCount = (ushort)responseData.Organisations.Count;
// Complete response.
responseData.SetPaging(model);
responseData.Success = true;
return Json(responseData);
}
//-------------------------------------------------------------------
// Get Event Admin Organisation List ajax request.
//-------------------------------------------------------------------
private class AjaxResponse_EventAdminOrganisationList : AjaxResponse_Data
{
// Construction.
public AjaxResponse_EventAdminOrganisationList(SaxModel_Online model) : base(model) { }
// Organisation list.
public List<OrganisationListData> Organisations { get; } = new List<OrganisationListData>();
}
//-------------------------------------------------------------------
[HttpPost]
[Route("Organisation/Ajax/GetEventAdminOrganisationList")]
public IActionResult Ajax_GetEventAdminOrganisationList(Model_Organisation model)
{
String fn = GetType().Name + ".Ajax_GetEventAdminOrganisationList";
String messageTitle = Localiser["organisation.caption.organisations"];
AjaxResponse_EventAdminOrganisationList responseData = new AjaxResponse_EventAdminOrganisationList(model);
// Validate session and referrer.
if (!ValidReferer) return Forbid();
if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData);
RefreshModel(model);
// Query columns.
ColumnDfn colOrganisationId = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.OrganisationId);
ColumnDfn colOrganisationName = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_Name);
ColumnDfn colRegionId = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_RegionId);
ColumnDfn colRegionName = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_Region_Name);
ColumnDfn colSportId = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_SportId);
ColumnDfn colSportName = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_Sport_Name);
List<ColumnDfn> columns = new List<ColumnDfn>()
{
colOrganisationId, colOrganisationName,
colRegionId, colRegionName,
colSportId, colSportName
};
// Organisation filter
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
prmUserOrganisation.UserAccountIdsIncluded.Add(SessionUserAccountId);
prmUserOrganisation.OrganisationStatusCat = SaxOrganisation.StatusCat.ActiveOnly;
prmUserOrganisation.OrganisationMembersOnly = true;
prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.Admin);
prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.ScheduleAdmin);
prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.ActiveOnly;
prmUserOrganisation.SortColumns.Add(colOrganisationName);
model.Paging.ItemTotal = (ulong)AccountMgr.GetUserOrganisationCount(prmUserOrganisation);
model.PopulatePagingTo(prmUserOrganisation.ResultsPaging);
using (DbResultSet resultSet = AccountMgr.ExecuteUserOrganisationQuery(columns, prmUserOrganisation))
{
while (resultSet != null && resultSet.HasRows && resultSet.NextRecord())
{
NamedValue.Map values = resultSet.GetRecordValues();
OrganisationListData organisationData = new OrganisationListData()
{
Id = model.EncryptId(new SysId(values.GetLong(colOrganisationId.DataName))),
Name = values.GetString(colOrganisationName.DataName),
RegionId = model.EncryptId(new SysId(values.GetLong(colRegionId.DataName))),
RegionName = values.GetString(colRegionName.DataName),
SportId = model.EncryptId(new SysId(values.GetLong(colSportId.DataName))),
SportName = values.GetString(colSportName.DataName),
};
responseData.Organisations.Add(organisationData);
}
}
if (model.Paging.IsPaged)
model.Paging.ItemCount = (ushort)responseData.Organisations.Count;
// Complete response.
responseData.SetPaging(model);
responseData.Success = true;
return Json(responseData);
}
//-------------------------------------------------------------------
// Get Opportunity Admin Organisation List ajax request.
//-------------------------------------------------------------------
private class AjaxResponse_OpportunityAdminOrganisationList : AjaxResponse_Data
{
// Construction.
public AjaxResponse_OpportunityAdminOrganisationList(SaxModel_Online model) : base(model) { }
// Organisation list.
public List<OrganisationListData> Organisations { get; } = new List<OrganisationListData>();
}
//-------------------------------------------------------------------
[HttpPost]
[Route("Organisation/Ajax/GetOpportunityAdminOrganisationList")]
public IActionResult Ajax_GetOpportunityAdminOrganisationList(Model_Organisation model)
{
String fn = GetType().Name + ".Ajax_GetOpportunityAdminOrganisationList";
String messageTitle = Localiser["organisation.caption.organisations"];
AjaxResponse_OpportunityAdminOrganisationList responseData = new AjaxResponse_OpportunityAdminOrganisationList(model);
// Validate session and referrer.
if (!ValidReferer) return Forbid();
if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData);
RefreshModel(model);
// Query columns.
ColumnDfn colOrganisationId = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.OrganisationId);
ColumnDfn colOrganisationName = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_Name);
ColumnDfn colRegionId = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_RegionId);
ColumnDfn colRegionName = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_Region_Name);
ColumnDfn colSportId = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_SportId);
ColumnDfn colSportName = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_Sport_Name);
List<ColumnDfn> columns = new List<ColumnDfn>()
{
colOrganisationId, colOrganisationName,
colRegionId, colRegionName,
colSportId, colSportName
};
// Organisation filter
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
prmUserOrganisation.UserAccountIdsIncluded.Add(SessionUserAccountId);
prmUserOrganisation.OrganisationStatusCat = SaxOrganisation.StatusCat.ActiveOnly;
prmUserOrganisation.OrganisationMembersOnly = true;
prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.Admin);
prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.OpportunityAdmin);
prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.ActiveOnly;
prmUserOrganisation.SortColumns.Add(colOrganisationName);
model.Paging.ItemTotal = (ulong)AccountMgr.GetUserOrganisationCount(prmUserOrganisation);
model.PopulatePagingTo(prmUserOrganisation.ResultsPaging);
using (DbResultSet resultSet = AccountMgr.ExecuteUserOrganisationQuery(columns, prmUserOrganisation))
{
while (resultSet != null && resultSet.HasRows && resultSet.NextRecord())
{
NamedValue.Map values = resultSet.GetRecordValues();
OrganisationListData organisationData = new OrganisationListData()
{
Id = model.EncryptId(new SysId(values.GetLong(colOrganisationId.DataName))),
Name = values.GetString(colOrganisationName.DataName),
RegionId = model.EncryptId(new SysId(values.GetLong(colRegionId.DataName))),
RegionName = values.GetString(colRegionName.DataName),
SportId = model.EncryptId(new SysId(values.GetLong(colSportId.DataName))),
SportName = values.GetString(colSportName.DataName),
};
responseData.Organisations.Add(organisationData);
}
}
if (model.Paging.IsPaged)
model.Paging.ItemCount = (ushort)responseData.Organisations.Count;
// Complete response.
responseData.SetPaging(model);
responseData.Success = true;
return Json(responseData);
}
//-------------------------------------------------------------------
}
//=======================================================================
}