Пример #1
0
        public async Task<ActionResult> Create(UserRoleViewModel userRoleViewModel)
        {
            if (!ModelState.IsValid) return View();

            var role = new BlogRole(userRoleViewModel.Name)
            {
                Description = userRoleViewModel.Description
            };

            // Save the new Description property:
            var roleresult = await RoleManager.CreateAsync(role);
            if (roleresult.Succeeded) return RedirectToAction("Index");

            ModelState.AddModelError("", roleresult.Errors.First());
            return View();
        }
Пример #2
0
        //
        // GET: /Roles/Edit/Admin
        public async Task<ActionResult> Edit(string id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            var role = await RoleManager.FindByIdAsync(id);
            if (role == null)
            {
                return HttpNotFound();
            }
            var userRoleViewModel = new UserRoleViewModel
            {
                Id = role.Id,
                Name = role.Name,
                Description = role.Description
            };

            // Update the new Description property for the ViewModel:
            return View(userRoleViewModel);
        }