using Microsoft.AspNetCore.Mvc.Rendering; using Sarand.BusinessMgr.Net.Core.Web.App; using Sarand.BusinessMgr.Net.Core.Web.Components; using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; using Sarand.BusinessMgr.Net.Standard.Base.Core; using Sarand.BusinessMgr.Web.Control.App; using Sarand.Net.Standard.Base.Core; using System; using System.Collections.Generic; namespace Sarand.BusinessMgr.Web.Control.Models { //======================================================================= public class SbmModel_Control : SbmModel_Base { //------------------------------------------------------------------- // Protected construction. protected SbmModel_Control(SbmLocaliser localiser) : base(localiser) { } //------------------------------------------------------------------- // Properties. protected SbmApplication_Control App_Control { get { return SbmApplication_Control.Instance; } } protected SbmSessionData_Control SessionData_Control { get { return SessionData_Web as SbmSessionData_Control; } } //------------------------------------------------------------------- public IEnumerable GetInstanceContextsForSelect() { List items = new List(); SbmcRepository.Params prmRepository = new SbmcRepository.Params(); prmRepository.StatusCat = SbmcRepository.StatusCat.NotDeleted; foreach (SbmcRepository repository in ControlInstanceMgr.GetRepositoryList(prmRepository)) items.Add(new SelectListItem(repository.Context, repository.Context)); return items; } //------------------------------------------------------------------- /// /// Form control value max length - BusinessMgr tables. /// In many cases the database columns allow plenty of extra space for the value, in case they need to be encrypted. /// Hence, several cases where the value entered in the control isn't allowed the full database length. /// public int GetControlMaxLength(SbmDbDfn_Control.ColumnIdx column) { int maxLength = (int)SbmDbDfn_Control.GetColTextLen(column); switch (column) { case SbmDbDfn_Control.ColumnIdx.UserAccount_EmailAddress: return Math.Min(maxLength, 100); case SbmDbDfn_Control.ColumnIdx.UserAccount_FirstName: case SbmDbDfn_Control.ColumnIdx.UserAccount_LastName: return Math.Min(maxLength, 40); case SbmDbDfn_Control.ColumnIdx.UserAccount_PhoneMain: case SbmDbDfn_Control.ColumnIdx.UserAccount_PhoneMobile: case SbmDbDfn_Control.ColumnIdx.UserAccount_PhoneAlt: return Math.Min(maxLength, 20); case SbmDbDfn_Control.ColumnIdx.ItemParam_Value: if (maxLength == 0 || maxLength > 2048) return 2048; break; } return maxLength; } //------------------------------------------------------------------- } //======================================================================= }