private void SetAppropriateIndexError(ISuccessOrErrors status, string format, params string [] args) { if (_showMismatchedIndexsAsErrors) { status.AddSingleError(format, args); } else { status.AddWarning(format, args); } }
private ISuccessOrErrors <TDto> validateDtoState <TDto>(ISuccessOrErrors <TDto> status, TDto dto, ActionFlags flags) where TDto : DtoBase <TContext, TEntity, TDto>, new() { var currentItem = dto.FindItemTrackedForUpdate(dbContext); if (!new TDto().AllowedActions.HasFlag(ActionFlags.Update) && currentItem != null) { return(status.AddSingleError("Dto is not allowed for this kind of action")); } if (!new TDto().AllowedActions.HasFlag(ActionFlags.Create) && currentItem == null) { return(status.AddSingleError("Dto is not allowed for this kind of action")); } if (!flags.HasFlag(ActionFlags.Update) && currentItem != null) { return(status.AddSingleError("Object already exists")); } if (!flags.HasFlag(ActionFlags.Create) && currentItem == null) { return(status.AddSingleError("Object doesn't exist")); } return(status); }