public UpdateTestCommand(UpdateTestDto dto) { Dto = dto; var validator = new Validator(); var result = validator.Validate(this); if (!result.IsValid) { throw new ValidationException(result.Errors); } }
public async Task <ActionResult <UpdatedTestDto> > Put([FromBody] UpdateTestDto updateTestDto) { UpdatedTestDto updatedTestDto = await testService.UpdateTest(updateTestDto); if (updatedTestDto == null) { return(NotFound()); } return(Ok(updatedTestDto)); }
public async Task <UpdatedTestDto> UpdateTest(UpdateTestDto updateTestDto) { Test test = await testRepository.GetByIdAsync(updateTestDto.Id); if (test == null) { return(null); } test = mapper.Map <Test>(updateTestDto); test.LastModifiedDate = DateTime.Now; testRepository.Update(test); await unitOfWork.SaveAsync(); return(mapper.Map <UpdatedTestDto>(test)); }
public async Task <GetTestDto> UpdateTest(UpdateTestDto dto) { return(await new UpdateTestCommand(dto).UpdateTest(UserInfo)); }