132 lines
5.4 KiB
C#
132 lines
5.4 KiB
C#
using Microsoft.AspNetCore.Http;
|
|
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.Online.Models
|
|
{
|
|
//=======================================================================
|
|
public class Model_Account : SaxModel_Online
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Construction.
|
|
public Model_Account(SaxLocaliser localiser) :
|
|
base(localiser)
|
|
{
|
|
AdditionalFiles_CSS.Add("css/sax-account.css");
|
|
AdditionalFiles_JS.Add("js/sax-account.js");
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Contact Properties.
|
|
public String AccountEmailAddress { get; set; }
|
|
public String AccountTitle { get; set; }
|
|
public String AccountFirstName { get; set; }
|
|
public String AccountLastName { get; set; }
|
|
// Regions.
|
|
public String AccountRegionIdCountry { get; set; }
|
|
public String AccountRegionCaptionCountry { get; }
|
|
public String AccountRegionIdProvince { get; set; }
|
|
public String AccountRegionCaptionProvince { get; }
|
|
// Image.
|
|
public List<IFormFile> AccountContactImage { get; set; }
|
|
|
|
//-------------------------------------------------------------------
|
|
// Sport properties.
|
|
public String UserSportId { get; set; }
|
|
public String ProfileSportId { get; set; }
|
|
public String ProfileSportExists { get; set; }
|
|
public String ProfileSportParticipationCode { get; set; }
|
|
public Sax.SportParticipation ProfileSportParticipation
|
|
{
|
|
get { return (Sax.SportParticipation)SportParticipationCodes.GetTypeForCode(ProfileSportParticipationCode); }
|
|
set { ProfileSportParticipationCode = SportParticipationCodes.GetCodeForType(value); }
|
|
}
|
|
public String ProfileSportOfficiatingCode { get; set; }
|
|
public Sax.SportOfficiating ProfileSportOfficiating
|
|
{
|
|
get { return (Sax.SportOfficiating)SportOfficiatingCodes.GetTypeForCode(ProfileSportOfficiatingCode); }
|
|
set { ProfileSportOfficiatingCode = SportOfficiatingCodes.GetCodeForType(value); }
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
public bool ValidateContactDetails(SaxController_Base.AjaxResponse_Data responseData)
|
|
{
|
|
// Title.
|
|
if (AccountTitle != null)
|
|
{
|
|
responseData.SetControlValue(nameof(AccountTitle), AccountTitle);
|
|
if (StringUtil.IsEmpty(AccountTitle))
|
|
responseData.SetControlError(nameof(AccountTitle), Localiser["msg.validation.mandatory.value"]);
|
|
else if (StringUtil.GetLength(AccountTitle) > GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.UserAccount_Title))
|
|
responseData.SetControlError(nameof(AccountTitle), Localiser["msg.validation.maximum.length", GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.UserAccount_Title)]);
|
|
}
|
|
|
|
// First Name.
|
|
if (AccountFirstName != null)
|
|
{
|
|
responseData.SetControlValue(nameof(AccountFirstName), AccountFirstName);
|
|
if (StringUtil.IsEmpty(AccountFirstName))
|
|
responseData.SetControlError(nameof(AccountFirstName), Localiser["msg.validation.mandatory.value"]);
|
|
else if (StringUtil.GetLength(AccountFirstName) > GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.UserAccount_FirstName))
|
|
responseData.SetControlError(nameof(AccountFirstName), Localiser["msg.validation.maximum.length", GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.UserAccount_FirstName)]);
|
|
}
|
|
|
|
// Last Name.
|
|
if (AccountLastName != null)
|
|
{
|
|
responseData.SetControlValue(nameof(AccountLastName), AccountLastName);
|
|
if (StringUtil.IsEmpty(AccountLastName))
|
|
responseData.SetControlError(nameof(AccountLastName), Localiser["msg.validation.mandatory.value"]);
|
|
else if (StringUtil.GetLength(AccountLastName) > GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.UserAccount_LastName))
|
|
responseData.SetControlError(nameof(AccountLastName), Localiser["msg.validation.maximum.length", GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.UserAccount_LastName)]);
|
|
}
|
|
|
|
// Country Region.
|
|
if (AccountRegionIdCountry != null && SysId.IsValid(AccountRegionIdCountry.ToSysId()))
|
|
{
|
|
SaxRegion regionCountry = Internals.GetRegion(AccountRegionIdCountry.ToSysId());
|
|
if (regionCountry == null)
|
|
responseData.SetControlError(nameof(AccountRegionIdCountry), Localiser["msg.validation.invalid.value"]);
|
|
}
|
|
|
|
// Province Region.
|
|
if (AccountRegionIdProvince != null)
|
|
{
|
|
SaxRegion regionProvince = Internals.GetRegion(AccountRegionIdProvince.ToSysId());
|
|
if (regionProvince == null)
|
|
responseData.SetControlError(nameof(AccountRegionIdProvince), Localiser["msg.validation.invalid.value"]);
|
|
}
|
|
|
|
return !responseData.HasControlErrors();
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
public bool ValidateProfileSportData(SaxController_Base.AjaxResponse_Data responseData)
|
|
{
|
|
// Sport.
|
|
if (ProfileSportId != null)
|
|
{
|
|
SysId profileSportId = ProfileSportId.ToSysId();
|
|
if (!SysId.IsValid(profileSportId))
|
|
responseData.SetControlError(nameof(ProfileSportId), Localiser["msg.validation.mandatory.value"]);
|
|
}
|
|
|
|
return !responseData.HasControlErrors();
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|