Exemple #1
0
        public static bool CreateUser(string UserName, string Password, string Email, List <string> Roles, string DefaultRole)
        {
            Membership.CreateUser(UserName, Password, Email);
            SURoleProvider rp = new SURoleProvider();

            rp.AddUsersToRoles(new string[] { UserName }, Roles.ToArray(), DefaultRole);
            return(true);
        }
 public ActionResult _AjaxDelete(Role item, [DataSourceRequest] DataSourceRequest request)
 {
     if (ModelState.IsValid)
     {
         SURoleProvider rp = new SURoleProvider();
         if (!rp.DeleteRole(item.Title, true))
         {
             ModelState.AddModelError("", "Not deleted");
         }
     }
     return(Json(new[] { item }.ToDataSourceResult(request, ModelState)));
 }
        public ActionResult Create(Role item)
        {
            if (ModelState.IsValid)
            {
                SURoleProvider rp = new SURoleProvider();
                rp.CreateRole(item.Title);

                try
                {
                    System.IO.Directory.CreateDirectory(Server.MapPath(string.Format("~/Content/UserFiles/{0}", item.Title)));
                    System.IO.Directory.CreateDirectory(Server.MapPath(string.Format("~/Content/UserFiles/{0}/Upload", item.Title)));
                    System.IO.Directory.CreateDirectory(Server.MapPath(string.Format("~/Content/UserFiles/{0}/Gallery", item.Title)));
                }
                catch
                {
                    TempData["MessageYellow"] = "Done but some group folders not created.";
                    return(RedirectToAction("Index"));
                }

                TempData["MessageGreen"] = "Done.";
                return(RedirectToAction("Index"));
            }
            return(View(item));
        }