Files
Saxonite/SaxoniteCoreWebOnline/Online/Models/Model_Account.cs
T
2021-05-20 19:22:52 +01:00

93 lines
3.7 KiB
C#

using Sarand.Net.Standard.Base.Bus;
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 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; }
//-------------------------------------------------------------------
// Sport properties.
public String UserSportId { get; set; }
public String ProfileSportId { get; set; }
public String ProfileSportExists { get; set; }
//-------------------------------------------------------------------
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.ColumnIdx.UserAccount_Title))
responseData.SetControlError(nameof(AccountTitle), Localiser["msg.validation.maximum.length", GetControlMaxLength(SaxDbDfn.ColumnIdx.JournalistArticle_Headline)]);
}
// 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.ColumnIdx.UserAccount_FirstName))
responseData.SetControlError(nameof(AccountFirstName), Localiser["msg.validation.maximum.length", GetControlMaxLength(SaxDbDfn.ColumnIdx.JournalistArticle_Headline)]);
}
// 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.ColumnIdx.UserAccount_LastName))
responseData.SetControlError(nameof(AccountLastName), Localiser["msg.validation.maximum.length", GetControlMaxLength(SaxDbDfn.ColumnIdx.JournalistArticle_Headline)]);
}
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();
}
//-------------------------------------------------------------------
}
//=======================================================================
}