412 lines
21 KiB
C#
412 lines
21 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.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 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.
|
|
//-------------------------------------------------------------------
|
|
private class AjaxResponse_ReferenceGolfStats : AjaxResponse_Data
|
|
{
|
|
// Construction.
|
|
public AjaxResponse_ReferenceGolfStats(SaxModel_Admin model) : base(model) { }
|
|
// Statistics.
|
|
public class StatData : AjaxResponse_Base
|
|
{
|
|
public String Caption { get; set; }
|
|
public String Value { get; set; }
|
|
}
|
|
public class StatGroupData : AjaxResponse_Base
|
|
{
|
|
public String Caption { get; set; }
|
|
public List<StatData> Stats { get; } = new List<StatData>();
|
|
}
|
|
public List<StatGroupData> Groups { get; } = new List<StatGroupData>();
|
|
}
|
|
//-------------------------------------------------------------------
|
|
[HttpPost]
|
|
[Route("Reference/Golf/Ajax/GetUsgaStats")]
|
|
[Route("Reference/Golf/Ajax/GetStats")]
|
|
[Route("Reference/Golf/Ajax/Stats")]
|
|
public IActionResult Ajax_GetUsgaStats(Model_ReferenceGolf model)
|
|
{
|
|
String fn = GetType().Name + ".Ajax_GetUsgaStats";
|
|
String messageTitle = Localiser["caption.reference.golf"];
|
|
AjaxResponse_ReferenceGolfStats responseData = new AjaxResponse_ReferenceGolfStats(model);
|
|
|
|
// Validate session.
|
|
if (!ValidUserSession)
|
|
return GetAjaxResult_InvalidSession(responseData);
|
|
|
|
// Statistics.
|
|
responseData.Groups.Add(PopulateCountryStatsData());
|
|
responseData.Groups.Add(PopulateProvinceStatsData());
|
|
responseData.Groups.Add(PopulateFacilityStatsData());
|
|
responseData.Groups.Add(PopulateCourseStatsData());
|
|
responseData.Groups.Add(PopulateMarkerStatsData());
|
|
|
|
// Complete response.
|
|
responseData.Success = true;
|
|
return Json(responseData);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
private AjaxResponse_ReferenceGolfStats.StatGroupData PopulateCountryStatsData()
|
|
{
|
|
AjaxResponse_ReferenceGolfStats.StatGroupData group = new AjaxResponse_ReferenceGolfStats.StatGroupData() { Caption = "Countries" };
|
|
|
|
// All countries.
|
|
SaxGolfUsgaCountry.Params prmCountry = new SaxGolfUsgaCountry.Params();
|
|
prmCountry.StatusCat = SaxGolfUsgaCountry.StatusCat.Any;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Total", Value = ReferenceGolfMgr.GetUsgaCountryCount(prmCountry).ToString() });
|
|
|
|
// Active countries.
|
|
prmCountry = new SaxGolfUsgaCountry.Params();
|
|
prmCountry.StatusCat = SaxGolfUsgaCountry.StatusCat.ActiveOnly;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Active", Value = ReferenceGolfMgr.GetUsgaCountryCount(prmCountry).ToString() });
|
|
|
|
// Inctive countries.
|
|
prmCountry = new SaxGolfUsgaCountry.Params();
|
|
prmCountry.StatusCat = SaxGolfUsgaCountry.StatusCat.InactiveOnly;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Inactive", Value = ReferenceGolfMgr.GetUsgaCountryCount(prmCountry).ToString() });
|
|
|
|
// Deleted countries.
|
|
prmCountry = new SaxGolfUsgaCountry.Params();
|
|
prmCountry.StatusCat = SaxGolfUsgaCountry.StatusCat.DeletedOnly;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Deleted", Value = ReferenceGolfMgr.GetUsgaCountryCount(prmCountry).ToString() });
|
|
|
|
// 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;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Priority no provinces", Value = ReferenceGolfMgr.GetUsgaCountryCount(prmCountry).ToString() });
|
|
|
|
// 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;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Non-priority no provinces", Value = ReferenceGolfMgr.GetUsgaCountryCount(prmCountry).ToString() });
|
|
|
|
// 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;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Priority with provinces", Value = ReferenceGolfMgr.GetUsgaCountryCount(prmCountry).ToString() });
|
|
|
|
// 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;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Non-priority with provinces", Value = ReferenceGolfMgr.GetUsgaCountryCount(prmCountry).ToString() });
|
|
|
|
return group;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
private AjaxResponse_ReferenceGolfStats.StatGroupData PopulateProvinceStatsData()
|
|
{
|
|
AjaxResponse_ReferenceGolfStats.StatGroupData group = new AjaxResponse_ReferenceGolfStats.StatGroupData() { Caption = "Provinces" };
|
|
|
|
// All provinces.
|
|
SaxGolfUsgaProvince.Params prmProvince = new SaxGolfUsgaProvince.Params();
|
|
prmProvince.StatusCat = SaxGolfUsgaProvince.StatusCat.Any;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Total", Value = ReferenceGolfMgr.GetUsgaProvinceCount(prmProvince).ToString() });
|
|
|
|
// Active provinces.
|
|
prmProvince = new SaxGolfUsgaProvince.Params();
|
|
prmProvince.StatusCat = SaxGolfUsgaProvince.StatusCat.ActiveOnly;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Active", Value = ReferenceGolfMgr.GetUsgaProvinceCount(prmProvince).ToString() });
|
|
|
|
// Inctive provinces.
|
|
prmProvince = new SaxGolfUsgaProvince.Params();
|
|
prmProvince.StatusCat = SaxGolfUsgaProvince.StatusCat.InactiveOnly;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Inactive", Value = ReferenceGolfMgr.GetUsgaProvinceCount(prmProvince).ToString() });
|
|
|
|
// Deleted provinces.
|
|
prmProvince = new SaxGolfUsgaProvince.Params();
|
|
prmProvince.StatusCat = SaxGolfUsgaProvince.StatusCat.DeletedOnly;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Deleted", Value = ReferenceGolfMgr.GetUsgaProvinceCount(prmProvince).ToString() });
|
|
|
|
// Priority provinces without facilities.
|
|
prmProvince = new SaxGolfUsgaProvince.Params();
|
|
prmProvince.PriorityFlagState = SacsHierarchyItem.Params.FlagState.True;
|
|
prmProvince.HasFacilities = SacsHierarchyItem.Params.BoolState.False;
|
|
prmProvince.StatusCat = SaxGolfUsgaProvince.StatusCat.ActiveOnly;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Priority no facilities", Value = ReferenceGolfMgr.GetUsgaProvinceCount(prmProvince).ToString() });
|
|
|
|
// Non-Priority provinces without facilities.
|
|
prmProvince = new SaxGolfUsgaProvince.Params();
|
|
prmProvince.PriorityFlagState = SacsHierarchyItem.Params.FlagState.False;
|
|
prmProvince.HasFacilities = SacsHierarchyItem.Params.BoolState.False;
|
|
prmProvince.StatusCat = SaxGolfUsgaProvince.StatusCat.ActiveOnly;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Non-priority no facilities", Value = ReferenceGolfMgr.GetUsgaProvinceCount(prmProvince).ToString() });
|
|
|
|
// Priority provinces with facilities.
|
|
prmProvince = new SaxGolfUsgaProvince.Params();
|
|
prmProvince.PriorityFlagState = SacsHierarchyItem.Params.FlagState.True;
|
|
prmProvince.HasFacilities = SacsHierarchyItem.Params.BoolState.True;
|
|
prmProvince.StatusCat = SaxGolfUsgaProvince.StatusCat.ActiveOnly;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Priority with facilities", Value = ReferenceGolfMgr.GetUsgaProvinceCount(prmProvince).ToString() });
|
|
|
|
// Non-Priority provinces with facilities.
|
|
prmProvince = new SaxGolfUsgaProvince.Params();
|
|
prmProvince.PriorityFlagState = SacsHierarchyItem.Params.FlagState.False;
|
|
prmProvince.HasFacilities = SacsHierarchyItem.Params.BoolState.True;
|
|
prmProvince.StatusCat = SaxGolfUsgaProvince.StatusCat.ActiveOnly;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Non-priority with facilities", Value = ReferenceGolfMgr.GetUsgaProvinceCount(prmProvince).ToString() });
|
|
|
|
return group;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
private AjaxResponse_ReferenceGolfStats.StatGroupData PopulateFacilityStatsData()
|
|
{
|
|
AjaxResponse_ReferenceGolfStats.StatGroupData group = new AjaxResponse_ReferenceGolfStats.StatGroupData() { Caption = "Facilities" };
|
|
|
|
// All facilities.
|
|
SaxGolfUsgaFacility.Params prmFacility = new SaxGolfUsgaFacility.Params();
|
|
prmFacility.StatusCat = SaxGolfUsgaFacility.StatusCat.Any;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Total", Value = ReferenceGolfMgr.GetUsgaFacilityCount(prmFacility).ToString() });
|
|
|
|
// Active facilities.
|
|
prmFacility = new SaxGolfUsgaFacility.Params();
|
|
prmFacility.StatusCat = SaxGolfUsgaFacility.StatusCat.ActiveOnly;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Active", Value = ReferenceGolfMgr.GetUsgaFacilityCount(prmFacility).ToString() });
|
|
|
|
// Inctive facilities.
|
|
prmFacility = new SaxGolfUsgaFacility.Params();
|
|
prmFacility.StatusCat = SaxGolfUsgaFacility.StatusCat.InactiveOnly;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Inactive", Value = ReferenceGolfMgr.GetUsgaFacilityCount(prmFacility).ToString() });
|
|
|
|
// Deleted facilities.
|
|
prmFacility = new SaxGolfUsgaFacility.Params();
|
|
prmFacility.StatusCat = SaxGolfUsgaFacility.StatusCat.DeletedOnly;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Deleted", Value = ReferenceGolfMgr.GetUsgaFacilityCount(prmFacility).ToString() });
|
|
|
|
// Facilities without courses.
|
|
prmFacility = new SaxGolfUsgaFacility.Params();
|
|
prmFacility.HasCourses = SacsHierarchyItem.Params.BoolState.False;
|
|
prmFacility.StatusCat = SaxGolfUsgaFacility.StatusCat.ActiveOnly;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "No courses", Value = ReferenceGolfMgr.GetUsgaFacilityCount(prmFacility).ToString() });
|
|
|
|
// Priority facilities with courses.
|
|
prmFacility = new SaxGolfUsgaFacility.Params();
|
|
prmFacility.HasCourses = SacsHierarchyItem.Params.BoolState.True;
|
|
prmFacility.StatusCat = SaxGolfUsgaFacility.StatusCat.ActiveOnly;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "With courses", Value = ReferenceGolfMgr.GetUsgaFacilityCount(prmFacility).ToString() });
|
|
|
|
return group;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
private AjaxResponse_ReferenceGolfStats.StatGroupData PopulateCourseStatsData()
|
|
{
|
|
AjaxResponse_ReferenceGolfStats.StatGroupData group = new AjaxResponse_ReferenceGolfStats.StatGroupData() { Caption = "Courses" };
|
|
|
|
// All courses.
|
|
SaxGolfUsgaCourse.Params prmCourse = new SaxGolfUsgaCourse.Params();
|
|
prmCourse.StatusCat = SaxGolfUsgaCourse.StatusCat.Any;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Total", Value = ReferenceGolfMgr.GetUsgaCourseCount(prmCourse).ToString() });
|
|
|
|
// Active courses.
|
|
prmCourse = new SaxGolfUsgaCourse.Params();
|
|
prmCourse.StatusCat = SaxGolfUsgaCourse.StatusCat.ActiveOnly;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Active", Value = ReferenceGolfMgr.GetUsgaCourseCount(prmCourse).ToString() });
|
|
|
|
// Inctive courses.
|
|
prmCourse = new SaxGolfUsgaCourse.Params();
|
|
prmCourse.StatusCat = SaxGolfUsgaCourse.StatusCat.InactiveOnly;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Inactive", Value = ReferenceGolfMgr.GetUsgaCourseCount(prmCourse).ToString() });
|
|
|
|
// Deleted courses.
|
|
prmCourse = new SaxGolfUsgaCourse.Params();
|
|
prmCourse.StatusCat = SaxGolfUsgaCourse.StatusCat.DeletedOnly;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Deleted", Value = ReferenceGolfMgr.GetUsgaCourseCount(prmCourse).ToString() });
|
|
|
|
// Priority courses without markers.
|
|
prmCourse = new SaxGolfUsgaCourse.Params();
|
|
prmCourse.PriorityFlagState = SacsHierarchyItem.Params.FlagState.True;
|
|
prmCourse.HasMarkers = SacsHierarchyItem.Params.BoolState.False;
|
|
prmCourse.StatusCat = SaxGolfUsgaCourse.StatusCat.ActiveOnly;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Priority no markers", Value = ReferenceGolfMgr.GetUsgaCourseCount(prmCourse).ToString() });
|
|
|
|
// Non-Priority courses without markers.
|
|
prmCourse = new SaxGolfUsgaCourse.Params();
|
|
prmCourse.PriorityFlagState = SacsHierarchyItem.Params.FlagState.False;
|
|
prmCourse.HasMarkers = SacsHierarchyItem.Params.BoolState.False;
|
|
prmCourse.StatusCat = SaxGolfUsgaCourse.StatusCat.ActiveOnly;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Non-priority no markers", Value = ReferenceGolfMgr.GetUsgaCourseCount(prmCourse).ToString() });
|
|
|
|
// Priority courses with markers.
|
|
prmCourse = new SaxGolfUsgaCourse.Params();
|
|
prmCourse.PriorityFlagState = SacsHierarchyItem.Params.FlagState.True;
|
|
prmCourse.HasMarkers = SacsHierarchyItem.Params.BoolState.True;
|
|
prmCourse.StatusCat = SaxGolfUsgaCourse.StatusCat.ActiveOnly;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Priority with markers", Value = ReferenceGolfMgr.GetUsgaCourseCount(prmCourse).ToString() });
|
|
|
|
// Non-Priority courses with markers.
|
|
prmCourse = new SaxGolfUsgaCourse.Params();
|
|
prmCourse.PriorityFlagState = SacsHierarchyItem.Params.FlagState.False;
|
|
prmCourse.HasMarkers = SacsHierarchyItem.Params.BoolState.True;
|
|
prmCourse.StatusCat = SaxGolfUsgaCourse.StatusCat.ActiveOnly;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Non-priority with markers", Value = ReferenceGolfMgr.GetUsgaCourseCount(prmCourse).ToString() });
|
|
|
|
return group;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
private AjaxResponse_ReferenceGolfStats.StatGroupData PopulateMarkerStatsData()
|
|
{
|
|
AjaxResponse_ReferenceGolfStats.StatGroupData group = new AjaxResponse_ReferenceGolfStats.StatGroupData() { Caption = "Markers" };
|
|
|
|
// All markers.
|
|
SaxGolfUsgaMarker.Params prmMarker = new SaxGolfUsgaMarker.Params();
|
|
prmMarker.StatusCat = SaxGolfUsgaMarker.StatusCat.Any;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Total", Value = ReferenceGolfMgr.GetUsgaMarkerCount(prmMarker).ToString() });
|
|
|
|
// Active markers.
|
|
prmMarker = new SaxGolfUsgaMarker.Params();
|
|
prmMarker.StatusCat = SaxGolfUsgaMarker.StatusCat.ActiveOnly;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Active", Value = ReferenceGolfMgr.GetUsgaMarkerCount(prmMarker).ToString() });
|
|
|
|
// Inctive markers.
|
|
prmMarker = new SaxGolfUsgaMarker.Params();
|
|
prmMarker.StatusCat = SaxGolfUsgaMarker.StatusCat.InactiveOnly;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Inactive", Value = ReferenceGolfMgr.GetUsgaMarkerCount(prmMarker).ToString() });
|
|
|
|
// Deleted markers.
|
|
prmMarker = new SaxGolfUsgaMarker.Params();
|
|
prmMarker.StatusCat = SaxGolfUsgaMarker.StatusCat.DeletedOnly;
|
|
group.Stats.Add(new AjaxResponse_ReferenceGolfStats.StatData() { Caption = "Deleted", Value = ReferenceGolfMgr.GetUsgaMarkerCount(prmMarker).ToString() });
|
|
|
|
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);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|