static Errors() { AccountErrors = new AccountErrors(); MaintenanceErrors = new MaintenanceErrors(); DatabaseErrors = new DatabaseErrors(); UserCreatorErrors = new UserCreatorErrors(); AuthErrors = new AuthErrors(); EmailErrors = new EmailErrors(); LogErrors = new LogErrors(); }
/// <summary> /// Проверить количество вложенных моделей /// </summary> public IResultError ValidateQuantity(IEnumerable <TDomain> domains) => domains.ToResultCollectionWhere( idsValidate => idsValidate.Any(), _ => DatabaseErrors.CollectionEmpty(typeof(TDomain).Name, _dataTable.TableName));
/// <summary> /// Сохранить изменения в базе асинхронно /// </summary> public async Task <IResultError> SaveChangesAsync() => await ResultErrorTryAsync(() => base.SaveChangesAsync(), DatabaseErrors.DatabaseSaveError());
/// <summary> /// Проверить наличие сущностей /// </summary> private async Task <IResultError> ValidateFindsCollection(IReadOnlyCollection <TId> ids) => await _dataTable.FindsExpressionValueAsync(ValidateIdsQuery(ids)). ResultCollectionBindWhereTaskAsync(idsFind => ids.All(idsFind.Contains), okFunc: idsFind => new ResultCollection <TId>(idsFind), badFunc: idsFind => new ResultCollection <TId>(DatabaseErrors.ValuesNotFoundError(ids.Except(idsFind), _dataTable.TableName)));
/// <summary> /// Получить ошибки двойной записи /// </summary> private static IResultCollection <TId> GetDuplicateErrorsResult(IEnumerable <TId> ids, string tableName) => new ResultCollection <TId>(DatabaseErrors.DuplicateErrors(ids, tableName));
/// <summary> /// Получить ошибку двойной записи /// </summary> private static IResultValue <TId> GetDuplicateErrorResult(TId id, string tableName) => new ResultValue <TId>(DatabaseErrors.DuplicateError(id, tableName));
/// <summary> /// Ошибка дублирующего элемента /// </summary> public static IErrorResult GetDuplicateError <TId>(IEnumerable <TId> ids) where TId : notnull => DatabaseErrors.DuplicateErrors(ids, String.Empty);
/// <summary> /// Ошибка дублирующего элемента /// </summary> public static IErrorResult GetDuplicateError <TId>(TId id) where TId : notnull => DatabaseErrors.DuplicateError(id, String.Empty);