Exemple #1
0
        public ActionResult Create([Bind(Include =
                                             "RoleName,Description")] RoleViewModel model)
        {
            string message = "That role name has already been used";

            if (ModelState.IsValid)
            {
                var role = new ApplicationRole(model.RoleName, model.Description);
                ApplicationRoleManager _roleManager = new RoleStore <IdentityRole>(context.Get <DataBaseContext>());
                if (_db.RoleExists(_roleManager, model.RoleName))
                {
                    return(View(message));
                }
                else
                {
                    _db.CreateRole(_roleManager, model.RoleName, model.Description);
                    return(RedirectToAction("Index", "Roles"));
                }
            }
            return(View());
        }