public async Task <IActionResult> DeleteAsync(DeleteViewModel viewModel) { if (!ModelState.IsValid) { ViewData["ErrorMessage"] = "Invalid form submission."; return(PartialView("_DeleteLocation", viewModel)); } BaseResponse _Response = new BaseResponse(); string _UserIDString = __UserManager.GetUserId(User); if (Guid.TryParse(_UserIDString, out Guid userUID)) { _Response = await __LocationManager.DeleteAsync(new UserUIDAndUIDRequest { UID = viewModel.Location.UID, UserUID = userUID }); } else { _Response.Success = false; _Response.ErrorMessage = $"You do not have permission to delete the {ENTITY_NAME}"; } if (!_Response.Success) { return(RedirectToAction("Index", "Stock", new { Area = "Stock", errorMessage = _Response.ErrorMessage })); } return(RedirectToAction("Index", "Stock", new { Area = "Stock", successMessage = $"{GlobalConstants.SUCCESS_ACTION_PREFIX} deleted {ENTITY_NAME}" })); }