|
|
|
@@ -0,0 +1,191 @@
|
|
|
|
|
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 Golf Controller - Ajax requests.
|
|
|
|
|
//=======================================================================
|
|
|
|
|
partial class ReferenceGolfController
|
|
|
|
|
{
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
// USGA Country data.
|
|
|
|
|
private class UsgaCountryStatsData : AjaxResponse_Base
|
|
|
|
|
{
|
|
|
|
|
public long? Total { get; set; }
|
|
|
|
|
public long? Active { get; set; }
|
|
|
|
|
public long? Inactive { get; set; }
|
|
|
|
|
public long? Deleted { get; set; }
|
|
|
|
|
public long? PriorityNoProvinces { get; set; }
|
|
|
|
|
public long? NonPriorityNoProvinces { get; set; }
|
|
|
|
|
public long? PriorityWithProvinces { get; set; }
|
|
|
|
|
public long? NonPriorityWithProvinces { get; set; }
|
|
|
|
|
}
|
|
|
|
|
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 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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
private void PopulateCountryStatsData(UsgaCountryStatsData countryStats)
|
|
|
|
|
{
|
|
|
|
|
// All countries.
|
|
|
|
|
SaxGolfUsgaCountry.Params prmCountry = new SaxGolfUsgaCountry.Params();
|
|
|
|
|
prmCountry.StatusCat = SaxGolfUsgaCountry.StatusCat.Any;
|
|
|
|
|
countryStats.Total = ReferenceGolfMgr.GetUsgaCountryCount(prmCountry);
|
|
|
|
|
|
|
|
|
|
// Active countries.
|
|
|
|
|
prmCountry = new SaxGolfUsgaCountry.Params();
|
|
|
|
|
prmCountry.StatusCat = SaxGolfUsgaCountry.StatusCat.ActiveOnly;
|
|
|
|
|
countryStats.Active = ReferenceGolfMgr.GetUsgaCountryCount(prmCountry);
|
|
|
|
|
|
|
|
|
|
// Inctive countries.
|
|
|
|
|
prmCountry = new SaxGolfUsgaCountry.Params();
|
|
|
|
|
prmCountry.StatusCat = SaxGolfUsgaCountry.StatusCat.InactiveOnly;
|
|
|
|
|
countryStats.Inactive = ReferenceGolfMgr.GetUsgaCountryCount(prmCountry);
|
|
|
|
|
|
|
|
|
|
// Deleted countries.
|
|
|
|
|
prmCountry = new SaxGolfUsgaCountry.Params();
|
|
|
|
|
prmCountry.StatusCat = SaxGolfUsgaCountry.StatusCat.DeletedOnly;
|
|
|
|
|
countryStats.Deleted = ReferenceGolfMgr.GetUsgaCountryCount(prmCountry);
|
|
|
|
|
|
|
|
|
|
// Priority countries without provinces.
|
|
|
|
|
prmCountry = new SaxGolfUsgaCountry.Params();
|
|
|
|
|
prmCountry.PriorityFlagState = SacsHierarchyItem.Params.FlagState.True;
|
|
|
|
|
prmCountry.HasProvinces = SacsHierarchyItem.Params.BoolState.False;
|
|
|
|
|
prmCountry.StatusCat = SaxGolfUsgaCountry.StatusCat.ActiveOnly;
|
|
|
|
|
countryStats.PriorityNoProvinces = ReferenceGolfMgr.GetUsgaCountryCount(prmCountry);
|
|
|
|
|
|
|
|
|
|
// Non-Priority countries without provinces.
|
|
|
|
|
prmCountry = new SaxGolfUsgaCountry.Params();
|
|
|
|
|
prmCountry.PriorityFlagState = SacsHierarchyItem.Params.FlagState.False;
|
|
|
|
|
prmCountry.HasProvinces = SacsHierarchyItem.Params.BoolState.False;
|
|
|
|
|
prmCountry.StatusCat = SaxGolfUsgaCountry.StatusCat.ActiveOnly;
|
|
|
|
|
countryStats.NonPriorityNoProvinces = ReferenceGolfMgr.GetUsgaCountryCount(prmCountry);
|
|
|
|
|
|
|
|
|
|
// Priority countries with provinces.
|
|
|
|
|
prmCountry = new SaxGolfUsgaCountry.Params();
|
|
|
|
|
prmCountry.PriorityFlagState = SacsHierarchyItem.Params.FlagState.True;
|
|
|
|
|
prmCountry.HasProvinces = SacsHierarchyItem.Params.BoolState.True;
|
|
|
|
|
prmCountry.StatusCat = SaxGolfUsgaCountry.StatusCat.ActiveOnly;
|
|
|
|
|
countryStats.PriorityWithProvinces = ReferenceGolfMgr.GetUsgaCountryCount(prmCountry);
|
|
|
|
|
|
|
|
|
|
// Non-Priority countries with provinces.
|
|
|
|
|
prmCountry = new SaxGolfUsgaCountry.Params();
|
|
|
|
|
prmCountry.PriorityFlagState = SacsHierarchyItem.Params.FlagState.False;
|
|
|
|
|
prmCountry.HasProvinces = SacsHierarchyItem.Params.BoolState.True;
|
|
|
|
|
prmCountry.StatusCat = SaxGolfUsgaCountry.StatusCat.ActiveOnly;
|
|
|
|
|
countryStats.NonPriorityWithProvinces = ReferenceGolfMgr.GetUsgaCountryCount(prmCountry);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
// Get ReferenceGolf List ajax request.
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
private class AjaxResponse_ReferenceGolfList : AjaxResponse_Data
|
|
|
|
|
{
|
|
|
|
|
// Construction.
|
|
|
|
|
public AjaxResponse_ReferenceGolfList(SaxModel_Admin model) : base(model) { }
|
|
|
|
|
// ReferenceGolf list.
|
|
|
|
|
public List<UsgaCountryListData> Countries { get; } = new List<UsgaCountryListData>();
|
|
|
|
|
}
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[Route("ReferenceGolf/Ajax/GetUsgaCountryList")]
|
|
|
|
|
[Route("ReferenceGolf/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 countryData = 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(countryData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (model.Paging.IsPaged)
|
|
|
|
|
model.Paging.ItemCount = (ushort)responseData.Countries.Count;
|
|
|
|
|
|
|
|
|
|
// Complete response.
|
|
|
|
|
responseData.SetPaging(model);
|
|
|
|
|
responseData.Success = true;
|
|
|
|
|
return Json(responseData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
}
|
|
|
|
|
//=======================================================================
|
|
|
|
|
}
|