public async Task <IActionResult> Edit(Guid id, ProfileVM 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.ToProfile(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 TestUpdateProfileAsync() { ApplicationSeeder.Seed(); var bo = new ProfileBO(); var resList = bo.ListAsync().Result; var item = resList.Result.FirstOrDefault(); item.Country = "Spain"; var resUpdate = bo.UpdateAsync(item).Result; var list = bo.ListUndeletedAsync().Result; Assert.IsTrue(resList.Success && resUpdate.Success && list.Result.First().Country == "Spain"); }