using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.BusinessMgr.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.App; using Sarand.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Dbas; using System; using System.Collections.Generic; namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr { //======================================================================= partial class SbmAccountMgr { //******************************************************************* // S y s t e m A c c o u n t //******************************************************************* //------------------------------------------------------------------- // Data Member & Utilities. //------------------------------------------------------------------- // Utilities. //------------------------------------------------------------------- // Retrieve individual systemAccounts. //------------------------------------------------------------------- // SystemAccountUser exists. public bool SystemAccountUserExistsById(SysId AccountId, SysId UserId) { ClearErrorState(); if (!SysId.IsValid(AccountId) && !SysId.IsValid(UserId)) return false; SbmSystemAccountUser.Params prmSystemAccountUser = new SbmSystemAccountUser.Params(); prmSystemAccountUser.AccountId = AccountId; prmSystemAccountUser.UserId = UserId; prmSystemAccountUser.StatusCat = SbmSystemAccountUser.StatusCat.Any; return GetSystemAccountUserCount(prmSystemAccountUser) == 1; } //------------------------------------------------------------------- // Get systemAccountUser. public abstract SbmSystemAccountUser GetSystemAccountUser(SbmSystemAccountUser.Params prm); public SbmSystemAccountUser GetSystemAccountUserById(SysId AccountId, SysId UserId) { ClearErrorState(); if (!SysId.IsValid(AccountId) && !SysId.IsValid(UserId)) return null; SbmSystemAccountUser.Params prmSystemAccountUser = new SbmSystemAccountUser.Params(); prmSystemAccountUser.AccountId = AccountId; prmSystemAccountUser.UserId = UserId; prmSystemAccountUser.StatusCat = SbmSystemAccountUser.StatusCat.Any; return GetSystemAccountUser(prmSystemAccountUser); } //------------------------------------------------------------------- // Create systemAccountUser. public abstract SbmSystemAccountUser CreateSystemAccountUser(SysId accountId, SysId userId); //------------------------------------------------------------------- // Validate systemAccountUser data. public bool IsValidSystemAccountUser(SbmSystemAccountUser systemAccountUser) { ClearErrorState(); if (systemAccountUser == null) return SetErrorState(ErrorMessage.ItemNotSpecified); return IsValidSystemAccountUserData(systemAccountUser.GetData(), new SbmSystemAccountUser.ErrField()); } public virtual bool IsValidSystemAccountUserData(SbmSystemAccountUser.Data data, SbmSystemAccountUser.ErrField errField) { // SystemAccountUser properties. ClearErrorState(); //Validate the identity. if (!SysId.IsValid(data.AccountId)) return SetErrorState("invalid account"); if (!SysId.IsValid(data.UserId)) return SetErrorState("invalid user"); // Validate the text attributes. // Common properties. if (!IsValidValue(data.Notes, "notes", (long)SbmDbDfn.GetColTextLen(SbmDbDfn.ColumnIdx.SystemAccountUser_Notes))) { errField.Notes = SacsHierarchyItem.ValidValue.Invalid; return false; } if (errField.Status != SacsHierarchyItem.ValidValue.Ignore) { if (!IsValidValue(data.StatusCode, "status", (long)SbmDbDfn.GetColTextLen(SbmDbDfn.ColumnIdx.SystemAccountUser_Status), true, true)) { errField.Status = SacsHierarchyItem.ValidValue.Invalid; return false; } if (!SbmSystemAccountUser.SystemAccountUserStatuses.Contains(data.Status)) { errField.Status = SacsHierarchyItem.ValidValue.Invalid; return SetErrorState(ErrorMessage.InvalidStatus); } } return true; } //------------------------------------------------------------------- // SystemAccountUser database interface. public abstract bool InsertSystemAccountUser(SbmSystemAccountUser systemAccountUser, DbUpdateInfo dbUpdateInfo); public abstract bool UpdateSystemAccountUser(SbmSystemAccountUser systemAccountUser, DbUpdateInfo dbUpdateInfo); public virtual bool SystemAccountUserCanBeDeleted(SbmSystemAccountUser systemAccountUser) { ClearErrorState(); return true; } public abstract bool DeleteSystemAccountUser(SbmSystemAccountUser systemAccountUser, DbUpdateInfo dbUpdateInfo); //------------------------------------------------------------------- // SystemAccountUser list. public abstract ColumnDfn GetSystemAccountUserColumnDfn(SbmSystemAccountUser.Column columnId, String caption = "", int width = 0); public abstract List GetSystemAccountUserQueryFilter(SbmSystemAccountUser.Params prm); public abstract long GetSystemAccountUserCount(SbmSystemAccountUser.Params prm); public abstract List GetSystemAccountUserList(SbmSystemAccountUser.Params prm); public abstract DbResultSet SystemAccountUserExecuteQuery(List columns, SbmSystemAccountUser.Params prm); //------------------------------------------------------------------- // D a t a V a l u e s //------------------------------------------------------------------- /// /// Extract and format result set data value where specific handling is required. /// Where response is an invalid data value, format value using column.FormatValue(values). /// public DataValue GetSystemAccountUserDataValue(ColumnDfn column, NamedValue.Map values) { DataValue value = new DataValue(); switch ((SbmSystemAccountUser.Column)column.Id) { //----------------------------------------------------------- // Notes. case SbmSystemAccountUser.Column.Notes: value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200)); break; // Status. case SbmSystemAccountUser.Column.Status_Desc: case SbmSystemAccountUser.Column.Status_Ind: { String statusCode = values.GetValue(column.DataName).ToString(); SaStatus status = SacsSystem.GetStatusForCode(statusCode); if (column.Id == (int)SbmSystemAccountUser.Column.Status_Desc) value = new DataValue(SacsSystem.GetStatusDescForCode(statusCode)); else if (column.Id == (int)SbmSystemAccountUser.Column.Status_Ind) value = new DataValue(SbmSystemAccountUser.GetStatusTriState(status)); } break; //----------------------------------------------------------- default: value = values.GetValue(column.DataName); break; } return value; } //------------------------------------------------------------------- } //======================================================================= }