1.2.11.9 Golf Countries & Provinces

This commit is contained in:
2024-06-17 18:16:02 +01:00
parent dedea84691
commit 1c77a2b2e9
43 changed files with 2256 additions and 182 deletions
@@ -7,7 +7,7 @@ using Saxonite.Net.Standard.Base.App;
using Saxonite.Net.Standard.Base.Helpers;
using System;
namespace Saxonite.Net.Core.Web.Admin.Controllers
namespace Saxonite.Net.Core.Web.Admin.Controllers.Reference
{
//=======================================================================
// Admin Reference Controller - Contact Method Ajax actions only.
@@ -12,7 +12,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Saxonite.Net.Core.Web.Admin.Controllers
namespace Saxonite.Net.Core.Web.Admin.Controllers.Reference
{
//=======================================================================
// Admin Reference Controller - Ajax actions only.
@@ -13,7 +13,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Saxonite.Net.Core.Web.Admin.Controllers
namespace Saxonite.Net.Core.Web.Admin.Controllers.Reference
{
//=======================================================================
// Reference Golf Controller - Ajax requests.
@@ -21,33 +21,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
partial class ReferenceGolfController
{
//-------------------------------------------------------------------
// USGA Country data.
private class UsgaCountryListData : AjaxResponse_Data.ItemData_Base
{
public String Code { get; set; }
public String Name { get; set; }
public bool? PriorityProvincePopulate { get; set; }
public long? ProvinceCount { get; set; }
public long? ProvinceCountActive { get; set; }
}
private class UsgaCountryItemData : UsgaCountryListData
{
}
private void PopulateUsgaCountryResponseListData(SaxGolfUsgaCountry province, UsgaCountryListData data)
{
data.Id = SysId.ToString(province.Id);
data.Code = province.CountryCode;
data.Name = province.CountryName;
data.StatusCode = province.StatusCode;
data.StatusDesc = province.StatusDesc;
}
private void PopulateUsgaCountryResponseItemData(SaxGolfUsgaCountry province, UsgaCountryItemData data)
{
PopulateUsgaCountryResponseListData(province, data);
}
//-------------------------------------------------------------------
// Get ReferenceGolf List ajax request.
// Get Stats ajax request.
//-------------------------------------------------------------------
private class AjaxResponse_ReferenceGolfStats : AjaxResponse_Data
{
@@ -329,82 +303,6 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
return group;
}
//-------------------------------------------------------------------
// Get ReferenceGolf List ajax request.
//-------------------------------------------------------------------
private class AjaxResponse_ReferenceGolfList : AjaxResponse_Data
{
// Construction.
public AjaxResponse_ReferenceGolfList(SaxModel_Admin model) : base(model) { }
// Country list.
public List<UsgaCountryListData> Countries { get; } = new List<UsgaCountryListData>();
}
//-------------------------------------------------------------------
[HttpPost]
[Route("Reference/Golf/Ajax/GetUsgaCountryList")]
[Route("Reference/Golf/Ajax/GetUsgaCountryies")]
public IActionResult Ajax_GetUsgaCountryList(Model_ReferenceGolf model)
{
String fn = GetType().Name + ".Ajax_GetUsgaCountryList";
String messageTitle = Localiser["caption.reference.golf"];
AjaxResponse_ReferenceGolfList responseData = new AjaxResponse_ReferenceGolfList(model);
// Validate session.
if (!ValidUserSession)
return GetAjaxResult_InvalidSession(responseData);
// Item filter.
SaxGolfUsgaCountry.Params prmUsgaCountry = new SaxGolfUsgaCountry.Params();
prmUsgaCountry.StatusCat = SaxGolfUsgaCountry.StatusCat.Any;
model.Paging.ItemTotal = (ulong)ReferenceGolfMgr.GetUsgaCountryCount(prmUsgaCountry);
model.PopulatePagingTo(prmUsgaCountry.ResultsPaging);
// Item columns.
ColumnDfn colId = ReferenceGolfMgr.GetUsgaCountryColumnDfn(SaxGolfUsgaCountry.Column.Id);
ColumnDfn colCode = ReferenceGolfMgr.GetUsgaCountryColumnDfn(SaxGolfUsgaCountry.Column.CountryCode);
ColumnDfn colName = ReferenceGolfMgr.GetUsgaCountryColumnDfn(SaxGolfUsgaCountry.Column.CountryName);
ColumnDfn colProvinceCount_All = ReferenceGolfMgr.GetUsgaCountryColumnDfn(SaxGolfUsgaCountry.Column.ProvinceCount_All);
ColumnDfn colProvinceCount_Active = ReferenceGolfMgr.GetUsgaCountryColumnDfn(SaxGolfUsgaCountry.Column.ProvinceCount_Active);
ColumnDfn colFlags = ReferenceGolfMgr.GetUsgaCountryColumnDfn(SaxGolfUsgaCountry.Column.Flags);
ColumnDfn colStatus = ReferenceGolfMgr.GetUsgaCountryColumnDfn(SaxGolfUsgaCountry.Column.Status);
List<ColumnDfn> columns = new List<ColumnDfn>()
{
colId, colCode, colName, colProvinceCount_All, colProvinceCount_Active, colFlags, colStatus
};
// Sort order.
prmUsgaCountry.SortColumns.Add(colName);
// Query items.
using (DbResultSet resultSet = ReferenceGolfMgr.ExecuteUsgaCountryQuery(columns, prmUsgaCountry))
{
while (resultSet != null && resultSet.HasRows && resultSet.NextRecord())
{
NamedValue.Map values = resultSet.GetRecordValues();
ushort flags = (ushort)values.GetLong(colFlags.DataName);
UsgaCountryListData provinceData = new UsgaCountryListData()
{
Id = values.GetString(colId.DataName),
Code = values.GetString(colName.DataName),
Name = values.GetString(colName.DataName),
ProvinceCount = values.GetLong(colProvinceCount_All.DataName),
ProvinceCountActive = values.GetLong(colProvinceCount_Active.DataName),
PriorityProvincePopulate = SacsHierarchyItem.GetFlag(flags, SaxGolfUsgaCountry.Flag_Priority),
StatusCode = values.GetString(colStatus.DataName),
StatusDesc = SacsSystem.GetStatusDescForCode(values.GetString(colStatus.DataName))
};
responseData.Countries.Add(provinceData);
}
}
if (model.Paging.IsPaged)
model.Paging.ItemCount = (ushort)responseData.Countries.Count;
// Complete response.
responseData.SetPaging(model);
responseData.Success = true;
return Json(responseData);
}
//-------------------------------------------------------------------
}
//=======================================================================
@@ -0,0 +1,250 @@
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.Admin.Models;
using Saxonite.Net.Standard.Base.App;
using Saxonite.Net.Standard.Base.Bus;
using Saxonite.Net.Standard.Base.Bus.Reference;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Saxonite.Net.Core.Web.Admin.Controllers.Reference
{
//=======================================================================
// Reference Golf Controller - Ajax requests.
//=======================================================================
partial class ReferenceGolfController
{
//-------------------------------------------------------------------
// USGA Country data.
private class UsgaCountryListData : AjaxResponse_Data.ItemData_Base
{
public String Code { get; set; }
public String Name { get; set; }
public bool? PriorityProvincePopulate { get; set; }
public long? ProvinceCount { get; set; }
public long? ProvinceCountActive { get; set; }
public long? FacilityCount { get; set; }
public long? FacilityCountActive { get; set; }
}
private class UsgaCountryItemData : UsgaCountryListData
{
}
private void PopulateUsgaCountryResponseListData(SaxGolfUsgaCountry country, UsgaCountryListData data)
{
data.Id = SysId.ToString(country.Id);
data.Code = country.CountryCode;
data.Name = country.CountryName;
data.StatusCode = country.StatusCode;
data.StatusDesc = country.StatusDesc;
}
private void PopulateUsgaCountryResponseItemData(SaxGolfUsgaCountry country, UsgaCountryItemData data)
{
PopulateUsgaCountryResponseListData(country, data);
}
//-------------------------------------------------------------------
// USGA Province data.
private class UsgaProvinceListData : AjaxResponse_Data.ItemData_Base
{
public String Code { get; set; }
public String Name { get; set; }
public bool? PriorityProvincePopulate { get; set; }
public long? FacilityCount { get; set; }
public long? FacilityCountActive { get; set; }
public long? CourseCount { get; set; }
public long? CourseCountActive { get; set; }
}
private class UsgaProvinceItemData : UsgaProvinceListData
{
}
private void PopulateUsgaProvinceResponseListData(SaxGolfUsgaProvince province, UsgaProvinceListData data)
{
data.Id = SysId.ToString(province.Id);
data.Code = province.ProvinceCode;
data.Name = province.ProvinceName;
data.StatusCode = province.StatusCode;
data.StatusDesc = province.StatusDesc;
}
private void PopulateUsgaProvinceResponseItemData(SaxGolfUsgaProvince province, UsgaProvinceItemData data)
{
PopulateUsgaProvinceResponseListData(province, data);
}
//-------------------------------------------------------------------
// Get Country List ajax request.
//-------------------------------------------------------------------
private class AjaxResponse_ReferenceGolf_CountryList : AjaxResponse_Data
{
// Construction.
public AjaxResponse_ReferenceGolf_CountryList(SaxModel_Admin model) : base(model) { }
// Country list.
public List<UsgaCountryListData> Countries { get; } = new List<UsgaCountryListData>();
}
//-------------------------------------------------------------------
[HttpPost]
[Route("Reference/Golf/Ajax/GetUsgaCountryList")]
[Route("Reference/Golf/Ajax/GetUsgaCountries")]
[Route("Reference/Golf/Ajax/GetCountryList")]
[Route("Reference/Golf/Ajax/GetCountries")]
public IActionResult Ajax_GetCountryList(Model_ReferenceGolf model)
{
String fn = GetType().Name + ".Ajax_GetCountryList";
String messageTitle = Localiser["caption.reference.golf"];
AjaxResponse_ReferenceGolf_CountryList responseData = new AjaxResponse_ReferenceGolf_CountryList(model);
// Validate session.
if (!ValidUserSession)
return GetAjaxResult_InvalidSession(responseData);
// Item columns.
ColumnDfn colId = ReferenceGolfMgr.GetUsgaCountryColumnDfn(SaxGolfUsgaCountry.Column.Id);
ColumnDfn colCode = ReferenceGolfMgr.GetUsgaCountryColumnDfn(SaxGolfUsgaCountry.Column.CountryCode);
ColumnDfn colName = ReferenceGolfMgr.GetUsgaCountryColumnDfn(SaxGolfUsgaCountry.Column.CountryName);
ColumnDfn colProvinceCount_All = ReferenceGolfMgr.GetUsgaCountryColumnDfn(SaxGolfUsgaCountry.Column.ProvinceCount_All);
ColumnDfn colProvinceCount_Active = ReferenceGolfMgr.GetUsgaCountryColumnDfn(SaxGolfUsgaCountry.Column.ProvinceCount_Active);
ColumnDfn colFacilityCount_All = ReferenceGolfMgr.GetUsgaCountryColumnDfn(SaxGolfUsgaCountry.Column.FacilityCount_All);
ColumnDfn colFacilityCount_Active = ReferenceGolfMgr.GetUsgaCountryColumnDfn(SaxGolfUsgaCountry.Column.FacilityCount_Active);
ColumnDfn colFlags = ReferenceGolfMgr.GetUsgaCountryColumnDfn(SaxGolfUsgaCountry.Column.Flags);
ColumnDfn colStatus = ReferenceGolfMgr.GetUsgaCountryColumnDfn(SaxGolfUsgaCountry.Column.Status);
List<ColumnDfn> columns = new List<ColumnDfn>()
{
colId, colCode, colName, colProvinceCount_All, colProvinceCount_Active, colFacilityCount_All, colFacilityCount_Active, colFlags, colStatus
};
// Item filter.
SaxGolfUsgaCountry.Params prmUsgaCountry = new SaxGolfUsgaCountry.Params();
prmUsgaCountry.CountryFilter = model.Filter.CountrySearch;
prmUsgaCountry.StatusCat = SaxGolfUsgaCountry.StatusCat.Any;
model.Paging.ItemTotal = (ulong)ReferenceGolfMgr.GetUsgaCountryCount(prmUsgaCountry);
model.PopulatePagingTo(prmUsgaCountry.ResultsPaging);
// Sort order.
prmUsgaCountry.SortColumns.Add(colName);
// Query items.
using (DbResultSet resultSet = ReferenceGolfMgr.ExecuteUsgaCountryQuery(columns, prmUsgaCountry))
{
while (resultSet != null && resultSet.HasRows && resultSet.NextRecord())
{
NamedValue.Map values = resultSet.GetRecordValues();
ushort flags = (ushort)values.GetLong(colFlags.DataName);
UsgaCountryListData provinceData = new UsgaCountryListData()
{
Id = values.GetString(colId.DataName),
Code = values.GetString(colCode.DataName),
Name = values.GetString(colName.DataName),
PriorityProvincePopulate = SacsHierarchyItem.GetFlag(flags, SaxGolfUsgaCountry.Flag_Priority),
ProvinceCount = values.GetLong(colProvinceCount_All.DataName),
ProvinceCountActive = values.GetLong(colProvinceCount_Active.DataName),
FacilityCount = values.GetLong(colFacilityCount_All.DataName),
FacilityCountActive = values.GetLong(colFacilityCount_Active.DataName),
StatusCode = values.GetString(colStatus.DataName),
StatusDesc = SacsSystem.GetStatusDescForCode(values.GetString(colStatus.DataName))
};
responseData.Countries.Add(provinceData);
}
}
if (model.Paging.IsPaged)
model.Paging.ItemCount = (ushort)responseData.Countries.Count;
// Complete response.
responseData.SetPaging(model);
responseData.Success = true;
return Json(responseData);
}
//-------------------------------------------------------------------
// Get Province List ajax request.
//-------------------------------------------------------------------
private class AjaxResponse_ReferenceGolf_ProvinceList : AjaxResponse_Data
{
// Construction.
public AjaxResponse_ReferenceGolf_ProvinceList(SaxModel_Admin model) : base(model) { }
// Province list.
public List<UsgaProvinceListData> Provinces { get; } = new List<UsgaProvinceListData>();
}
//-------------------------------------------------------------------
[HttpPost]
[Route("Reference/Golf/Ajax/GetUsgaProvinceList")]
[Route("Reference/Golf/Ajax/GetUsgaProvinces")]
[Route("Reference/Golf/Ajax/GetProvinceList")]
[Route("Reference/Golf/Ajax/GetProvinces")]
public IActionResult Ajax_GetProvinceList(Model_ReferenceGolf model)
{
String fn = GetType().Name + ".Ajax_GetProvinceList";
String messageTitle = Localiser["caption.reference.golf"];
AjaxResponse_ReferenceGolf_ProvinceList responseData = new AjaxResponse_ReferenceGolf_ProvinceList(model);
// Validate session.
if (!ValidUserSession)
return GetAjaxResult_InvalidSession(responseData);
// Item columns.
ColumnDfn colId = ReferenceGolfMgr.GetUsgaProvinceColumnDfn(SaxGolfUsgaProvince.Column.Id);
ColumnDfn colCode = ReferenceGolfMgr.GetUsgaProvinceColumnDfn(SaxGolfUsgaProvince.Column.ProvinceCode);
ColumnDfn colName = ReferenceGolfMgr.GetUsgaProvinceColumnDfn(SaxGolfUsgaProvince.Column.ProvinceName);
ColumnDfn colFacilityCount_All = ReferenceGolfMgr.GetUsgaProvinceColumnDfn(SaxGolfUsgaProvince.Column.FacilityCount_All);
ColumnDfn colFacilityCount_Active = ReferenceGolfMgr.GetUsgaProvinceColumnDfn(SaxGolfUsgaProvince.Column.FacilityCount_Active);
ColumnDfn colCourseCount_All = ReferenceGolfMgr.GetUsgaProvinceColumnDfn(SaxGolfUsgaProvince.Column.CourseCount_All);
ColumnDfn colCourseCount_Active = ReferenceGolfMgr.GetUsgaProvinceColumnDfn(SaxGolfUsgaProvince.Column.CourseCount_Active);
ColumnDfn colFlags = ReferenceGolfMgr.GetUsgaProvinceColumnDfn(SaxGolfUsgaProvince.Column.Flags);
ColumnDfn colStatus = ReferenceGolfMgr.GetUsgaProvinceColumnDfn(SaxGolfUsgaProvince.Column.Status);
List<ColumnDfn> columns = new List<ColumnDfn>()
{
colId, colCode, colName, colFacilityCount_All, colFacilityCount_Active, colCourseCount_All, colCourseCount_Active, colFlags, colStatus
};
// Item filter.
SaxGolfUsgaProvince.Params prmUsgaProvince = new SaxGolfUsgaProvince.Params();
if (StringUtil.ToLong(model.Filter.CountryId) > 0)
prmUsgaProvince.CountryIdsIncluded.Add(StringUtil.ToSysId(model.Filter.CountryId));
prmUsgaProvince.ProvinceFilter = model.Filter.ProvinceSearch;
prmUsgaProvince.StatusCat = SaxGolfUsgaProvince.StatusCat.Any;
model.Paging.ItemTotal = (ulong)ReferenceGolfMgr.GetUsgaProvinceCount(prmUsgaProvince);
model.PopulatePagingTo(prmUsgaProvince.ResultsPaging);
// Sort order.
prmUsgaProvince.SortColumns.Add(colCode);
// Query items.
using (DbResultSet resultSet = ReferenceGolfMgr.ExecuteUsgaProvinceQuery(columns, prmUsgaProvince))
{
while (resultSet != null && resultSet.HasRows && resultSet.NextRecord())
{
NamedValue.Map values = resultSet.GetRecordValues();
ushort flags = (ushort)values.GetLong(colFlags.DataName);
UsgaProvinceListData provinceData = new UsgaProvinceListData()
{
Id = values.GetString(colId.DataName),
Code = values.GetString(colCode.DataName),
Name = values.GetString(colName.DataName),
PriorityProvincePopulate = SacsHierarchyItem.GetFlag(flags, SaxGolfUsgaProvince.Flag_Priority),
FacilityCount = values.GetLong(colFacilityCount_All.DataName),
FacilityCountActive = values.GetLong(colFacilityCount_Active.DataName),
CourseCount = values.GetLong(colCourseCount_All.DataName),
CourseCountActive = values.GetLong(colCourseCount_Active.DataName),
StatusCode = values.GetString(colStatus.DataName),
StatusDesc = SacsSystem.GetStatusDescForCode(values.GetString(colStatus.DataName))
};
responseData.Provinces.Add(provinceData);
}
}
if (model.Paging.IsPaged)
model.Paging.ItemCount = (ushort)responseData.Provinces.Count;
// Complete response.
responseData.SetPaging(model);
responseData.Success = true;
return Json(responseData);
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -9,7 +9,7 @@ using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
namespace Saxonite.Net.Core.Web.Admin.Controllers
namespace Saxonite.Net.Core.Web.Admin.Controllers.Reference
{
//=======================================================================
public partial class ReferenceGolfController : SaxController_Admin
@@ -18,7 +18,7 @@ using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
namespace Saxonite.Net.Core.Web.Admin.Controllers
namespace Saxonite.Net.Core.Web.Admin.Controllers.System
{
//=======================================================================
// System - Ajax - Database controller
@@ -4,6 +4,7 @@ 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.IO;
using Sarand.Net.Standard.Base.Utils;
using Saxonite.Net.Core.Web.Admin.Models;
using Saxonite.Net.Standard.Base.App;
@@ -15,7 +16,7 @@ using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace Saxonite.Net.Core.Web.Admin.Controllers
namespace Saxonite.Net.Core.Web.Admin.Controllers.System
{
//=======================================================================
// System - Ajax - Database controller
@@ -256,7 +257,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
responseData.File.Name = Path.GetFileName(responseData.File.Path);
try
{
String[] fileLines = System.IO.File.ReadAllLines(responseData.File.Path);
String[] fileLines = FileUtil.ReadAllFileLines(responseData.File.Path);
responseData.File.Data = String.Join("\n", fileLines);
// Construct html data.
foreach (var fileLine in fileLines)
@@ -14,7 +14,7 @@ using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
namespace Saxonite.Net.Core.Web.Admin.Controllers
namespace Saxonite.Net.Core.Web.Admin.Controllers.System
{
//=======================================================================
public partial class SystemController : SaxController_Admin
@@ -30,6 +30,12 @@ namespace Saxonite.Net.Core.Web.Admin.Models
// Reference Golf list parameters.
public class FilterData
{
public String CountrySearch { get; set; }
public String CountryId { get; set; }
public String ProvinceSearch { get; set; }
public String ProvinceId { get; set; }
public String CourseSearch{ get; set; }
public String CourseId { get; set; }
}
public FilterData Filter { get; } = new FilterData();