public ActionResult CreateNewGroup(GroupModel model) { try { if (!ModelState.IsValid) { return RedirectToAction("Error", "Base", new { eID = 0 }); } var group = _repository.FindGroupByName(model.GroupName); if (group != null) { return RedirectToAction("Error", "Base", new { eID = 1 }); } var newGroup = new UserGroup { GroupName = model.GroupName, DisplayName = model.DisplayName, Level = model.Level, CreatedByUserID = int.Parse(User.Identity.Name), CreatedOnDate = DateTime.Now }; _repository.AddNewGroup(newGroup); _repository.CommitChanges(); return RedirectToAction("Index"); } catch (Exception) { return RedirectToAction("Error", new {eID = 0}); } }
public ActionResult DeleteGroup(GroupModel model) { try { int groupID = model.GroupID; _repository.DeleteGroup(groupID); _repository.CommitChanges(); return RedirectToAction("Index"); } catch (Exception) { return RedirectToAction("Error", new {eID = 0}); } }
public PartialViewResult DeleteGroup(int groupID) { var usergroup = _repository.FindGroupByID(groupID); var model = new GroupModel { GroupID = usergroup.ID, GroupName = usergroup.GroupName, DisplayName = usergroup.DisplayName, Level = usergroup.Level.Value }; return PartialView(model); }
public ActionResult EditGroup(GroupModel model) { try { if (!ModelState.IsValid) { return RedirectToAction("Error", new { eID = 0 }); } var group = _repository.FindGroupByID(model.GroupID); group.GroupName = model.GroupName; group.DisplayName = model.DisplayName; group.Level = model.Level; group.LastModifiedOnDate = DateTime.Now; group.LastModifiedByUserID = int.Parse(User.Identity.Name); _repository.UpdateGroup(group); _repository.CommitChanges(); return RedirectToAction("Index"); } catch (Exception) { return RedirectToAction("Error", new {eID = 0}); } }