public ActionResult DeleteConfirmed(int id) { if (AclHelper.hasAccess(User, currentAction, currentController)) { try { rs_user_group rs_user_group = db.rs_user_group.Single(s => s.GroupId == id); Logger.Log("Delete", "Delete Group [ID:" + rs_user_group.GroupId + "]"); TempData["Notification"] = NotificationHelper.Inform("Delete Group [ID:" + rs_user_group.GroupId + "]"); db.rs_user_group.Remove(rs_user_group); db.SaveChanges(); } catch (Exception ex) { TempData["Notification"] = NotificationHelper.Error(ex.Message); } return(RedirectToAction("Index")); } else { return(RedirectToAction("NotAuthenticated", "Home")); } }
// // GET: /UserGroup/Delete/5 public ActionResult Delete(int id) { if (AclHelper.hasAccess(User, currentAction, currentController)) { rs_user_group rs_user_group = db.rs_user_group.Single(s => s.GroupId == id); return(View(rs_user_group)); } else { return(RedirectToAction("NotAuthenticated", "Home")); } }
public ActionResult Edit(rs_user_group rs_user_group) { if (AclHelper.hasAccess(User, currentAction, currentController)) { if (ModelState.IsValid) { rs_user_group current = db.rs_user_group.SingleOrDefault(s => s.Name == rs_user_group.Name && s.GroupId != rs_user_group.GroupId); if (current != null) { TempData["Notification"] = NotificationHelper.Error("User group already exist."); } else { try { rs_user_group.UserUpdate = User.Identity.Name; rs_user_group.DateUpdate = DateTime.Now; db.Entry(rs_user_group).State = EntityState.Modified; db.SaveChanges(); //db.rs_user_group.Attach(rs_user_group); //db.ObjectStateManager.ChangeObjectState(rs_user_group, EntityState.Modified); //db.SaveChanges(); Logger.Log("Edit", "Edit Group [ID:" + rs_user_group.GroupId + "]"); TempData["Notification"] = NotificationHelper.Inform("Edit Group [ID:" + rs_user_group.GroupId + "]"); return(RedirectToAction("Index")); } catch (Exception ex) { TempData["Notification"] = NotificationHelper.Error(ex.Message); } } } return(View(rs_user_group)); } else { return(RedirectToAction("NotAuthenticated", "Home")); } }
public ActionResult Create(rs_user_group rs_user_group) { if (AclHelper.hasAccess(User, currentAction, currentController)) { if (ModelState.IsValid) { rs_user_group current = db.rs_user_group.Where(s => s.Name == rs_user_group.Name).SingleOrDefault(); if (current != null) { TempData["Notification"] = NotificationHelper.Error("User group already exist."); } else { try { rs_user_group.DateEntry = DateTime.Now; rs_user_group.UserEntry = User.Identity.Name; db.rs_user_group.Add(rs_user_group); db.SaveChanges(); Logger.Log("Add", "New Group [Name: " + rs_user_group.Name + "]"); TempData["Notification"] = NotificationHelper.Inform("New Group [Name: " + rs_user_group.Name + "]"); return(RedirectToAction("Index")); } catch (Exception ex) { TempData["Notification"] = NotificationHelper.Error(ex.Message); } } } return(View(rs_user_group)); } else { return(RedirectToAction("NotAuthenticated", "Home")); } }