public async Task <IActionResult> Update(int id, Step step) { try { step.Id = id; return(this.Ok(await _repository.Update(step))); } catch (Exception e) { return(this.Ok(TranslateError.Convert(e))); } }
public async Task It_Should_Update_Step() { // Arrange batchRepository.DoesBatchExist(Arg.Any <string>()) .Returns(true); stepRepository.Update(Arg.Any <Step>()) .Returns(true); var request = UpdateSteps.Build; request.BatchId = TestBatchId; // Act var response = await Sut.Put(request); // Assert response.Should().NotBeNull(); await stepRepository.Received().Update(Arg.Is <Step>(a => a.BatchId == request.BatchId && a.Name == request.StepName && a.Description == request.Description)); }
public async Task <UpdateStepResponse> Put(UpdateStepRequest request) { if (!await batchRepository.DoesBatchExist(request.BatchId)) { throw Err.BatchNotFound(request.BatchId); } var step = request.ConvertTo <Step>(); var updated = await stepRepository.Update(step); if (!updated) { throw Err.StepNotFound(request.StepName); } return(new UpdateStepResponse()); }