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); }