public async Task <ActionResult> Delete(String id) { SmsServiceRole role = await RoleManager.FindByIdAsync(id); if (role != null) { await RoleManager.DeleteAsync(role); } return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit(String id) { SmsServiceRole role = await RoleManager.FindByIdAsync(id); if (role != null) { Mapper.CreateMap <SmsServiceRole, EditRoleModel>(); return(View(Mapper.Map <SmsServiceRole, EditRoleModel>(role))); } return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit(EditRoleModel model) { if (ModelState.IsValid) { SmsServiceRole role = await RoleManager.FindByIdAsync(model.Id); if (role != null) { role.Description = model.Description; role.Name = model.Name; IdentityResult result = await RoleManager.UpdateAsync(role); if (result.Succeeded) { return(RedirectToAction("Index")); } ModelState.AddModelError(String.Empty, "Не удалось обновить роль"); } } return(View(model)); }