public async Task <ActionResult> Create(CreateGroupModel model) { using (var identityGroupService = new IdentityGroupService()) { if (!ModelState.IsValid) { return(PartialView("_Create", model)); } var group = new Group() { Name = model.Name, DisplayName = 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)); } }
public async Task <bool> Delete(long groupId) { using (var identityGroupService = new IdentityGroupService()) { var group = identityGroupService.FindByIdAsync(groupId).Result; foreach (var user in group.Users) { await RemoveUserFromGroup(user.Id, @group.Name); } var result = await identityGroupService.DeleteAsync(group); return(result.Succeeded); } }
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(); } }