public ActionResult DeleteDepartment(string id = null) { try { session.IsAuthenticated(); if (id != null) { if (departmentManager.DeleteDepartment(Convert.ToInt32(Security.Decrypt(id)))) { ViewBag.SaveMessage = "Delete successfully."; } else { ViewBag.ExErrorMessage = "Failed to Delete."; } } return(RedirectToAction("Get")); } catch (Exception ex) { ViewBag.ExErrorMessage = ex.Message; return(RedirectToAction("Get")); } }
public IHttpActionResult Delete([FromUri] int id) { bool succsess = departmentBll.DeleteDepartment(id); if (succsess) { return(Ok()); } return(BadRequest()); }
public bool DeleteDepartment(Int32 departmentId) { try { return(_departmentManager.DeleteDepartment(departmentId)); } catch (Exception ex) { ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message); return(false); } }
public ActionResult DeleteDepartmentFromList(int departmentId) { int rowsEffected = aDepartmentManager.DeleteDepartment(departmentId); if (rowsEffected > 0) { return(RedirectToAction("ViewAllDepartments")); } else { string msg = "Delete could not occur"; return(RedirectToAction("ViewAllDepartments", new { message = msg })); } }
public ActionResult Delete(int?id) { if (Session["UserRoleId"] == null) { return(RedirectToAction("Login", "Login")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var message = departmentManager.DeleteDepartment(id); return(RedirectToAction("Save")); }
public ActionResult Delete(string Ids)//,FormCollection formCollection) { string[] ids = Ids.Split(new char[] { ',' }); bool isSuccess = false; foreach (string ID in ids) { try { departmentManager.DeleteDepartment(int.Parse(ID)); isSuccess = true; } catch (Exception e) { try { if (ID == "") { TempData["Error"] = e.Message;// + "Select more than one row then click on 'DeleteAll' button to perform delete action."; break; } else if (e.Message != null) { String alertDelete = e.InnerException.InnerException.Message; TempData["Error"] = e.InnerException.InnerException.Message.Substring(0, alertDelete.IndexOf('.')); TempData["Error"] = alertDelete.Contains("The DELETE statement conflicted with the REFERENCE constraint ") ? "Department already in use can't be deleted" : "Error occured"; } else { TempData["Error"] = "Unknown"; } } catch (Exception ex) { if (ex.Message != null) { TempData["Error"] = e.Message + ex.Message; } break; } } } return(Json(new { success = isSuccess, error = @TempData["Error"] })); }
/// <summary> /// 删除 /// </summary> /// <param name="input"></param> public void DeletePost(EntityDto <long> input) { var type = _departmentManagerManager.GetDepartment(input.Id); if (type == null) { throw new UserFriendlyException("操作出错,该部门或已删除!"); } var depar = _departmentManagerManager.GetDepartmentCount(input.Id); if (depar > 0) { throw new UserFriendlyException("删除出错,该部门下有子部门,请先删除子部门在进行此删除操作!"); } else { _departmentManagerManager.DeleteDepartment(input.Id); } }
public async Task <ActionResult <Result> > DeleteDepartment(long id) { try { var Result = await _DepartmentManager.DeleteDepartment(id, GetUserName()); return(Result); } catch (Exception ex) { _exceptionManager.SaveLog(Request.Path, id, ex, GetUserName()); return(new Result() { IsSuccess = false, Errors = new List <string> { Resources.ExceptionMessage } }); } }