// Delete a file in the user's root directory. public async Task <ActionResult> DeleteFileOrFolder(string id) { ResultsViewModel results = new ResultsViewModel(false); try { // Delete the item. results.Items = await filesService.DeleteFileOrFolder(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("Files", results)); }
// Delete a file in the user's root directory. public async Task <ActionResult> DeleteFileOrFolder(string id) { ResultsViewModel results = new ResultsViewModel(false); try { // Initialize the GraphServiceClient. GraphServiceClient graphClient = SDKHelper.GetAuthenticatedClient(); // Delete the item. results.Items = await filesService.DeleteFileOrFolder(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("Files", results)); }