public async Task <IActionResult> UpdateProject(Guid id, [FromBody] ChangeProjectDto updatedProject) { var commandResult = await _projectManagerService.Handle( new UpdateProjectCommand( id, updatedProject.Description, updatedProject.ProjectType.ToProjectTypeEnum())); if (commandResult.IsSuccessful) { return(NoContent()); } _logger.LogError(commandResult.FailReasons[0]); return(BadRequest(commandResult.FailReasons)); }
public IActionResult Put(int id, [FromBody] ChangeProjectDto dto , [FromServices] IChangeProjectCommand command , [FromServices] ChangeProjectValidator validator) { dto.Id = id; var result = validator.Validate(dto); if (result.IsValid) { Project project = _mapper.Map <Project>(dto); _useCaseExecutor.ExecuteCommand(command, project); return(Ok("Project updated successfully")); } return(UnprocessableEntity(UnprocessableEntityResponse.Message(result.Errors))); }