public async Task UpdateSystemItemSetUp() { //Arrange var itemkey = Guid.NewGuid(); var item = GetMockItem(itemkey); _mockItemRepository.Reset(); _mockItemRepository.Setup(b => b.GetItemById(itemkey)) .ReturnsAsync(item); _mockItemRepository.Setup(b => b.UpdateSystemItemSetUp(item)) .ReturnsAsync(true); //Act var result = await _subject.UpdateSystemItemSetUp(itemkey, new SystemItemSetupRequest() { Description = "test Description" }); //Assert _mockItemRepository.VerifyAll(); Assert.NotNull(result); Assert.Equal(CreateUpdateResultEnum.Success, result.OperationResult); }
public async Task <IActionResult> UpdateItemSetUpById(Guid itemkey, [FromBody] SystemItemSetupRequest medicationItem) { if (ModelState.IsValid) { _logger.LogDebug("Update Item SetUp called with {@EditSyatemItemSetUp}", medicationItem); var systemItemUpdate = await _systemItemSetUpManager.UpdateSystemItemSetUp(itemkey, medicationItem); if (systemItemUpdate.OperationResult == CreateUpdateResultEnum.NotFound) { _logger.LogError("No Result Found for item {itemkey}.", itemkey); return(NotFound($"Item with itemkey key {itemkey} not found.")); } if (systemItemUpdate.OperationResult != CreateUpdateResultEnum.Success) { _logger.LogError("There was an error updating System item setup."); return(BadRequest("There was an error updating System item setup.")); } _logger.LogInformation("Update Item SetUp successfully done with result : {EditSyatemItemSetUp}", systemItemUpdate); return(Ok(systemItemUpdate.Object)); } return(BadRequest(new ModelStateRequestValidationAdaptor(ModelState))); }