v1.1.1.0
This commit is contained in:
@@ -33,9 +33,9 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
// Sport.
|
||||
public long SportId { get; set; }
|
||||
public String SportName { get; set; }
|
||||
// Region.
|
||||
public long RegionId { get; set; }
|
||||
public String RegionName { get; set; }
|
||||
// Region - country.
|
||||
public long RegionIdCountry { get; set; }
|
||||
public String RegionNameCountry { get; set; }
|
||||
// Common properties.
|
||||
public String StatusCode { get; set; }
|
||||
public String StatusDesc { get; set; }
|
||||
@@ -57,9 +57,9 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
using (SaxSport sport = ReferenceMgr.GetSportById(organisation.SportIdPrimary))
|
||||
data.SportName = sport?.Name ?? "";
|
||||
// Region.
|
||||
data.RegionId = SysId.ToLong(organisation.RegionIdPrimary);
|
||||
data.RegionIdCountry = SysId.ToLong(organisation.RegionIdPrimary);
|
||||
using (SaxRegion region = ReferenceMgr.GetRegionById(organisation.RegionIdPrimary))
|
||||
data.RegionName = region?.Name ?? "";
|
||||
data.RegionNameCountry = region?.Name ?? "";
|
||||
// Common properties.
|
||||
data.StatusCode = organisation.StatusCode;
|
||||
data.StatusDesc = organisation.StatusDesc;
|
||||
@@ -154,8 +154,8 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
MemberCount = StringUtil.ToLong(values.GetString(colMemberCount.DataName)),
|
||||
SportId = values.GetLong(colSportId.DataName),
|
||||
SportName = values.GetString(colSportName.DataName),
|
||||
RegionId = values.GetLong(colRegionId.DataName),
|
||||
RegionName = values.GetString(colRegionName.DataName),
|
||||
RegionIdCountry = values.GetLong(colRegionId.DataName),
|
||||
RegionNameCountry = values.GetString(colRegionName.DataName),
|
||||
StatusCode = values.GetString(colStatus.DataName),
|
||||
StatusDesc = SacsSystem.GetStatusDescForCode(values.GetString(colStatus.DataName))
|
||||
};
|
||||
@@ -257,8 +257,8 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
organisation.OrganisationCategory = model.OrganisationCategory;
|
||||
if (model.OrganisationSportId != null)
|
||||
organisation.SportIdPrimary = model.OrganisationSportId.ToSysId();
|
||||
if (model.OrganisationRegionId != null)
|
||||
organisation.RegionIdPrimary = model.OrganisationRegionId.ToSysId();
|
||||
if (model.OrganisationRegionIdCountry != null)
|
||||
organisation.RegionIdPrimary = model.OrganisationRegionIdCountry.ToSysId();
|
||||
// Common properties.
|
||||
if (model.OrganisationStatusCode != null)
|
||||
organisation.Status = model.OrganisationStatus;
|
||||
|
||||
@@ -53,12 +53,20 @@ namespace Saxonite.Net.Core.Web.Admin.Models
|
||||
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; }
|
||||
public String OrganisationRegionIdCountry { get; set; }
|
||||
// Common properties.
|
||||
public String OrganisationNotes { get; set; }
|
||||
public String OrganisationStatusCode { get; set; }
|
||||
public SaStatus OrganisationStatus { get { return SacsSystem.GetStatusForCode(OrganisationStatusCode); } }
|
||||
|
||||
// Utilities.
|
||||
public bool IsSportMandatory()
|
||||
{
|
||||
if (OrganisationCategory == Sax.OrganisationCategory.Club) return true;
|
||||
if (OrganisationCategory == Sax.OrganisationCategory.Association) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validation.
|
||||
//-------------------------------------------------------------------
|
||||
@@ -89,6 +97,44 @@ namespace Saxonite.Net.Core.Web.Admin.Models
|
||||
responseData.SetControlError(nameof(OrganisationCategoryValue), Localiser["msg.validation.mandatory.value"]);
|
||||
}
|
||||
|
||||
// Organisation sport.
|
||||
if (OrganisationSportId != null)
|
||||
{
|
||||
if (SysId.IsValid(OrganisationSportId.ToSysId()) || IsSportMandatory())
|
||||
{
|
||||
using (SaxSport sport = ReferenceMgr.GetSportById(OrganisationSportId.ToSysId()))
|
||||
{
|
||||
if (sport == null)
|
||||
responseData.SetControlError(nameof(OrganisationSportId), Localiser["msg.validation.invalid.value"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Organisation country.
|
||||
if (OrganisationRegionIdCountry != null)
|
||||
{
|
||||
using (SaxRegion region = ReferenceMgr.GetRegionById(OrganisationRegionIdCountry.ToSysId()))
|
||||
{
|
||||
if (region == null)
|
||||
responseData.SetControlError(nameof(OrganisationRegionIdCountry), Localiser["msg.validation.invalid.value"]);
|
||||
else if (region.RegionType != Sax.RegionType.Country)
|
||||
responseData.SetControlError(nameof(OrganisationRegionIdCountry), "Organisation region must be a country");
|
||||
}
|
||||
|
||||
if (!StringUtil.IsEmpty(OrganisationName))
|
||||
{
|
||||
// Name must be unqiue within region.
|
||||
SaxOrganisation.Params prmOrganisation = new SaxOrganisation.Params();
|
||||
if (SysId.IsValid(OrganisationId.ToSysId()))
|
||||
prmOrganisation.IdsExcluded.Add(OrganisationId.ToSysId());
|
||||
prmOrganisation.NameFull = OrganisationName;
|
||||
prmOrganisation.RegionIdsIncluded.Add(OrganisationRegionIdCountry.ToSysId());
|
||||
prmOrganisation.StatusCat = SaxOrganisation.StatusCat.Any;
|
||||
if (AccountMgr.GetOrganisationCount(prmOrganisation) > 0)
|
||||
responseData.SetControlError(nameof(OrganisationName), Localiser["msg.validation.duplicate.value"]);
|
||||
}
|
||||
}
|
||||
|
||||
// Organisation status.
|
||||
if (OrganisationStatusCode != null)
|
||||
{
|
||||
|
||||
@@ -90,8 +90,6 @@ namespace Saxonite.Net.Core.Web.Admin.Models
|
||||
// User title.
|
||||
if (UserTitle != null)
|
||||
{
|
||||
if (StringUtil.IsEmpty(UserTitle))
|
||||
responseData.SetControlError(nameof(UserTitle), Localiser["msg.validation.mandatory.value"]);
|
||||
}
|
||||
|
||||
// User first name.
|
||||
|
||||
Reference in New Issue
Block a user