public async Task <IActionResult> Edit(Guid id, [Bind("Id, Name")] CategoryInterestPointViewModel vm) { if (ModelState.IsValid) { var getOperation = await _bo.ReadAsync((Guid)id); if (!getOperation.Success) { return(OperationErrorBackToIndex(getOperation.Exception)); } if (getOperation.Result == null) { return(NotFound()); } var result = getOperation.Result; if (!vm.CompareToModel(result)) { result.Name = vm.Name; var updateOperation = await _bo.UpdateAsync(result); if (!updateOperation.Success) { TempData["Alert"] = AlertFactory.GenerateAlert(NotificationType.Danger, updateOperation.Exception); return(View(vm)); } else { return(OperationSuccess("The record was successfuly updated")); } } } return(RedirectToAction(nameof(Index))); }
public void TestUpdateInterestpointCategoryAsync() { BoraNowSeeder.Seed(); var cipbo = new CategoryInterestPointBusinessObject(); var resList = cipbo.List(); var item = resList.Result.FirstOrDefault(); var categoryInterestPoint = new CategoryInterestPoint("C"); item.Name = categoryInterestPoint.Name; var resUpdate = cipbo.UpdateAsync(item).Result; resList = cipbo.ListAsync().Result; Assert.IsTrue(resUpdate.Success && resList.Success && resList.Result.First().Name == categoryInterestPoint.Name); }