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>
248 lines
9.4 KiB
C#
248 lines
9.4 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Sarand.Net.Standard.Base.App;
|
|
using Sarand.Net.Standard.Base.Bus;
|
|
using Sarand.Net.Standard.Base.Utils;
|
|
using Saxonite.Net.Standard.Base.App;
|
|
using Saxonite.Net.Standard.Base.Bus.Reference;
|
|
using Saxonite.Net.Standard.Base.Mgr.Reference;
|
|
using Saxonite.Web.Api.App;
|
|
using static Sarand.Net.Standard.Base.Helpers.SacsHttpClientHelper;
|
|
using static Saxonite.Net.Standard.Base.App.Sax.Config.Online;
|
|
|
|
namespace Saxonite.Web.Api.Controllers
|
|
{
|
|
//=======================================================================
|
|
[ApiController]
|
|
public class GolfController : SwapiControllerBase
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Construction.
|
|
public GolfController()
|
|
{
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// USGA Countries.
|
|
|
|
public class RequestData_UsgaCountries
|
|
{
|
|
public String? Search { get; set; }
|
|
public SaxGolfUsgaCountry.StatusCat? Status { get; set; } = SaxGolfUsgaCountry.StatusCat.ActiveOnly;
|
|
}
|
|
public class ResponseData_UsgaCountries : ApiResponse_Data
|
|
{
|
|
public class UsgaCountriesData
|
|
{
|
|
public long? Id { get; set; }
|
|
public String? Code { get; set; }
|
|
public String? Name { get; set; }
|
|
}
|
|
public List<UsgaCountriesData> UsgaCountries { get; } = new List<UsgaCountriesData>();
|
|
}
|
|
[HttpPost]
|
|
[Route("[controller]/UsgaCountries")]
|
|
public ResponseData_UsgaCountries GetUsgaCountries_Post(RequestData_UsgaCountries requestData)
|
|
{
|
|
ResponseData_UsgaCountries responseData = new ResponseData_UsgaCountries();
|
|
|
|
SaxGolfUsgaCountry.Params prmCountries = new SaxGolfUsgaCountry.Params();
|
|
prmCountries.CountryFilter = requestData.Search;
|
|
prmCountries.StatusCat = requestData.Status ?? SaxGolfUsgaCountry.StatusCat.NotDeleted;
|
|
foreach (SaxGolfUsgaCountry usgaCountry in ReferenceGolfMgr.GetUsgaCountryList(prmCountries))
|
|
{
|
|
ResponseData_UsgaCountries.UsgaCountriesData countryData = new ResponseData_UsgaCountries.UsgaCountriesData();
|
|
countryData.Id = SysId.ToLong(usgaCountry.Id);
|
|
if (!StringUtil.IsBlank(usgaCountry.CountryCode))
|
|
countryData.Code = usgaCountry.CountryCode;
|
|
if (!StringUtil.IsBlank(usgaCountry.CountryName))
|
|
countryData.Name = usgaCountry.CountryName;
|
|
responseData.UsgaCountries.Add(countryData);
|
|
}
|
|
|
|
return responseData;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// USGA Provinces.
|
|
|
|
public class RequestData_UsgaProvinces
|
|
{
|
|
public String? CountryId { get; set; }
|
|
public String? Search { get; set; }
|
|
public SaxGolfUsgaProvince.StatusCat? Status { get; set; } = SaxGolfUsgaProvince.StatusCat.ActiveOnly;
|
|
}
|
|
public class ResponseData_UsgaProvinces : ApiResponse_Data
|
|
{
|
|
public class UsgaProvinceData
|
|
{
|
|
public String? Id { get; set; }
|
|
public String? Code { get; set; }
|
|
public String? Name { get; set; }
|
|
}
|
|
public List<UsgaProvinceData> UsgaProvinces { get; } = new List<UsgaProvinceData>();
|
|
}
|
|
[HttpPost]
|
|
[Route("[controller]/UsgaProvinces")]
|
|
public ResponseData_UsgaProvinces GetUsgaProvinces_Post(RequestData_UsgaProvinces requestData)
|
|
{
|
|
ResponseData_UsgaProvinces responseData = new ResponseData_UsgaProvinces();
|
|
|
|
SysId countryId = SysId.ToSysId(requestData.CountryId);
|
|
if (SysId.IsValid(countryId))
|
|
{
|
|
SaxGolfUsgaProvince.Params prmProvinces = new SaxGolfUsgaProvince.Params();
|
|
prmProvinces.CountryIdsIncluded.Add(countryId);
|
|
prmProvinces.ProvinceFilter = requestData.Search;
|
|
prmProvinces.StatusCat = requestData.Status ?? SaxGolfUsgaProvince.StatusCat.NotDeleted;
|
|
foreach (SaxGolfUsgaProvince usgaProvince in ReferenceGolfMgr.GetUsgaProvinceList(prmProvinces))
|
|
{
|
|
ResponseData_UsgaProvinces.UsgaProvinceData provinceData = new ResponseData_UsgaProvinces.UsgaProvinceData();
|
|
provinceData.Id = SysId.ToString(usgaProvince.Id);
|
|
if (!StringUtil.IsBlank(usgaProvince.ProvinceCode))
|
|
provinceData.Code = usgaProvince.ProvinceCode;
|
|
if (!StringUtil.IsBlank(usgaProvince.ProvinceName))
|
|
provinceData.Name = usgaProvince.ProvinceName;
|
|
responseData.UsgaProvinces.Add(provinceData);
|
|
}
|
|
}
|
|
|
|
return responseData;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// USGA Courses.
|
|
|
|
public class RequestData_UsgaCourses
|
|
{
|
|
public String? ProvinceId { get; set; }
|
|
public String? Search { get; set; }
|
|
public SaxGolfUsgaCourse.StatusCat? Status { get; set; } = SaxGolfUsgaCourse.StatusCat.ActiveOnly;
|
|
}
|
|
public class ResponseData_UsgaCourses : ApiResponse_Data
|
|
{
|
|
public class UsgaCourseData
|
|
{
|
|
public String? Id { get; set; }
|
|
public String? Caption { get; set; }
|
|
public String? CourseName { get; set; }
|
|
public String? FullName { get; set; }
|
|
public String? Address1 { get; set; }
|
|
public String? Address2 { get; set; }
|
|
public String? City { get; set; }
|
|
}
|
|
public List<UsgaCourseData> UsgaCourses { get; } = new List<UsgaCourseData>();
|
|
}
|
|
[HttpPost]
|
|
[Route("[controller]/UsgaCourses")]
|
|
public ResponseData_UsgaCourses GetUsgaCourses_Post(RequestData_UsgaCourses requestData)
|
|
{
|
|
ResponseData_UsgaCourses responseData = new ResponseData_UsgaCourses();
|
|
|
|
SysId provinceId = SysId.ToSysId(requestData.ProvinceId);
|
|
if (SysId.IsValid(provinceId))
|
|
{
|
|
SaxGolfUsgaCourse.Params prmCourses = new SaxGolfUsgaCourse.Params();
|
|
prmCourses.ProvinceIdsIncluded.Add(provinceId);
|
|
prmCourses.CourseFilter = requestData.Search;
|
|
prmCourses.StatusCat = requestData.Status ?? SaxGolfUsgaCourse.StatusCat.NotDeleted;
|
|
foreach (SaxGolfUsgaCourse usgaCourse in ReferenceGolfMgr.GetUsgaCourseList(prmCourses))
|
|
{
|
|
ResponseData_UsgaCourses.UsgaCourseData provinceData = new ResponseData_UsgaCourses.UsgaCourseData();
|
|
provinceData.Id = SysId.ToString(usgaCourse.Id);
|
|
if (!StringUtil.IsBlank(usgaCourse.Caption))
|
|
provinceData.Caption = usgaCourse.Caption;
|
|
if (!StringUtil.IsBlank(usgaCourse.CourseName))
|
|
provinceData.CourseName = usgaCourse.CourseName;
|
|
if (!StringUtil.IsBlank(usgaCourse.FullName))
|
|
provinceData.FullName = usgaCourse.FullName;
|
|
if (!StringUtil.IsBlank(usgaCourse.Address1))
|
|
provinceData.Address1 = usgaCourse.Address1;
|
|
if (!StringUtil.IsBlank(usgaCourse.Address2))
|
|
provinceData.Address2 = usgaCourse.Address2;
|
|
if (!StringUtil.IsBlank(usgaCourse.City))
|
|
provinceData.City = usgaCourse.City;
|
|
responseData.UsgaCourses.Add(provinceData);
|
|
}
|
|
}
|
|
|
|
return responseData;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// USGA Markers.
|
|
|
|
public class RequestData_UsgaMarkers
|
|
{
|
|
public String? CourseId { get; set; }
|
|
public String? Search { get; set; }
|
|
public SaxGolfUsgaMarker.StatusCat? Status { get; set; } = SaxGolfUsgaMarker.StatusCat.ActiveOnly;
|
|
}
|
|
public class ResponseData_UsgaMarkers : ApiResponse_Data
|
|
{
|
|
public class UsgaMarkerData
|
|
{
|
|
public String? CourseId { get; set; }
|
|
public String? MarkerId { get; set; }
|
|
public String? Caption { get; set; }
|
|
public short? Holes { get; set; }
|
|
public String? HolesCaption { get; set; }
|
|
public String? Tee { get; set; }
|
|
public String? Gender { get; set; }
|
|
public short? SlopeRating { get; set; }
|
|
public short? Par { get; set; }
|
|
public decimal? CourseRating { get; set; }
|
|
public decimal? BogeyRating { get; set; }
|
|
public short? Length { get; set; }
|
|
}
|
|
public List<UsgaMarkerData> UsgaMarkers { get; } = new List<UsgaMarkerData>();
|
|
}
|
|
[HttpPost]
|
|
[Route("[controller]/UsgaMarkers")]
|
|
public ResponseData_UsgaMarkers GetUsgaMarkers_Post(RequestData_UsgaMarkers requestData)
|
|
{
|
|
ResponseData_UsgaMarkers responseData = new ResponseData_UsgaMarkers();
|
|
|
|
SysId courseId = SysId.ToSysId(requestData.CourseId);
|
|
if (SysId.IsValid(courseId))
|
|
{
|
|
SaxGolfUsgaMarker.Params prmMarkers = new SaxGolfUsgaMarker.Params();
|
|
prmMarkers.CourseIdsIncluded.Add(courseId);
|
|
prmMarkers.MarkerFilter = requestData.Search;
|
|
prmMarkers.StatusCat = requestData.Status ?? SaxGolfUsgaMarker.StatusCat.NotDeleted;
|
|
foreach (SaxGolfUsgaMarker usgaMarker in ReferenceGolfMgr.GetUsgaMarkerList(prmMarkers))
|
|
{
|
|
ResponseData_UsgaMarkers.UsgaMarkerData provinceData = new ResponseData_UsgaMarkers.UsgaMarkerData();
|
|
provinceData.CourseId = SysId.ToString(usgaMarker.CourseId);
|
|
provinceData.MarkerId = SysId.ToString(usgaMarker.Id);
|
|
if (!StringUtil.IsBlank(usgaMarker.Caption))
|
|
provinceData.Caption = usgaMarker.Caption;
|
|
if (usgaMarker.Holes > 0)
|
|
provinceData.Holes = usgaMarker.Holes;
|
|
if (!StringUtil.IsBlank(usgaMarker.HolesCaption))
|
|
provinceData.HolesCaption = usgaMarker.HolesCaption;
|
|
if (!StringUtil.IsBlank(usgaMarker.Tee))
|
|
provinceData.Tee = usgaMarker.Tee;
|
|
if (!StringUtil.IsBlank(usgaMarker.Gender))
|
|
provinceData.Gender = usgaMarker.Gender;
|
|
if (usgaMarker.SlopeRating > 0)
|
|
provinceData.SlopeRating = usgaMarker.SlopeRating;
|
|
if (usgaMarker.Par > 0)
|
|
provinceData.Par = usgaMarker.Par;
|
|
if (usgaMarker.CourseRating > 0)
|
|
provinceData.CourseRating = usgaMarker.CourseRating;
|
|
if (usgaMarker.BogeyRating > 0)
|
|
provinceData.BogeyRating = usgaMarker.BogeyRating;
|
|
if (usgaMarker.Length > 0)
|
|
provinceData.Length = usgaMarker.Length;
|
|
responseData.UsgaMarkers.Add(provinceData);
|
|
}
|
|
}
|
|
|
|
return responseData;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|