private static void DeleteGroup() { if (_createdGroup == null) { return; } Console.WriteLine(); // Remove the previously created group Console.WriteLine(); Console.WriteLine($"Delete Group With Id {_createdGroup.Id}"); GroupsService.DeleteGroup(_createdGroup.Id); }
// Delete a group. Warning: This operation cannot be undone. // This snippet requires an admin work account. public async Task <ActionResult> DeleteGroup(string id) { ResultsViewModel results = new ResultsViewModel(false); try { // Delete the group. results.Items = await groupsService.DeleteGroup(id); } catch (ServiceException se) { if ((se.InnerException as AuthenticationException)?.Error.Code == Resource.Error_AuthChallengeNeeded) { HttpContext.Request.GetOwinContext().Authentication.Challenge(); return(new EmptyResult()); } return(RedirectToAction("Index", "Error", new { message = string.Format(Resource.Error_Message, Request.RawUrl, se.Error.Code, se.Error.Message) })); } return(View("Groups", results)); }
// Delete a group. Warning: This operation cannot be undone. // This snippet requires an admin work account. public async Task <ActionResult> DeleteGroup(string id) { ResultsViewModel results = new ResultsViewModel(false); try { // Initialize the GraphServiceClient. GraphServiceClient graphClient = SDKHelper.GetAuthenticatedClient(); // Delete the group. results.Items = await groupsService.DeleteGroup(graphClient, id); } catch (ServiceException se) { if (se.Error.Message == Resource.Error_AuthChallengeNeeded) { return(new EmptyResult()); } return(RedirectToAction("Index", "Error", new { message = string.Format(Resource.Error_Message, Request.RawUrl, se.Error.Code, se.Error.Message) })); } return(View("Groups", results)); }