Ejemplo n.º 1
0
 //Редактирование роли
 public async Task<CreateRoleModel> UpdateAsync(CreateRoleModel roleUpdate)
 {
     CatalogRole role = await _roleManager.FindByIdAsync(roleUpdate.Id);
     role.Name = roleUpdate.Name;
     role.MaxFileSizeExNetwork = roleUpdate.MaxFileSizeExNetwork;
     role.MaxFileSizeInNetwork = roleUpdate.MaxFileSizeInNetwork;
     role.MaxDownLoadsPerDay = roleUpdate.MaxDownLoadsPerDay;
     role.UploadFiles = roleUpdate.UploadFiles;
     role.Bonus = roleUpdate.Bonus;
     IdentityResult result = await _roleManager.UpdateAsync(role);
     return result.Succeeded ? roleUpdate : null;
 }
Ejemplo n.º 2
0
 //Создание роли
 public async Task<CreateRoleModel> CreateAsync(CreateRoleModel roleCreate)
 {
     CatalogRole role = new CatalogRole
     {
         Name = roleCreate.Name,
         MaxFileSizeExNetwork = roleCreate.MaxFileSizeExNetwork,
         MaxFileSizeInNetwork = roleCreate.MaxFileSizeInNetwork,
         MaxDownLoadsPerDay = roleCreate.MaxDownLoadsPerDay,
         UploadFiles = roleCreate.UploadFiles,
         Bonus = roleCreate.Bonus,
     };
     IdentityResult result = await _roleManager.CreateAsync(role);
     return result.Succeeded ? roleCreate : null;
 }
Ejemplo n.º 3
0
 public async Task<ActionResult> EditRole(CreateRoleModel role)
 {
     if (ModelState.IsValid)
     {
         if (await RoleService.UpdateAsync(role) != null)
         {
             ViewBag.Status = "Роль " + role.Name + " успешно изменена";
             return PartialView("Success");
         }
         else
         {
             return HttpNotFound();
         }
     }
     return View();
 }