public async Task <IActionResult> Edit(Guid id, ServiceVM vm) { if (ModelState.IsValid) { var getOperation = await _bo.ReadAsync(id); if (!getOperation.Success) { return(OperationErrorBackToIndex(getOperation.Exception)); } if (getOperation.Result == null) { return(RecordNotFound()); } var result = getOperation.Result; if (!vm.CompareToModel(result)) { result = vm.ToService(result); var updateOperation = await _bo.UpdateAsync(result); if (!updateOperation.Success) { TempData["Alert"] = AlertFactory.GenerateAlert(NotificationType.Danger, updateOperation.Exception); return(View(vm)); } return(OperationSuccess("The record was successfully updated.")); } } return(RedirectToAction(nameof(Index))); }
public void TestUpdateServiceAsync() { ApplicationSeeder.Seed(); var bo = new ServiceBO(); var resList = bo.ListAsync().Result; var item = resList.Result.FirstOrDefault(); item.IsActive = false; var resUpdate = bo.UpdateAsync(item).Result; var list = bo.ListUndeletedAsync().Result; Assert.IsTrue(resList.Success && resUpdate.Success && list.Result.First().IsActive == false); }