public bool Delete(int id) { if (id <= 0) { return(false); } Menu menu = _repository.Find(id); if (menu == null) { return(false); } if (menu.PId == 0) { List <Menu> tempMenuList = _repository.Select(c => c.PId == menu.Id); foreach (var tempMenu in tempMenuList) { _repository.Delete(tempMenu); _unitOfWork.Commit(); } } List <RoleMenu> roleMenus = _roleMenuService.GetAll(c => c.MenuId == id); foreach (var roleMenu in roleMenus) { _roleMenuService.Delete(roleMenu.Id); } _repository.Delete(menu); return(_unitOfWork.Commit() > 0); }
public bool Delete(int id) { if (id <= 0) { return(false); } if (_repository.Find(id) == null) { return(false); } List <RoleMenu> roleMenus = _roleMenuService.GetAll(c => c.RoleId == id); foreach (var roleMenu in roleMenus) { _roleMenuService.Delete(roleMenu); } List <Users> userList = _usersService.GetUsers(c => c.RoleId == id); foreach (var users in userList) { _usersService.Delete(users); } _repository.Delete(id); return(_unitOfWork.Commit() > 0); }
//[ValidateAntiForgeryToken] public ActionResult DeleteConfirmed(int id) { RoleMenu roleMenu = _roleMenuService.Find(id); _roleMenuService.Delete(roleMenu); _unitOfWork.SaveChanges(); if (Request.IsAjaxRequest()) { return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); } DisplaySuccessMessage("Has delete a RoleMenu record"); return(RedirectToAction("Index")); }
public Task <IResultModel> Delete([BindRequired] string id) { return(_service.Delete(id)); }