108 lines
4.4 KiB
C#
108 lines
4.4 KiB
C#
using Sarand.Net.Standard.Base.App;
|
|
using Sarand.Net.Standard.Base.Bus;
|
|
using Sarand.Net.Standard.Base.Core;
|
|
using Sarand.Net.Standard.Base.Utils;
|
|
using Saxonite.Base.App;
|
|
using Saxonite.Net.Core.Web.Base.App;
|
|
using Saxonite.Net.Core.Web.Base.Controllers;
|
|
using Saxonite.Net.Core.Web.Base.Models;
|
|
using Saxonite.Net.Standard.Base.App;
|
|
using Saxonite.Net.Standard.Base.Bus;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Saxonite.Net.Core.Web.Admin.Models
|
|
{
|
|
//=======================================================================
|
|
public class Model_Organisation : SaxModel_Admin
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Construction.
|
|
public Model_Organisation(SaxLocaliser localiser) :
|
|
base(localiser)
|
|
{
|
|
AdditionalFiles_JS.Add("js/sax-organisation.js");
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// List configuration.
|
|
public class FilterData
|
|
{
|
|
public String Organisation { get; set; }
|
|
public String OrganisationTypeCode { get; set; }
|
|
public String OrganisationCategoryCode { get; set; }
|
|
}
|
|
public FilterData Filter { get; } = new FilterData();
|
|
public Sax.OrganisationType FilterOrganisationType
|
|
{
|
|
get { return (Sax.OrganisationType)OrganisationTypeCodes.GetTypeForCode(Filter.OrganisationTypeCode); }
|
|
}
|
|
public Sax.OrganisationCategory FilterOrganisationCategory
|
|
{
|
|
get { return (Sax.OrganisationCategory)OrganisationCategoryCodes.GetTypeForCode(Filter.OrganisationCategoryCode); }
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Organisation properties.
|
|
public String OrganisationId { get; set; }
|
|
public String OrganisationName { get; set; }
|
|
public String OrganisationTypeValue { get; set; }
|
|
public Sax.OrganisationType OrganisationType { get { return (Sax.OrganisationType)OrganisationTypeCodes.GetTypeForCode(OrganisationTypeValue); } }
|
|
public String OrganisationCategoryValue { get; set; }
|
|
public Sax.OrganisationCategory OrganisationCategory { get { return (Sax.OrganisationCategory)OrganisationCategoryCodes.GetTypeForCode(OrganisationCategoryValue); } }
|
|
public String OrganisationSportId { get; set; }
|
|
public String OrganisationRegionId { get; set; }
|
|
// Common properties.
|
|
public String OrganisationNotes { get; set; }
|
|
public String OrganisationStatusCode { get; set; }
|
|
public SaStatus OrganisationStatus { get { return SacsSystem.GetStatusForCode(OrganisationStatusCode); } }
|
|
|
|
//-------------------------------------------------------------------
|
|
// Validation.
|
|
//-------------------------------------------------------------------
|
|
// Organisation validation.
|
|
public bool ValidateOrganisationData(SaxController_Base.AjaxResponse_Data responseData)
|
|
{
|
|
// Organisation name.
|
|
if (OrganisationName != null)
|
|
{
|
|
responseData.SetControlValue(nameof(OrganisationName), OrganisationName);
|
|
if (StringUtil.IsEmpty(OrganisationName))
|
|
responseData.SetControlError(nameof(OrganisationName), Localiser["msg.validation.mandatory.value"]);
|
|
else if (StringUtil.GetLength(OrganisationName) > GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.Organisation_Name))
|
|
responseData.SetControlError(nameof(OrganisationName), Localiser["msg.validation.maximum.length", GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.Organisation_Name)]);
|
|
}
|
|
|
|
// Organisation type.
|
|
if (OrganisationTypeValue != null)
|
|
{
|
|
if (StringUtil.IsEmpty(OrganisationTypeValue))
|
|
responseData.SetControlError(nameof(OrganisationTypeValue), Localiser["msg.validation.mandatory.value"]);
|
|
}
|
|
|
|
// Organisation category.
|
|
if (OrganisationCategoryValue != null)
|
|
{
|
|
if (StringUtil.IsEmpty(OrganisationCategoryValue))
|
|
responseData.SetControlError(nameof(OrganisationCategoryValue), Localiser["msg.validation.mandatory.value"]);
|
|
}
|
|
|
|
// Organisation status.
|
|
if (OrganisationStatusCode != null)
|
|
{
|
|
if (StringUtil.IsEmpty(OrganisationStatusCode))
|
|
responseData.SetControlError(nameof(OrganisationStatus), Localiser["msg.validation.mandatory.value"]);
|
|
else if (!SaxOrganisation.ValidStatuses.Contains(OrganisationStatus))
|
|
responseData.SetControlError(nameof(OrganisationStatus), Localiser["msg.validation.invalid.value"]);
|
|
}
|
|
|
|
return !responseData.HasControlErrors();
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|