/// <summary> /// Confirmation message /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult ConfirmDeleteRole(int id = 0) { IRoleDto role = null; try { role = _userManager.GetRole(UserId, id); if (role == null) { throw new Exception("Role not found"); } } catch (Exception exception) { TempData["MessageType"] = WebMessageType.Failure; TempData["Message"] = exception.Message; } ConfirmDeleteModel model = new ConfirmDeleteModel { DeleteAction = "DeleteRole", ReturnAction = "ShowRole", Name = role.Name, Id = role.Id }; return(View("ConfirmDelete", model)); }
/// <summary> /// First step of deleting a user input /// </summary> /// <param name="type"></param> /// <param name="id"></param> /// <returns></returns> public ActionResult ConfirmDeleteUserInput(UserInputType type, int id) { ConfirmDeleteModel model = new ConfirmDeleteModel { Type = type, Id = id }; model.DeleteAction = "DeleteUserInput"; model.ReturnAction = "ShowUserInput"; IUserInput input = null; try { switch (type) { case UserInputType.Text: input = _portfolioService.GetTextInput(UserId, id); break; case UserInputType.Selection: input = _portfolioService.GetSelectionInput(UserId, id); break; case UserInputType.ScriptedSelection: input = _portfolioService.GetScriptedSelectionInput(UserId, id); break; } } catch (Exception exception) { TempData["MessageType"] = WebMessageType.Failure; //return incomplete data with an error message TempData["Message"] = $"Failed to find user input, error: {exception.Message}"; return(View(model)); } if (input != null) { model.Name = input.DisplayName; } return(View(model)); }
/// <summary> /// confirm delete a package /// </summary> /// <param name="id">package id</param> /// <returns></returns> public ActionResult ConfirmDeletePackage(int id) { ConfirmDeleteModel model = new ConfirmDeleteModel { Id = id, DeleteAction = "DeletePackage", ReturnAction = "ShowPackage" }; try { model.Name = _portfolioService.GetServiceRequestPackage(UserId, id).Name; //complete model details } catch (Exception exception) { TempData["MessageType"] = WebMessageType.Failure; TempData["Message"] = $"Failed to retrieve service request package, error: {exception.Message}"; } return(View("ConfirmDeletePackage", model)); }
public ActionResult DeleteUserInput(ConfirmDeleteModel deleteModel) { try { switch (deleteModel.Type) { case UserInputType.Text: _portfolioService.ModifyTextInput(UserId, new TextInputDto { Id = deleteModel.Id }, EntityModification.Delete); break; case UserInputType.ScriptedSelection: _portfolioService.ModifyScriptedSelectionInput(UserId, new ScriptedSelectionInputDto { Id = deleteModel.Id }, EntityModification.Delete); break; case UserInputType.Selection: _portfolioService.ModifySelectionInput(UserId, new SelectionInputDto { Id = deleteModel.Id }, EntityModification.Delete); break; } } catch (Exception exception) { TempData["MessageType"] = WebMessageType.Failure; TempData["Message"] = $"Failed to delete {deleteModel.Name}, error: {exception.Message}"; } TempData["MessageType"] = WebMessageType.Success; TempData["Message"] = "Successfully deleted user input"; return(RedirectToAction("ShowUserInput", new { id = 0 })); }