public async Task <IActionResult> CreateRole(ERRole model)
        {
            var name = model.RoleName + "";

            try
            {
                name = name.Trim();
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
            }
            if (ModelState.IsValid)
            {
                IdentityRole identityRole = new IdentityRole
                {
                    Name = name
                };
                IdentityResult result = await roleManager.CreateAsync(identityRole);

                if (result.Succeeded)
                {
                    ViewBag.Success = "Successfully added: " + name;
                    return(RedirectToAction("Index"));
                }
                foreach (IdentityError error in result.Errors)
                {
                    ModelState.AddModelError("", error.Description);
                }
            }
            return(View(model));
        }
Exemple #2
0
        public ActionResult Create(ERRole Role)
        {
            try
            {
                ERRepositry.Instance.AddRole(Role);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Exemple #3
0
        public ActionResult Edit(Guid id, ERRole Role)
        {
            try
            {
                ERRepositry.Instance.UpdateRole(Role);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Exemple #4
0
        //
        // GET: /Role/Create

        public ActionResult Create()
        {
            ERRole Role = new ERRole();

            return(View(Role));
        }