public async Task<ActionResult> Create(CreateViewModel createViewModel)
        {
            if (!ModelState.IsValid)
            {
                return View(createViewModel);
            }

            var applicationRoleList = new List<ApplicationRole>();
            var checkBoxRoleViewModelArray = createViewModel.CheckBoxRoleViewModelList.ToArray();
            for (var i = 0; i < checkBoxRoleViewModelArray.Count(); i++)
            {
                var checkBoxRole = createViewModel.CheckBoxRoleViewModelList[i];
                var selectedRoleId = checkBoxRole.Selected ? checkBoxRole.Id : 0;
                var selectedRole = await RoleManager.FindByIdAsync(selectedRoleId);
                applicationRoleList.Add(selectedRole);
            }
            var group = new Group()
            {
                Name = createViewModel.Name,
                Description = createViewModel.Description,
                ApplicationRoles = applicationRoleList,
            };
            GroupService.CreateGroup(group);
            TempData["GroupId"] = group.GroupId;
            TempData["GroupName"] = group.Name;
            TempData["Message"] = GroupsMessage.CreateSuccess;

            return RedirectToAction("index", "groups");
        }
 public async Task<ActionResult> Create()
 {
     var checkBoxRoleViewModelList = new List<create.CheckBoxRoleViewModel>();
     var roleArray = await RoleManager.Roles.ToArrayAsync();
     for (int i = 0; i < roleArray.Count(); i++)
     {
         var role = roleArray[i];
         var checkBoxRoleViewModel = new create.CheckBoxRoleViewModel()
         {
             Id = role.Id,
             Description = role.Description,
             Name = role.Name,
         };
         checkBoxRoleViewModelList.Add(checkBoxRoleViewModel);
     }
     var createViewModel = new CreateViewModel()
     {
         CheckBoxRoleViewModelList = checkBoxRoleViewModelList
     };
     return View(createViewModel);
 }