1.2.11.7 Golf stats

This commit is contained in:
2024-06-16 15:36:25 +01:00
parent 8c76d97d9f
commit 6b7450550e
12 changed files with 485 additions and 53 deletions
@@ -321,6 +321,12 @@ namespace Saxonite.Net.Core.Web.Base.Procs
SaLogger.Warn($"{SysUtil.Fn} USGA Country not found for code '{countryCode}'.");
return usgaProvinces;
}
if (usgaCountry.Priority)
{
// Clear country 'priority' flag.
usgaCountry.Priority = false;
ReferenceGolfMgr.UpdateUsgaCountry(usgaCountry, DbUpdateInfo);
}
try
{
@@ -390,9 +396,6 @@ namespace Saxonite.Net.Core.Web.Base.Procs
if (!ReferenceGolfMgr.HasErrorState())
{
// Provinces updates OK.
// Clear country 'priority' flag.
usgaCountry.Priority = false;
ReferenceGolfMgr.UpdateUsgaCountry(usgaCountry, DbUpdateInfo);
}
else SaLogger.Warn($"{SysUtil.Fn} Error bulk updating USGA provinces: {ReferenceGolfMgr.ErrorStateMessage}.");
}
@@ -433,6 +436,12 @@ namespace Saxonite.Net.Core.Web.Base.Procs
SaLogger.Warn($"{SysUtil.Fn} USGA Province not found for code '{provinceCode}'.");
return usgaCourses;
}
if (usgaProvince.Priority)
{
// Clear province 'priority' flag.
usgaProvince.Priority = false;
ReferenceGolfMgr.UpdateUsgaProvince(usgaProvince, DbUpdateInfo);
}
try
{
@@ -604,9 +613,6 @@ namespace Saxonite.Net.Core.Web.Base.Procs
if (!ReferenceGolfMgr.HasErrorState())
{
// Courses updates OK.
// Clear province 'priority' flag.
usgaProvince.Priority = false;
ReferenceGolfMgr.UpdateUsgaProvince(usgaProvince, DbUpdateInfo);
}
else SaLogger.Warn($"{SysUtil.Fn} Error bulk updating USGA courses: {ReferenceGolfMgr.ErrorStateMessage}.");
}
@@ -723,6 +729,11 @@ namespace Saxonite.Net.Core.Web.Base.Procs
SaLogger.Warn($"{SysUtil.Fn} USGA Course not found for Id '{usgaCourseId}'.");
return markersData.Markers;
}
if (usgaCourse.Priority)
{
usgaCourse.Priority = false;
ReferenceGolfMgr.UpdateUsgaCourse(usgaCourse, DbUpdateInfo);
}
try
{
@@ -913,16 +924,17 @@ namespace Saxonite.Net.Core.Web.Base.Procs
ReferenceGolfMgr.BulkUpdateUsgaMarkers(markersUpdateData, DbUpdateInfo);
if (!ReferenceGolfMgr.HasErrorState())
{
// Courses updates OK.
// Store Marker data and clear Course 'priority' flag.
if (markersData.Markers.Any())
{
usgaCourse.MarkersData = JsonConvert.SerializeObject(markersData);
usgaCourse.Priority = false;
ReferenceGolfMgr.UpdateUsgaCourse(usgaCourse, DbUpdateInfo);
}
// Markers updates OK.
}
else SaLogger.Warn($"{SysUtil.Fn} Error bulk updating USGA markers: {ReferenceGolfMgr.ErrorStateMessage}.");
// Store Marker data and clear Course 'priority' flag.
if (markersData.Markers.Any())
{
usgaCourse.MarkersData = JsonConvert.SerializeObject(markersData);
usgaCourse.Priority = false;
ReferenceGolfMgr.UpdateUsgaCourse(usgaCourse, DbUpdateInfo);
}
}
catch (Exception exc)
{
@@ -22,17 +22,6 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
{
//-------------------------------------------------------------------
// 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; }
@@ -44,69 +33,300 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
private class UsgaCountryItemData : UsgaCountryListData
{
}
private void PopulateUsgaCountryResponseListData(SaxGolfUsgaCountry country, UsgaCountryListData data)
private void PopulateUsgaCountryResponseListData(SaxGolfUsgaCountry province, UsgaCountryListData data)
{
data.Id = SysId.ToString(country.Id);
data.Code = country.CountryCode;
data.Name = country.CountryName;
data.StatusCode = country.StatusCode;
data.StatusDesc = country.StatusDesc;
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 country, UsgaCountryItemData data)
private void PopulateUsgaCountryResponseItemData(SaxGolfUsgaCountry province, UsgaCountryItemData data)
{
PopulateUsgaCountryResponseListData(country, data);
PopulateUsgaCountryResponseListData(province, data);
}
//-------------------------------------------------------------------
private void PopulateCountryStatsData(UsgaCountryStatsData countryStats)
// 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;
countryStats.Total = ReferenceGolfMgr.GetUsgaCountryCount(prmCountry);
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;
countryStats.Active = ReferenceGolfMgr.GetUsgaCountryCount(prmCountry);
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;
countryStats.Inactive = ReferenceGolfMgr.GetUsgaCountryCount(prmCountry);
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;
countryStats.Deleted = ReferenceGolfMgr.GetUsgaCountryCount(prmCountry);
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;
countryStats.PriorityNoProvinces = ReferenceGolfMgr.GetUsgaCountryCount(prmCountry);
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;
countryStats.NonPriorityNoProvinces = ReferenceGolfMgr.GetUsgaCountryCount(prmCountry);
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;
countryStats.PriorityWithProvinces = ReferenceGolfMgr.GetUsgaCountryCount(prmCountry);
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;
countryStats.NonPriorityWithProvinces = ReferenceGolfMgr.GetUsgaCountryCount(prmCountry);
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;
}
//-------------------------------------------------------------------
@@ -116,13 +336,13 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
{
// Construction.
public AjaxResponse_ReferenceGolfList(SaxModel_Admin model) : base(model) { }
// ReferenceGolf list.
// Country list.
public List<UsgaCountryListData> Countries { get; } = new List<UsgaCountryListData>();
}
//-------------------------------------------------------------------
[HttpPost]
[Route("ReferenceGolf/Ajax/GetUsgaCountryList")]
[Route("ReferenceGolf/Ajax/GetUsgaCountryies")]
[Route("Reference/Golf/Ajax/GetUsgaCountryList")]
[Route("Reference/Golf/Ajax/GetUsgaCountryies")]
public IActionResult Ajax_GetUsgaCountryList(Model_ReferenceGolf model)
{
String fn = GetType().Name + ".Ajax_GetUsgaCountryList";
@@ -162,7 +382,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
{
NamedValue.Map values = resultSet.GetRecordValues();
ushort flags = (ushort)values.GetLong(colFlags.DataName);
UsgaCountryListData countryData = new UsgaCountryListData()
UsgaCountryListData provinceData = new UsgaCountryListData()
{
Id = values.GetString(colId.DataName),
Code = values.GetString(colName.DataName),
@@ -173,7 +393,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
StatusCode = values.GetString(colStatus.DataName),
StatusDesc = SacsSystem.GetStatusDescForCode(values.GetString(colStatus.DataName))
};
responseData.Countries.Add(countryData);
responseData.Countries.Add(provinceData);
}
}
if (model.Paging.IsPaged)
@@ -23,6 +23,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
//-------------------------------------------------------------------
[HttpGet]
[Route("Reference/Golf")]
public IActionResult Index()
{
// Validate session.
@@ -33,10 +34,10 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
// Paging.
Model_ReferenceGolf model = new Model_ReferenceGolf(Localiser);
model.Paging.PageNo = 1;
model.Paging.PageLength = 12;
//model.Paging.PageNo = 1;
//model.Paging.PageLength = 12;
return View(model);
return View("/Views/Reference/Golf/Index.cshtml",model);
}
//-------------------------------------------------------------------
@@ -123,6 +123,9 @@
<data name="caption.download.organisations" xml:space="preserve">
<value>Download Organisations</value>
</data>
<data name="caption.golf" xml:space="preserve">
<value>Golf</value>
</data>
<data name="caption.image.upload" xml:space="preserve">
<value>Image Upload</value>
</data>
@@ -531,6 +534,9 @@
<data name="label.sports" xml:space="preserve">
<value>Sports</value>
</data>
<data name="label.statictics" xml:space="preserve">
<value>Statistics</value>
</data>
<data name="label.status" xml:space="preserve">
<value>Status</value>
</data>
@@ -36,6 +36,10 @@
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Update="wwwroot\js\sax-ref-golf.js">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
</Project>
@@ -0,0 +1,95 @@
@model Model_ReferenceGolf
@inject SaxLocaliser Localiser
@{
/* Reference - Golf - Index */
ViewData["Title"] = "Reference - Golf";
}
<div class="sax-panel Golf">
<style type="text/css">
.GolfStats .GroupCaption
{
margin-top: 4px;
margin-bottom: 4px;
font-weight: 600;
text-align: center;
border-bottom: 1px solid slategray;
}
.GolfStats .StatCaption
{
color: slategray;
}
</style>
<div class="sax-panel-filter">
<div class="sax-header row">
<div class="col"><div class="sax-caption">@Localiser["caption.reference.golf"]</div></div>
<div class="fixed row">
<div class="sax-action sax-results-refresh"><img src="~/img/action/refresh24.png" alt="@(Localiser["label.refresh"])" title="@(Localiser["label.refresh"])" /></div>
</div>
</div>
<div class="sax-content">
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmRefGolfFilter", @class = "sax-form", @onSubmit = "return false;" }))
{
<div class="row">
<div class="col-sm-5 col-md-3 sax-label text-left text-sm-right">@Localiser["label.options"]</div>
<div class="col-sm-7 col-md-3 mb-sm-1 mb-md-0">
@* ToDo ... *@
</div>
</div>
}
</div>
</div>
@* Reference - Golf - Stats *@
<div class="sax-panel-info sax-panel-results GolfStats">
<div class="sax-header">
<div class="sax-caption">@Localiser["label.statictics"]</div>
</div>
<div class="sax-content">
<div class="sax-panel-messages"></div>
<div class="sax-panel-item-list row"></div>
</div>
<div class="sax-panel-item-template">
<div class="GolfStatGroup col-sm-12">
<div class="GroupCaption"></div>
</div>
</div>
<div class="sax-panel-item-template">
<div class="GolfStat col-sm-6">
<div class="row">
<div class="col-8 text-right pr-2"><div class="StatCaption"></div></div>
<div class="col-4"><div class="StatValue"></div></div>
</div>
</div>
</div>
</div>
<div class="sax-panel-results">
<div class="sax-panel-results">
<div class="sax-panel-messages"></div>
<div class="sax-panel-item-list"></div>
<div class="sax-panel-item-template">
<div class="sax-panel-item GolfCountry">
<div class="sax-header row">
<div class="col">
<div class="sax-caption"><div class="sax-action CountryName"></div></div>
</div>
<div class="fixed sax-actions">
</div>
</div>
<div class="sax-content">
<div class="row">
<div class="col-sm-6"><span class="Flags"></span></div>
<div class="col-sm-6 right"><span class="Status"></span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@@ -1,4 +1,5 @@
@model SaxModel_Admin
@model SaxModel_Admin
@inject Microsoft.AspNetCore.Antiforgery.IAntiforgery AntiForgery;
@inject SaxLocaliser Localiser
@*
@@ -135,6 +136,7 @@
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<div class="dropdown-item text-dark sax-action" onclick="sax.goToPage('Sport');">@Localiser["sport.caption.sports"]</div>
<div class="dropdown-item text-dark sax-action" onclick="sax.goToPage('Region');">@Localiser["region.caption.regions"]</div>
<div class="dropdown-item text-dark sax-action" onclick="sax.goToPage('Reference/Golf');">@Localiser["caption.golf"]</div>
</div>
</li>
<li class="nav-item dropdown">
@@ -0,0 +1,83 @@
/*
* Admin - User page scripts.
*/
(function (win, doc, undef)
{
"use strict";
let rg = sax.refGolf = sax.refGolf || { data: {}, fn: {}, $pnl: {}, $frm: {}, $dlg: {} };
//--------------------------------------------------------------
/* Reference - Golf - Stats. */
rg.fn.refreshStats = function (delay)
{
//sax.debug('refreshOrganisations');
rg.ajaxGolfStats = rg.ajaxGolfStats || { url: sax.url.base + 'Reference/Golf/Ajax/GetStats', formId: rg.$frm.filter.prop('id'), callbackFn: rg.fn.doRefreshStats };
sax.doAjaxRequest(rg.ajaxGolfStats, delay || 50);
}
rg.fn.doRefreshStats = function (response)
{
sax.debug('doRefreshStats', response);
if (!response.success) return;
let $msgs = $('.sax-panel-messages', rg.$pnl.stats).empty();
let $list = $('.sax-panel-item-list', rg.$pnl.stats).empty();
for (let groupIdx = 0; groupIdx < (response.groups || []).length; groupIdx++)
{
let group = response.groups[groupIdx];
$list.append(rg.fn.populateStatGroup(rg.fn.getStatGroupTemplate(), group.caption));
for (let statIdx = 0; statIdx < (group.stats || []).length; statIdx++)
{
let stat = group.stats[statIdx];
if (stat.value>0) $list.append(rg.fn.populateStat(rg.fn.getStatTemplate(), stat.caption, stat.value));
}
}
}
rg.fn.populateStatGroup=function($item, caption)
{
$('.GroupCaption', $item).text(caption);
return $item;
}
rg.fn.getStatGroupTemplate = function ()
{
return $('.sax-panel-item-template .GolfStatGroup', rg.$pnl.stats).clone();
}
rg.fn.populateStat = function ($item, caption, value)
{
$('.StatCaption', $item).text(caption);
$('.StatValue', $item).text(value);
return $item;
}
rg.fn.getStatTemplate = function ()
{
return $('.sax-panel-item-template .GolfStat', rg.$pnl.stats).clone();
}
//--------------------------------------------------------------
$(function ()
{
rg.$pnl.golf = $('.sax-panel.Golf');
rg.$pnl.filter = $('.sax-panel-filter', rg.$pnl.golf);
$('.sax-results-refresh', rg.$pnl.filter).on('click', rg.fn.refreshStats);
rg.$frm.filter = $('#frmRefGolfFilter', rg.$pnl.filter);
// Stats.
rg.$pnl.stats = $('.sax-panel-info.GolfStats', rg.$pnl.golf);
setTimeout(rg.fn.refreshStats, 250);
// Courses.
//$('.PagingPageNo', rg.$dlg).val(1);
//$('.PagingPageLength', rg.$dlg).val(16);
var opt = sax.dlgOpts();
//opt.open = function () { rg.fn.refreshOrganisations(200); };
//opt.buttons[sax.dlg.btn.ok] = function () { rg.fn.confirmSelection(); };
opt.buttons[sax.dlg.btn.cancel] = function () { rg.fn.cleanUp(); $(this).dialog('close'); };
//rg.$dlg = $('#dlgSelectOrganisation').dialog(opt);
});
//--------------------------------------------------------------
}(window, window.document));
/* The End */
+1 -1
View File
@@ -176,7 +176,7 @@ namespace Saxonite.Net.Standard.Base.App
public static class UsgaGolfDataLookup
{
public static bool Enabled { get; set; } = SacsSystem.DebugMode ? true : true;
public static int MinsBetweenExecution { get; set; } = SacsSystem.DebugMode ? 8 : 20;
public static int MinsBetweenExecution { get; set; } = SacsSystem.DebugMode ? 8 : 30;
public static int HoursBetweenCountryLookup { get; set; } = SacsSystem.DebugMode ? 24 : 24 * 5;
}
}
+1 -1
View File
@@ -18,7 +18,7 @@ namespace Saxonite.Net.Standard.Base.App
//-------------------------------------------------------------------
public static class Version
{
private static String version { get; } = "1.2.11.6";
private static String version { get; } = "1.2.11.7";
// Retrieve version.
public static String GetFullVersion () { return version; }
public static String GetAppVersion ()
@@ -309,6 +309,8 @@ namespace Saxonite.Net.Standard.Base.Bus.Reference
public String FacilityFilter { get; set; }
public String FacilityNameFull { get; set; }
public String FacilityNamePartial { get; set; }
// Associated data.
public BoolState HasCourses { get; set; } = BoolState.Either;
// Common properties.
public String NotesPartial { get; set; }
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
@@ -480,6 +480,13 @@ namespace Saxonite.Net.Standard.Dbas.Mgr.Reference
if (!StringUtil.IsEmpty(prm.FacilityNamePartial))
filter.Add($"{SaxDbDfn_Reference.GetColumnNameQual(SaxDbDfn_Reference.ColumnIdx.UsgaFacility_FacilityName, aliasUsgaFacility)} LIKE '%{DbQuery.FormatForLike(prm.FacilityNamePartial)}%'");
// Associated data.
if (prm.HasCourses != SacsHierarchyItem.Params.BoolState.Either)
{
String existsPrefix = (prm.HasCourses == SacsHierarchyItem.Params.BoolState.True ? "" : "Not ");
filter.Add($"{existsPrefix} Exists (Select 1 From {SaxDbDfn_Reference.GetTableNameQual(SaxDbDfn_Reference.TableIdx.UsgaCourse)} Where {SaxDbDfn_Reference.GetColumnNameQual(SaxDbDfn_Reference.ColumnIdx.UsgaCourse_FacilityId)}={col_Id})");
}
// Notes.
if (!StringUtil.IsEmpty(prm.NotesPartial))
filter.Add($"{SaxDbDfn_Reference.GetColumnNameQual(SaxDbDfn_Reference.ColumnIdx.UsgaFacility_Notes, aliasUsgaFacility)} LIKE '%{DbQuery.FormatForLike(prm.NotesPartial)}%'");