コード例 #1
0
        public async Task<ActionResult> Edit(RolesAdminEditViewModel model)
        {
            var tempIdentityRole = new IdentityRole
            {
                Id = model.RoleId,
                Name = model.RoleName
            };

            if(ModelState.IsValid)
            {
                var result = await RoleManager.UpdateAsync(tempIdentityRole);
                if(!result.Succeeded)
                {
                    ModelState.AddModelError("", result.Errors.First().ToString());
                    return View();
                }
                return RedirectToAction("Index");
            }
            else
            {
                return View();
            }
        }
コード例 #2
0
        //Get: /RolesAdmin/Edit/5
        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 editVM = new RolesAdminEditViewModel
            {
                RoleId = role.Id,
                RoleName = role.Name
            };

            return View(editVM);
        }