Example #1
0
        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");
        }
Example #2
0
        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)));
        }