Example #1
0
        public async Task <ActionResult> Create(CreateGroupModel model)
        {
            var identityGroupService = new IdentityGroupService();

            try
            {
                if (!ModelState.IsValid)
                {
                    return(PartialView("_Create", model));
                }

                var group = new Group()
                {
                    Name        = model.Name,
                    Description = model.Description
                };

                var result = await identityGroupService.CreateAsync(group);

                if (result.Succeeded)
                {
                    return(Json(new { success = true }));
                }

                AddErrors(result);

                return(PartialView("_Create", model));
            }
            finally
            {
                identityGroupService.Dispose();
            }
        }
Example #2
0
        public async Task <bool> Delete(long groupId)
        {
            var identityGroupService = new IdentityGroupService();

            try
            {
                var group  = identityGroupService.FindByIdAsync(groupId).Result;
                var result = await identityGroupService.DeleteAsync(group);

                return(result.Succeeded);
            }
            finally
            {
                identityGroupService.Dispose();
            }
        }