public void CreateNewRole(Role model)
 {
     ApplicationRoleManager rm = new ApplicationRoleManager(new ApplicationRoleStore(new ApplicationDbContext()));
     rm.Create(new ApplicationRole(model.Name)
     {
         Id = Guid.NewGuid().ToString()
     });
 }
Beispiel #2
0
        public ActionResult AddRole(Role model)
        {
            try
            {
                db.CreateNewRole(model);
                return RedirectToAction("Roles", "People");
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.ToString());
            }

            return View(model);
        }
Beispiel #3
0
        public ActionResult EditRole(Role model)
        {
            //az anonymous "role" nem szerkeszthető, törölhető
            if (model.Name == "anonymous")
                return RedirectToAction("Roles", "People");

            try
            {
                db.EditRole(model);
                return RedirectToAction("Roles", "People");
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.ToString());
            }

            return View(model);
        }
 public void EditRole(Role model)
 {
     Role role = GetRoleById(model.Id);
     role.Name = model.Name;
     Save();
 }