public RemoveRoleCaseValidator(BugTrackerContext context , UseCaseExecutor useCaseExector , IGetOneRoleCaseQuery query) { _context = context; _useCaseExector = useCaseExector; _query = query; RuleFor(x => x.RoleId) .Must((dto, userId) => ApplicationUserCaseExists(dto)) .WithMessage("Entity with given ApplicationUserId and CaseId doesn't exist"); }
public IActionResult Delete([FromBody] RemoveRoleCaseDto dto , [FromServices] RemoveRoleCaseValidator validator , [FromServices] IGetOneRoleCaseQuery query , [FromServices] IRemoveRoleCaseCommand command) { var result = validator.Validate(dto); if (result.IsValid) { RoleUserCase roleCase = _useCaseExecutor.ExecuteQuery(query, dto); _useCaseExecutor.ExecuteCommand(command, roleCase); return(Ok()); } return(UnprocessableEntity(UnprocessableEntityResponse.Message(result.Errors))); }