public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                var roll = new Role() { };
                
                roll.RoleName = collection["RoleName"];
                foreach (string key in collection.AllKeys)
                {
                    if (key.StartsWith("category_") && collection[key] == "on")
                    {
                        string id = key.Split('_')[1];
                        roll.ContentPermission += (id + ",");//(string.IsNullOrEmpty(roll.ContentPermission) ? string.Empty : "," + key.Split('_')[1]);
                        //roll.ContentPermission +=  key.Split('_')[1];
                    }
                }
                
                if (string.IsNullOrEmpty(roll.RoleName)) {
                    throw new Exception(""); }

                roll.IsFullPermission           = !string.IsNullOrEmpty(collection["FullControl"]) && collection["FullControl"] == "on";
                roll.AllowManageRole            = !string.IsNullOrEmpty(collection["Role"]) && collection["Role"] == "on";
                roll.AllowManageUser            = !string.IsNullOrEmpty(collection["User"]) && collection["User"] == "on";
                roll.AllowManageMenu            = !string.IsNullOrEmpty(collection["Menu"]) && collection["Menu"] == "on";
                roll.AllowManageAllContent      = !string.IsNullOrEmpty(collection["AllContent"]) && collection["AllContent"] == "on";
                roll.AllowManageLink            = !string.IsNullOrEmpty(collection["Link"]) && collection["Link"] == "on";
                roll.AllowManageOnlineSupporter = !string.IsNullOrEmpty(collection["OnlineSupport"]) && collection["OnlineSupport"] == "on";
                roll.AllowManageContact         = !string.IsNullOrEmpty(collection["Contact"]) && collection["Contact"] == "on";
                roll.AllowManagePoll            = !string.IsNullOrEmpty(collection["Poll"]) && collection["Poll"] == "on";
                roll.AllowManageBanner          = !string.IsNullOrEmpty(collection["Banner"]) && collection["Banner"] == "on";

                RoleService.AddRole(roll);
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
 public ActionResult EditRow(int id, Role role)
 {
     try
     {
         return Content("");
     }
     catch
     {
         
     }
     return Content("");
 }
 public ActionResult EditRole(int id, Role role)
 {
     DBNLDataContext db = new DBNLDataContext();
     Role updRole = db.Roles.Where(p => p.Id == id).SingleOrDefault();
     updRole.ComponentPermission = role.ComponentPermission;
     updRole.ContentPermission = role.ContentPermission;
     updRole.RoleName = role.RoleName;
     db.SubmitChanges();
     return RedirectToAction("ListRoles");
 }
 public ActionResult DeleteRole(Role role)
 {
     DBNLDataContext db = new DBNLDataContext();
     db.Roles.DeleteOnSubmit(role);
     db.SubmitChanges();
     return RedirectToAction("ListRoles");
 }
 partial void DeleteRole(Role instance);
 partial void UpdateRole(Role instance);
 partial void InsertRole(Role instance);