public ActionResult AddMask() { AddRoleDataContext context = new AddRoleDataContext(); List <string> roleList = new List <string>(); foreach (string role in Roles.GetAllRoles()) { string roleDescription = context.aspnet_Roles.Single(p => p.RoleName == role.ToString()).Description; if (roleDescription != null) { roleDescription = role; } roleList.Add(roleDescription); } ViewBag.roles = roleList; db db = new db(); List <string> stringList = new List <string>(); List <object> objectList = db.multipleItemSelect("maskFile", maskTable, "bakeryId='" + Session["id"] + "'"); foreach (object o in objectList) { stringList.Add(o.ToString()); } ViewBag.masks = stringList; if (Session["tempforview"] != null) { ViewBag.message = Session["tempforview"]; Session["tempforview"] = null; } return(View()); }
public ActionResult AddRoleForm(AdminAddRoleModel model) { try { int id; if (Roles.RoleExists(model.Role)) { Session["tempforview"] = "Role: " + model.Role + " already exist look up!"; } else { Roles.CreateRole(model.Role); AddRoleDataContext db = new AddRoleDataContext(); aspnet_Role role = db.aspnet_Roles.Single(p => p.RoleName == model.Role); role.Description = model.RoleDescription; db.SubmitChanges(); if (Int32.TryParse(model.Role, out id) == true) { string[] users = Roles.GetUsersInRole("AllDest"); Roles.AddUsersToRole(users, model.Role); } Session["success"] = "Role: " + model.Role + " has been successfully added."; } return(RedirectToAction("AddRole", "Admin")); } catch (Exception msg) { // something went wrong, and you wanna know why throw msg; } }