1.2.11.4
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
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.Mgr.Reference
|
||||
{
|
||||
//=======================================================================
|
||||
public class SaxItemMgr_Reference : SaxItemMgr
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
protected SaxItemMgr_Reference(SaxSessionContext sessionContext, SaxInternals internals) :
|
||||
base(sessionContext, internals)
|
||||
{
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public ISacsDatabase ReferenceDatabase { get { return SaxGlobals.App.GetDatabase(SessionContext, Sax.Database.Reference); } }
|
||||
public IDatabaseInfo ReferenceDbInfo { get { return SaxGlobals.App.CreateDbInfo(SessionContext, Sax.Database.Reference); } }
|
||||
// Managers.
|
||||
public SaxReferenceGolfMgr ReferenceGolfMgr { get { return Internals.ReferenceGolfMgr; } }
|
||||
// Application codes.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
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 Saxonite.Base.App;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using Saxonite.Net.Standard.Base.Bus.Reference;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Mgr.Reference
|
||||
{
|
||||
//=======================================================================
|
||||
partial class SaxReferenceGolfMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// Reference Mgr - Golf - USGA Country
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxGolfUsgaCountry CreateUsgaCountry();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool UsgaCountryExistsById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
SaxGolfUsgaCountry.Params prmUsgaCountry = new SaxGolfUsgaCountry.Params();
|
||||
prmUsgaCountry.IdsIncluded.Add(id);
|
||||
prmUsgaCountry.StatusCat = SaxGolfUsgaCountry.StatusCat.Any;
|
||||
return GetUsgaCountryCount(prmUsgaCountry) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxGolfUsgaCountry GetUsgaCountry(SaxGolfUsgaCountry.Params prmUsgaCountry);
|
||||
public SaxGolfUsgaCountry GetUsgaCountryById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
SaxGolfUsgaCountry.Params prmUsgaCountry = new SaxGolfUsgaCountry.Params();
|
||||
prmUsgaCountry.IdsIncluded.Add(id);
|
||||
prmUsgaCountry.StatusCat = SaxGolfUsgaCountry.StatusCat.Any;
|
||||
return GetUsgaCountry(prmUsgaCountry);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidUsgaCountry(SaxGolfUsgaCountry usgaCountry)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (usgaCountry == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidUsgaCountryData(usgaCountry.GetData(), new SaxGolfUsgaCountry.ErrField());
|
||||
}
|
||||
public virtual bool IsValidUsgaCountryData(SaxGolfUsgaCountry.Data data, SaxGolfUsgaCountry.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Country code.
|
||||
if (errField.CountryCode != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.CountryCode, "code", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCountry_CountryCode), true))
|
||||
{
|
||||
errField.CountryCode = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// ENT Country code.
|
||||
if (errField.EntCountryCode != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.EntCountryCode, "ent code", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCountry_EntCountryCode)))
|
||||
{
|
||||
errField.EntCountryCode = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Country name.
|
||||
if (errField.CountryName != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.CountryName, "name", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCountry_CountryName), true))
|
||||
{
|
||||
errField.CountryName = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCountry_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCountry_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxGolfUsgaCountry.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item database interface.
|
||||
public abstract bool InsertUsgaCountry(SaxGolfUsgaCountry usgaCountry, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateUsgaCountry(SaxGolfUsgaCountry usgaCountry, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool UsgaCountryCanBeDeleted(SaxGolfUsgaCountry usgaCountry)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteUsgaCountry(SaxGolfUsgaCountry usgaCountry, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Bulk updates.
|
||||
public class UsgaCountryData
|
||||
{
|
||||
public String CountryCode { get; set; }
|
||||
public String EntCountryCode { get; set; } = null;
|
||||
public String CountryName { get; set; } = null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Bulk update USGA Countries.
|
||||
/// <para>- Country code must be supplied to act as identifier.</para>
|
||||
/// <para>- Other properties are validated as per country rules - check error state.</para>
|
||||
/// <para>- Other properties are left as is if null.</para>
|
||||
/// </summary>
|
||||
public abstract bool BulkUpdateUsgaCountries(List<UsgaCountryData> countries, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
public abstract ColumnDfn GetUsgaCountryColumnDfn(SaxGolfUsgaCountry.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetUsgaCountryQueryFilter(SaxGolfUsgaCountry.Params prmUsgaCountry);
|
||||
public abstract long GetUsgaCountryCount(SaxGolfUsgaCountry.Params prmUsgaCountry);
|
||||
public long GetActiveUsgaCountryCount() { return GetUsgaCountryCount(new SaxGolfUsgaCountry.Params()); }
|
||||
public abstract List<SaxGolfUsgaCountry> GetUsgaCountryList(SaxGolfUsgaCountry.Params prmUsgaCountry);
|
||||
public abstract DbResultSet ExecuteUsgaCountryQuery(List<ColumnDfn> columns, SaxGolfUsgaCountry.Params prmUsgaCountry);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract and format result set data value where specific handling is required.
|
||||
/// <para>Where response is an invalid data value, format value using column.FormatValue(values).</para>
|
||||
/// </summary>
|
||||
public virtual DataValue GetUsgaCountryDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxGolfUsgaCountry.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Notes.
|
||||
case SaxGolfUsgaCountry.Column.Notes:
|
||||
{
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxGolfUsgaCountry.Column.Status_Desc:
|
||||
case SaxGolfUsgaCountry.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxGolfUsgaCountry.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxGolfUsgaCountry.Column.Status_Ind)
|
||||
value = new DataValue(SaxGolfUsgaCountry.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,257 @@
|
||||
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 Saxonite.Base.App;
|
||||
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;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Mgr.Reference
|
||||
{
|
||||
//=======================================================================
|
||||
partial class SaxReferenceGolfMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// Reference Mgr - Golf - USGA Course
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxGolfUsgaCourse CreateUsgaCourse(SysId facilityId);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool UsgaCourseExistsById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
SaxGolfUsgaCourse.Params prmUsgaCourse = new SaxGolfUsgaCourse.Params();
|
||||
prmUsgaCourse.IdsIncluded.Add(id);
|
||||
prmUsgaCourse.StatusCat = SaxGolfUsgaCourse.StatusCat.Any;
|
||||
return GetUsgaCourseCount(prmUsgaCourse) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxGolfUsgaCourse GetUsgaCourse(SaxGolfUsgaCourse.Params prmUsgaCourse);
|
||||
public SaxGolfUsgaCourse GetUsgaCourseById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
SaxGolfUsgaCourse.Params prmUsgaCourse = new SaxGolfUsgaCourse.Params();
|
||||
prmUsgaCourse.IdsIncluded.Add(id);
|
||||
prmUsgaCourse.StatusCat = SaxGolfUsgaCourse.StatusCat.Any;
|
||||
return GetUsgaCourse(prmUsgaCourse);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidUsgaCourse(SaxGolfUsgaCourse usgaCourse)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (usgaCourse == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidUsgaCourseData(usgaCourse.GetData(), new SaxGolfUsgaCourse.ErrField());
|
||||
}
|
||||
public virtual bool IsValidUsgaCourseData(SaxGolfUsgaCourse.Data data, SaxGolfUsgaCourse.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Facility.
|
||||
if (errField.FacilityId != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.FacilityId))
|
||||
{
|
||||
errField.FacilityId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Facility must be specified");
|
||||
}
|
||||
// Course Id.
|
||||
if (errField.CourseId != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.CourseId))
|
||||
{
|
||||
errField.CourseId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Course Id must be specified");
|
||||
}
|
||||
// Caption.
|
||||
if (errField.Caption != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Caption, "caption", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCourse_Caption), true))
|
||||
{
|
||||
errField.Caption = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Course name.
|
||||
if (errField.CourseName != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.CourseName, "name", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCourse_CourseName), true))
|
||||
{
|
||||
errField.CourseName = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Full name.
|
||||
if (errField.FullName != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.FullName, "full name", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCourse_FullName)))
|
||||
{
|
||||
errField.FullName = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Address line 1.
|
||||
if (errField.Address1 != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Address1, "address line 1", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCourse_Address1)))
|
||||
{
|
||||
errField.Address1 = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Address line 2.
|
||||
if (errField.Address2 != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Address2, "address line 2", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCourse_Address2)))
|
||||
{
|
||||
errField.Address2 = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// City.
|
||||
if (errField.City != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.City, "city", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCourse_City)))
|
||||
{
|
||||
errField.City = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Email.
|
||||
if (errField.Email != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Email, "email", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCourse_Email)))
|
||||
{
|
||||
errField.Email = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Telephone.
|
||||
if (errField.Telephone != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Telephone, "telephone", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCourse_Telephone)))
|
||||
{
|
||||
errField.Telephone = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCourse_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaCourse_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxGolfUsgaCourse.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Associated data - ignore for deleted items.
|
||||
if (!data.IsStatusDeleted)
|
||||
{
|
||||
|
||||
// Facility.
|
||||
if (errField.FacilityId != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.FacilityId))
|
||||
{
|
||||
SaxGolfUsgaFacility.Params prmFacility = new SaxGolfUsgaFacility.Params();
|
||||
prmFacility.IdsIncluded.Add(data.FacilityId);
|
||||
prmFacility.StatusCat = SaxGolfUsgaFacility.StatusCat.NotDeleted;
|
||||
if (ReferenceGolfMgr.GetUsgaFacilityCount(prmFacility) < 1)
|
||||
{
|
||||
errField.FacilityId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid course specified");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item database interface.
|
||||
public abstract bool InsertUsgaCourse(SaxGolfUsgaCourse usgaCourse, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateUsgaCourse(SaxGolfUsgaCourse usgaCourse, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool UsgaCourseCanBeDeleted(SaxGolfUsgaCourse usgaCourse)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteUsgaCourse(SaxGolfUsgaCourse usgaCourse, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Bulk updates.
|
||||
public class UsgaCourseData
|
||||
{
|
||||
public SysId FacilityId { get; set; }
|
||||
public SysId CourseId { get; set; }
|
||||
public SysId LegacyCrpCourseId { 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 string Email { get; set; }
|
||||
public string Telephone { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Bulk update USGA Courses.
|
||||
/// <para>- Facility code must be supplied to identify parent.</para>
|
||||
/// <para>- Course Id must be supplied to act as identifier.</para>
|
||||
/// <para>- Other properties are validated as per province rules - check error state.</para>
|
||||
/// <para>- Other properties are left as is if null.</para>
|
||||
/// </summary>
|
||||
public abstract bool BulkUpdateUsgaCourses(List<UsgaCourseData> courses, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
public abstract ColumnDfn GetUsgaCourseColumnDfn(SaxGolfUsgaCourse.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetUsgaCourseQueryFilter(SaxGolfUsgaCourse.Params prmUsgaCourse);
|
||||
public abstract long GetUsgaCourseCount(SaxGolfUsgaCourse.Params prmUsgaCourse);
|
||||
public abstract List<SaxGolfUsgaCourse> GetUsgaCourseList(SaxGolfUsgaCourse.Params prmUsgaCourse);
|
||||
public abstract DbResultSet ExecuteUsgaCourseQuery(List<ColumnDfn> columns, SaxGolfUsgaCourse.Params prmUsgaCourse);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract and format result set data value where specific handling is required.
|
||||
/// <para>Where response is an invalid data value, format value using column.FormatValue(values).</para>
|
||||
/// </summary>
|
||||
public virtual DataValue GetUsgaCourseDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxGolfUsgaCourse.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Notes.
|
||||
case SaxGolfUsgaCourse.Column.Notes:
|
||||
{
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxGolfUsgaCourse.Column.Status_Desc:
|
||||
case SaxGolfUsgaCourse.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxGolfUsgaCourse.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxGolfUsgaCourse.Column.Status_Ind)
|
||||
value = new DataValue(SaxGolfUsgaCourse.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
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 Saxonite.Base.App;
|
||||
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;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Mgr.Reference
|
||||
{
|
||||
//=======================================================================
|
||||
partial class SaxReferenceGolfMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// Reference Mgr - Golf - USGA Facility
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxGolfUsgaFacility CreateUsgaFacility(SysId provinceId);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool UsgaFacilityExistsById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
SaxGolfUsgaFacility.Params prmUsgaFacility = new SaxGolfUsgaFacility.Params();
|
||||
prmUsgaFacility.IdsIncluded.Add(id);
|
||||
prmUsgaFacility.StatusCat = SaxGolfUsgaFacility.StatusCat.Any;
|
||||
return GetUsgaFacilityCount(prmUsgaFacility) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxGolfUsgaFacility GetUsgaFacility(SaxGolfUsgaFacility.Params prmUsgaFacility);
|
||||
public SaxGolfUsgaFacility GetUsgaFacilityById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
SaxGolfUsgaFacility.Params prmUsgaFacility = new SaxGolfUsgaFacility.Params();
|
||||
prmUsgaFacility.IdsIncluded.Add(id);
|
||||
prmUsgaFacility.StatusCat = SaxGolfUsgaFacility.StatusCat.Any;
|
||||
return GetUsgaFacility(prmUsgaFacility);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidUsgaFacility(SaxGolfUsgaFacility usgaFacility)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (usgaFacility == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidUsgaFacilityData(usgaFacility.GetData(), new SaxGolfUsgaFacility.ErrField());
|
||||
}
|
||||
public virtual bool IsValidUsgaFacilityData(SaxGolfUsgaFacility.Data data, SaxGolfUsgaFacility.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Province.
|
||||
if (errField.ProvinceId != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.ProvinceId))
|
||||
{
|
||||
errField.ProvinceId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Province must be specified");
|
||||
}
|
||||
// Facility code.
|
||||
if (errField.FacilityId != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.FacilityId))
|
||||
{
|
||||
errField.FacilityId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Facility Id must be specified");
|
||||
}
|
||||
// Facility name.
|
||||
if (errField.FacilityName != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.FacilityName, "name", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaFacility_FacilityName), true))
|
||||
{
|
||||
errField.FacilityName = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaFacility_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaFacility_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxGolfUsgaFacility.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Associated data - ignore for deleted items.
|
||||
if (!data.IsStatusDeleted)
|
||||
{
|
||||
|
||||
// Province.
|
||||
if (errField.ProvinceId != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.ProvinceId))
|
||||
{
|
||||
SaxGolfUsgaProvince.Params prmProvince = new SaxGolfUsgaProvince.Params();
|
||||
prmProvince.IdsIncluded.Add(data.ProvinceId);
|
||||
prmProvince.StatusCat = SaxGolfUsgaProvince.StatusCat.NotDeleted;
|
||||
if (ReferenceGolfMgr.GetUsgaProvinceCount(prmProvince) < 1)
|
||||
{
|
||||
errField.ProvinceId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid province specified");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item database interface.
|
||||
public abstract bool InsertUsgaFacility(SaxGolfUsgaFacility usgaFacility, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateUsgaFacility(SaxGolfUsgaFacility usgaFacility, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool UsgaFacilityCanBeDeleted(SaxGolfUsgaFacility usgaFacility)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteUsgaFacility(SaxGolfUsgaFacility usgaFacility, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Bulk updates.
|
||||
public class UsgaFacilityData
|
||||
{
|
||||
public String ProvinceCode { get; set; }
|
||||
public SysId FacilityId { get; set; }
|
||||
public String FacilityName { get; set; } = null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Bulk update USGA Facilities.
|
||||
/// <para>- Province code must be supplied to identify parent.</para>
|
||||
/// <para>- Facility Id must be supplied to act as identifier.</para>
|
||||
/// <para>- Other properties are validated as per province rules - check error state.</para>
|
||||
/// <para>- Other properties are left as is if null.</para>
|
||||
/// </summary>
|
||||
public abstract bool BulkUpdateUsgaFacilities(List<UsgaFacilityData> facilities, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
public abstract ColumnDfn GetUsgaFacilityColumnDfn(SaxGolfUsgaFacility.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetUsgaFacilityQueryFilter(SaxGolfUsgaFacility.Params prmUsgaFacility);
|
||||
public abstract long GetUsgaFacilityCount(SaxGolfUsgaFacility.Params prmUsgaFacility);
|
||||
public abstract List<SaxGolfUsgaFacility> GetUsgaFacilityList(SaxGolfUsgaFacility.Params prmUsgaFacility);
|
||||
public abstract DbResultSet ExecuteUsgaFacilityQuery(List<ColumnDfn> columns, SaxGolfUsgaFacility.Params prmUsgaFacility);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract and format result set data value where specific handling is required.
|
||||
/// <para>Where response is an invalid data value, format value using column.FormatValue(values).</para>
|
||||
/// </summary>
|
||||
public virtual DataValue GetUsgaFacilityDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxGolfUsgaFacility.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Notes.
|
||||
case SaxGolfUsgaFacility.Column.Notes:
|
||||
{
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxGolfUsgaFacility.Column.Status_Desc:
|
||||
case SaxGolfUsgaFacility.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxGolfUsgaFacility.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxGolfUsgaFacility.Column.Status_Ind)
|
||||
value = new DataValue(SaxGolfUsgaFacility.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,258 @@
|
||||
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 Saxonite.Base.App;
|
||||
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;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Mgr.Reference
|
||||
{
|
||||
//=======================================================================
|
||||
partial class SaxReferenceGolfMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// Reference Mgr - Golf - USGA Marker
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxGolfUsgaMarker CreateUsgaMarker(SysId courseId);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool UsgaMarkerExistsById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
SaxGolfUsgaMarker.Params prmUsgaMarker = new SaxGolfUsgaMarker.Params();
|
||||
prmUsgaMarker.IdsIncluded.Add(id);
|
||||
prmUsgaMarker.StatusCat = SaxGolfUsgaMarker.StatusCat.Any;
|
||||
return GetUsgaMarkerCount(prmUsgaMarker) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxGolfUsgaMarker GetUsgaMarker(SaxGolfUsgaMarker.Params prmUsgaMarker);
|
||||
public SaxGolfUsgaMarker GetUsgaMarkerById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
SaxGolfUsgaMarker.Params prmUsgaMarker = new SaxGolfUsgaMarker.Params();
|
||||
prmUsgaMarker.IdsIncluded.Add(id);
|
||||
prmUsgaMarker.StatusCat = SaxGolfUsgaMarker.StatusCat.Any;
|
||||
return GetUsgaMarker(prmUsgaMarker);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidUsgaMarker(SaxGolfUsgaMarker usgaMarker)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (usgaMarker == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidUsgaMarkerData(usgaMarker.GetData(), new SaxGolfUsgaMarker.ErrField());
|
||||
}
|
||||
public virtual bool IsValidUsgaMarkerData(SaxGolfUsgaMarker.Data data, SaxGolfUsgaMarker.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Course.
|
||||
if (errField.CourseId != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.CourseId))
|
||||
{
|
||||
errField.CourseId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Course must be specified");
|
||||
}
|
||||
// Marker Id.
|
||||
if (errField.MarkerId != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.MarkerId))
|
||||
{
|
||||
errField.MarkerId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Marker Id must be specified");
|
||||
}
|
||||
// Caption.
|
||||
if (errField.Caption != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Caption, "caption", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaMarker_Caption), true))
|
||||
{
|
||||
errField.Caption = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Holes.
|
||||
if (errField.Holes != SacsHierarchyItem.ValidValue.Ignore && data.Holes < 1)
|
||||
{
|
||||
errField.HolesCaption = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Holes must be specified");
|
||||
}
|
||||
// Holes caption.
|
||||
if (errField.HolesCaption != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.HolesCaption, "holes caption", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaMarker_HolesCaption)))
|
||||
{
|
||||
errField.HolesCaption = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Tee.
|
||||
if (errField.Tee != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Tee, "tee", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaMarker_Tee), true))
|
||||
{
|
||||
errField.Tee = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Gender.
|
||||
if (errField.Gender != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Gender, "gender", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaMarker_Gender)))
|
||||
{
|
||||
errField.Gender = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Slope Rating.
|
||||
if (errField.SlopeRating != SacsHierarchyItem.ValidValue.Ignore && data.SlopeRating < 1)
|
||||
{
|
||||
errField.SlopeRating = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Slope rating must be specified");
|
||||
}
|
||||
// Par.
|
||||
if (errField.Par != SacsHierarchyItem.ValidValue.Ignore && data.Par < 1)
|
||||
{
|
||||
errField.Par = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Par must be specified");
|
||||
}
|
||||
// Course Rating.
|
||||
if (errField.CourseRating != SacsHierarchyItem.ValidValue.Ignore && data.CourseRating < 1)
|
||||
{
|
||||
errField.CourseRating = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Course rating must be specified");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaMarker_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaMarker_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxGolfUsgaMarker.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Associated data - ignore for deleted items.
|
||||
if (!data.IsStatusDeleted)
|
||||
{
|
||||
|
||||
// Course.
|
||||
if (errField.CourseId != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.CourseId))
|
||||
{
|
||||
SaxGolfUsgaCourse.Params prmCourse = new SaxGolfUsgaCourse.Params();
|
||||
prmCourse.IdsIncluded.Add(data.CourseId);
|
||||
prmCourse.StatusCat = SaxGolfUsgaCourse.StatusCat.NotDeleted;
|
||||
if (ReferenceGolfMgr.GetUsgaCourseCount(prmCourse) < 1)
|
||||
{
|
||||
errField.CourseId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid marker specified");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item database interface.
|
||||
public abstract bool InsertUsgaMarker(SaxGolfUsgaMarker usgaMarker, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateUsgaMarker(SaxGolfUsgaMarker usgaMarker, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool UsgaMarkerCanBeDeleted(SaxGolfUsgaMarker usgaMarker)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteUsgaMarker(SaxGolfUsgaMarker usgaMarker, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Bulk updates.
|
||||
public class UsgaMarkerData
|
||||
{
|
||||
public SysId CourseId { get; set; }
|
||||
public SysId 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; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Bulk update USGA Markers.
|
||||
/// <para>- Course Id must be supplied to identify parent.</para>
|
||||
/// <para>- Marker Id must be supplied to act as identifier.</para>
|
||||
/// <para>- Other properties are validated as per merker rules - check error state.</para>
|
||||
/// <para>- Other properties are left as is if null.</para>
|
||||
/// </summary>
|
||||
public abstract bool BulkUpdateUsgaMarkers(List<UsgaMarkerData> markers, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
public abstract ColumnDfn GetUsgaMarkerColumnDfn(SaxGolfUsgaMarker.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetUsgaMarkerQueryFilter(SaxGolfUsgaMarker.Params prmUsgaMarker);
|
||||
public abstract long GetUsgaMarkerCount(SaxGolfUsgaMarker.Params prmUsgaMarker);
|
||||
public abstract List<SaxGolfUsgaMarker> GetUsgaMarkerList(SaxGolfUsgaMarker.Params prmUsgaMarker);
|
||||
public abstract DbResultSet ExecuteUsgaMarkerQuery(List<ColumnDfn> columns, SaxGolfUsgaMarker.Params prmUsgaMarker);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract and format result set data value where specific handling is required.
|
||||
/// <para>Where response is an invalid data value, format value using column.FormatValue(values).</para>
|
||||
/// </summary>
|
||||
public virtual DataValue GetUsgaMarkerDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxGolfUsgaMarker.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Notes.
|
||||
case SaxGolfUsgaMarker.Column.Notes:
|
||||
{
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxGolfUsgaMarker.Column.Status_Desc:
|
||||
case SaxGolfUsgaMarker.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxGolfUsgaMarker.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxGolfUsgaMarker.Column.Status_Ind)
|
||||
value = new DataValue(SaxGolfUsgaMarker.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
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 Saxonite.Base.App;
|
||||
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;
|
||||
|
||||
namespace Saxonite.Net.Standard.Base.Mgr.Reference
|
||||
{
|
||||
//=======================================================================
|
||||
partial class SaxReferenceGolfMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// Reference Mgr - Golf - USGA Province
|
||||
//*******************************************************************
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SaxGolfUsgaProvince CreateUsgaProvince(SysId countryId);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item exists.
|
||||
public bool UsgaProvinceExistsById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
SaxGolfUsgaProvince.Params prmUsgaProvince = new SaxGolfUsgaProvince.Params();
|
||||
prmUsgaProvince.IdsIncluded.Add(id);
|
||||
prmUsgaProvince.StatusCat = SaxGolfUsgaProvince.StatusCat.Any;
|
||||
return GetUsgaProvinceCount(prmUsgaProvince) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
public abstract SaxGolfUsgaProvince GetUsgaProvince(SaxGolfUsgaProvince.Params prmUsgaProvince);
|
||||
public SaxGolfUsgaProvince GetUsgaProvinceById(SysId id)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
SaxGolfUsgaProvince.Params prmUsgaProvince = new SaxGolfUsgaProvince.Params();
|
||||
prmUsgaProvince.IdsIncluded.Add(id);
|
||||
prmUsgaProvince.StatusCat = SaxGolfUsgaProvince.StatusCat.Any;
|
||||
return GetUsgaProvince(prmUsgaProvince);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidUsgaProvince(SaxGolfUsgaProvince usgaProvince)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (usgaProvince == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidUsgaProvinceData(usgaProvince.GetData(), new SaxGolfUsgaProvince.ErrField());
|
||||
}
|
||||
public virtual bool IsValidUsgaProvinceData(SaxGolfUsgaProvince.Data data, SaxGolfUsgaProvince.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Country.
|
||||
if (errField.CountryId != SacsHierarchyItem.ValidValue.Ignore && !SysId.IsValid(data.CountryId))
|
||||
{
|
||||
errField.CountryId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Country must be specified");
|
||||
}
|
||||
// Province code.
|
||||
if (errField.ProvinceCode != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.ProvinceCode, "code", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaProvince_ProvinceCode), true))
|
||||
{
|
||||
errField.ProvinceCode = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// ENT Province code.
|
||||
if (errField.EntProvinceCode != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.EntProvinceCode, "ENT code", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaProvince_EntProvinceCode), true))
|
||||
{
|
||||
errField.EntProvinceCode = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
// Province name.
|
||||
if (errField.ProvinceName != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.ProvinceName, "name", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaProvince_ProvinceName), true))
|
||||
{
|
||||
errField.ProvinceName = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Common properties.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaProvince_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SaxDbDfn_Reference.GetColTextLen(SaxDbDfn_Reference.ColumnIdx.UsgaProvince_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SaxGolfUsgaProvince.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Associated data - ignore for deleted items.
|
||||
if (!data.IsStatusDeleted)
|
||||
{
|
||||
|
||||
// Country.
|
||||
if (errField.CountryId != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.CountryId))
|
||||
{
|
||||
SaxGolfUsgaCountry.Params prmCountry = new SaxGolfUsgaCountry.Params();
|
||||
prmCountry.IdsIncluded.Add(data.CountryId);
|
||||
prmCountry.StatusCat = SaxGolfUsgaCountry.StatusCat.NotDeleted;
|
||||
if (ReferenceGolfMgr.GetUsgaCountryCount(prmCountry) < 1)
|
||||
{
|
||||
errField.CountryId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid country specified");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item database interface.
|
||||
public abstract bool InsertUsgaProvince(SaxGolfUsgaProvince usgaProvince, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateUsgaProvince(SaxGolfUsgaProvince usgaProvince, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool UsgaProvinceCanBeDeleted(SaxGolfUsgaProvince usgaProvince)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteUsgaProvince(SaxGolfUsgaProvince usgaProvince, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Bulk updates.
|
||||
public class UsgaProvinceData
|
||||
{
|
||||
public String CountryCode { get; set; }
|
||||
public String ProvinceCode { get; set; }
|
||||
public String EntProvinceCode { get; set; } = null;
|
||||
public String ProvinceName { get; set; } = null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Bulk update USGA Provinces.
|
||||
/// <para>- Country code must be supplied to identify parent.</para>
|
||||
/// <para>- Province code must be supplied to act as identifier.</para>
|
||||
/// <para>- Other properties are validated as per province rules - check error state.</para>
|
||||
/// <para>- Other properties are left as is if null.</para>
|
||||
/// </summary>
|
||||
public abstract bool BulkUpdateUsgaProvinces(List<UsgaProvinceData> provinces, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
public abstract ColumnDfn GetUsgaProvinceColumnDfn(SaxGolfUsgaProvince.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetUsgaProvinceQueryFilter(SaxGolfUsgaProvince.Params prmUsgaProvince);
|
||||
public abstract long GetUsgaProvinceCount(SaxGolfUsgaProvince.Params prmUsgaProvince);
|
||||
public abstract List<SaxGolfUsgaProvince> GetUsgaProvinceList(SaxGolfUsgaProvince.Params prmUsgaProvince);
|
||||
public abstract DbResultSet ExecuteUsgaProvinceQuery(List<ColumnDfn> columns, SaxGolfUsgaProvince.Params prmUsgaProvince);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Extract and format result set data value where specific handling is required.
|
||||
/// <para>Where response is an invalid data value, format value using column.FormatValue(values).</para>
|
||||
/// </summary>
|
||||
public virtual DataValue GetUsgaProvinceDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SaxGolfUsgaProvince.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Notes.
|
||||
case SaxGolfUsgaProvince.Column.Notes:
|
||||
{
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Status.
|
||||
case SaxGolfUsgaProvince.Column.Status_Desc:
|
||||
case SaxGolfUsgaProvince.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SaxGolfUsgaProvince.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDesc(status));
|
||||
else if (column.Id == (int)SaxGolfUsgaProvince.Column.Status_Ind)
|
||||
value = new DataValue(SaxGolfUsgaProvince.GetStatusTriState(status));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
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.Mgr.Reference
|
||||
{
|
||||
//=======================================================================
|
||||
public abstract partial class SaxReferenceGolfMgr : SaxItemMgr_Reference
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
protected SaxReferenceGolfMgr(SaxSessionContext sessionContext, SaxInternals internals) :
|
||||
base(sessionContext, internals)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
Reference in New Issue
Block a user