Files
Saxonite/Workspace/SaxoniteStandardBase/Base/Bus/Reference/SaxGolfUsgaMarker.cs
T
andy 9f22b522df v1.3.0 Restructure Saxonite workspace and upgrade to .NET 10 (#1)
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>
2026-10-16 18:24:16 +01:00

364 lines
10 KiB
C#

using NPOI.SS.Formula.Functions;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils;
using Saxonite.Net.Standard.Base.App;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Saxonite.Net.Standard.Base.Bus.Reference
{
//=======================================================================
// Golf - USGA Marker.
//=======================================================================
public abstract class SaxGolfUsgaMarker : SaxDisposableHierarchyItem
{
//-------------------------------------------------------------------
// Columns.
public enum Column
{
Pos,
Id,
CountryId,
Country_Name,
ProvinceId,
Province_Name,
FacilityId,
Facility_Name,
CourseId,
UsgaCourseId,
Course_Name,
UsgaMarkerId,
Caption,
Holes,
HolesCaption,
Tee,
Gender,
SlopeRating,
Par,
CourseRating,
BogeyRating,
Length,
// Associated data.
// Common.
Notes,
Flags,
Status,
Status_Desc,
Status_Ind,
CreateOn_Date,
UpdateOn_Date,
}
//-------------------------------------------------------------------
/// <summary>Properties other than common.</summary>
public class DataProperties
{
public SysId CourseId { get; set; }
public SysId UsgaMarkerId { 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; }
}
//-------------------------------------------------------------------
// Data.
public new class Data : SacsHierarchyItem.Data
{
// Data members.
private readonly DataProperties data = new DataProperties();
// Construction.
public Data()
{
Status = DefaultStatus;
}
// Properties.
public SysId CourseId
{
get { return data.CourseId; }
set { CheckChanged(data.CourseId, value); data.CourseId = value; }
}
public SysId UsgaMarkerId
{
get { return data.UsgaMarkerId; }
set { CheckChanged(data.UsgaMarkerId, value); data.UsgaMarkerId = value; }
}
public String Caption
{
get { return data.Caption; }
set { CheckChanged(data.Caption, value); data.Caption = value; }
}
public short Holes
{
get { return data.Holes; }
set { CheckChanged(data.Holes, value); data.Holes = value; }
}
public String HolesCaption
{
get { return data.HolesCaption; }
set { CheckChanged(data.HolesCaption, value); data.HolesCaption = value; }
}
public String Tee
{
get { return data.Tee; }
set { CheckChanged(data.Tee, value); data.Tee = value; }
}
public String Gender
{
get { return data.Gender; }
set { CheckChanged(data.Gender, value); data.Gender = value; }
}
public short SlopeRating
{
get { return data.SlopeRating; }
set { CheckChanged(data.SlopeRating, value); data.SlopeRating = value; }
}
public short Par
{
get { return data.Par; }
set { CheckChanged(data.Par, value); data.Par = value; }
}
public decimal CourseRating
{
get { return data.CourseRating; }
set { CheckChanged(data.CourseRating, value); data.CourseRating = value; }
}
public decimal BogeyRating
{
get { return data.BogeyRating; }
set { CheckChanged(data.BogeyRating, value); data.BogeyRating = value; }
}
public short Length
{
get { return data.Length; }
set { CheckChanged(data.Length, value); data.Length = value; }
}
// Population.
internal void PopulateFrom(Data data)
{
CourseId = data.CourseId;
UsgaMarkerId = data.UsgaMarkerId;
Caption = data.Caption;
Holes = data.Holes;
HolesCaption = data.HolesCaption;
Tee = data.Tee;
Gender = data.Gender;
SlopeRating = data.SlopeRating;
Par = data.Par;
CourseRating = data.CourseRating;
BogeyRating = data.BogeyRating;
Length = data.Length;
base.PopulateFrom(data);
}
public Data Clone()
{
Data data = new Data();
data.PopulateFrom(this);
return data;
}
}
//-------------------------------------------------------------------
// Error field - identify properties with validation error.
public new class ErrField : SacsHierarchyItem.ErrField
{
// Identifies the field that has invalid data.
public ValidValue CourseId { get; set; } = ValidValue.Valid;
public ValidValue UsgaMarkerId { get; set; } = ValidValue.Valid;
public ValidValue Caption { get; set; } = ValidValue.Valid;
public ValidValue Holes { get; set; } = ValidValue.Valid;
public ValidValue HolesCaption { get; set; } = ValidValue.Valid;
public ValidValue Tee { get; set; } = ValidValue.Valid;
public ValidValue Gender { get; set; } = ValidValue.Valid;
public ValidValue SlopeRating { get; set; } = ValidValue.Valid;
public ValidValue Par { get; set; } = ValidValue.Valid;
public ValidValue CourseRating { get; set; } = ValidValue.Valid;
public ValidValue BogeyRating { get; set; } = ValidValue.Valid;
public ValidValue Length { get; set; } = ValidValue.Valid;
}
//-------------------------------------------------------------------
// Data members.
private readonly Data data = new Data();
//-------------------------------------------------------------------
// Construction.
protected SaxGolfUsgaMarker(SysId id, SysId facilityId) : base(id)
{
base.SetData(data);
this.CourseId = facilityId;
Status = DefaultStatus;
}
//-------------------------------------------------------------------
// Status.
private static readonly List<SaStatus> validStatuses = new List<SaStatus>()
{
SaStatus.Active,
SaStatus.Inactive,
SaStatus.Deleted,
};
public static SaStatus DefaultStatus { get { return SaStatus.Active; } }
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(validStatuses); } }
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
{
if (status == SaStatus.Active) return DataValue.TriStateType.Green;
if (status == SaStatus.Inactive) return DataValue.TriStateType.Red;
if (status == SaStatus.Deleted) return DataValue.TriStateType.Purple;
return DataValue.TriStateType.Unknown;
}
//-------------------------------------------------------------------
// Utilities.
public ItemId GetItemId()
{
return new ItemId((short)Sax.DataItemType.Golf_UsgaMarker, Id);
}
//-------------------------------------------------------------------
// Properties.
public Data GetData() { return data.Clone(); }
public void SetData(Data data)
{
// Properties that cannot be changed if previously specified.
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
throw new NotSupportedException($"{SysUtil.Fn} Id cannot be changed");
this.data.PopulateFrom(data);
}
public SysId CourseId
{
get { return data.CourseId; }
set { data.CourseId = value; }
}
public SysId UsgaMarkerId
{
get { return data.UsgaMarkerId; }
set { data.UsgaMarkerId = value; }
}
public String Caption
{
get { return data.Caption; }
set { data.Caption = value; }
}
public short Holes
{
get { return data.Holes; }
set { data.Holes = value; }
}
public String HolesCaption
{
get { return data.HolesCaption; }
set { data.HolesCaption = value; }
}
public String Tee
{
get { return data.Tee; }
set { data.Tee = value; }
}
public String Gender
{
get { return data.Gender; }
set { data.Gender = value; }
}
public short SlopeRating
{
get { return data.SlopeRating; }
set { data.SlopeRating = value; }
}
public short Par
{
get { return data.Par; }
set { data.Par = value; }
}
public decimal CourseRating
{
get { return data.CourseRating; }
set { data.CourseRating = value; }
}
public decimal BogeyRating
{
get { return data.BogeyRating; }
set { data.BogeyRating = value; }
}
public short Length
{
get { return data.Length; }
set { data.Length = value; }
}
//-------------------------------------------------------------------
// Flags - positions 1-16 available.
//-------------------------------------------------------------------
// A s s o c i a t e d D a t a
//-------------------------------------------------------------------
//-------------------------------------------------------------------
// P a r a m s
//-------------------------------------------------------------------
// List parameters.
public enum StatusCat
{
NotDeleted = 0,
ActiveOnly,
InactiveOnly,
Any,
DeletedOnly,
}
/// <summary>
/// Item list parameters.
/// </summary>
public new class Params : SacsHierarchyItem.Params
{
// List filtering.
public List<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public List<SysId> CourseIdsIncluded { get; } = new List<SysId>();
/// <summary>USGA Marker Ids.</summary>
public List<SysId> UsgaMarkerIdsIncluded { get; } = new List<SysId>();
/// <summary>Generic filter - partial caption, holes, tee, gender etc.</summary>
public String MarkerFilter { get; set; }
// Marker proprerties.
public short Holes { get; set; }
public String Gender { get; set; }
// Common properties.
public String NotesPartial { get; set; }
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
// Table aliases - blank if not linked.
public String Alias_Country { get; set; }
public String Alias_Province { get; set; }
public String Alias_Facility { get; set; }
public String Alias_Course{ get; set; }
}
//-------------------------------------------------------------------
}
//=======================================================================
// Item list extension methods.
public static class SaxGolfUsgaMarkerList
{
//-------------------------------------------------------------------
public static SaxGolfUsgaMarker GetMarkerById(this IEnumerable<SaxGolfUsgaMarker> values, SysId markerId)
{
if (!SysId.IsValid(markerId)) return null;
foreach (SaxGolfUsgaMarker province in values)
if (province.Id.Equals(markerId)) return province;
return null;
}
//-------------------------------------------------------------------
}
//=======================================================================
}