public async Task <IActionResult> Details(BeneficiaryDetailViewModel formData) { try { if (ModelState.IsValid) { await _beneficiaryServices.UpdateBeneficiaryDetailAsync(new BeneficiaryDetails { DateTimeModified = DateTimeOffset.Now, EmployeeID = formData.EmployeeID, BeneficiaryName = formData.BeneficiaryName, BeneficiaryContact = formData.BeneficiaryContact, RelationshipId = formData.RelationshipId, UserAccount = User.Identity.Name, Id = formData.Id }); TempData["Message"] = "Changes saved successfully"; _logger.LogInformation($"Success: successfully updated employee beneficiary record by user={@User.Identity.Name.Substring(4)}"); return(RedirectToAction("details", new { id = formData.Id })); } } catch (ApplicationException error) { _logger.LogError( error, $"FAIL: failed to update employee beneficiary details {formData.BeneficiaryName}. Internal Application Error.; user={@User.Identity.Name.Substring(4)}"); ModelState.AddModelError("Beneficiary", $"Failed to update employee beneficiary record. {formData.BeneficiaryName} Contact IT ServiceDesk for support thank you."); } await LoadSelectListsAsync(); return(View(formData)); }
public async Task <IActionResult> Details(Guid id) { var beneficiaryQuery = await _beneficiaryServices.GetBeneficiaryDetailById(id); if (beneficiaryQuery == null) { return(NotFound()); } var model = new BeneficiaryDetailViewModel { Id = beneficiaryQuery.Id, EmployeeID = beneficiaryQuery.EmployeeID ?? Guid.Empty, BeneficiaryName = beneficiaryQuery.BeneficiaryName, BeneficiaryContact = beneficiaryQuery.BeneficiaryContact, RelationshipId = beneficiaryQuery.RelationshipId ?? Guid.Empty }; await LoadSelectListsAsync(); return(View(model)); }