// Delete an event. public async Task <ActionResult> DeleteEvent(string id) { ResultsViewModel results = new ResultsViewModel(); results.Selectable = false; try { // Initialize the GraphServiceClient. GraphServiceClient graphClient = SDKHelper.GetAuthenticatedClient(); // Delete the event. results.Items = await eventsService.DeleteEvent(graphClient, id); } catch (ServiceException se) { if (se.Error.Message == Resource.Error_AuthChallengeNeeded) { return(new EmptyResult()); } // Personal accounts that aren't enabled for the Outlook REST API get a "MailboxNotEnabledForRESTAPI" or "MailboxNotSupportedForRESTAPI" error. return(RedirectToAction("Index", "Error", new { message = string.Format(Resource.Error_Message, Request.RawUrl, se.Error.Code, se.Error.Message) })); } return(View("Events", results)); }
public IActionResult Delete(int id) { if (!ModelState.IsValid) { return(BadRequest(this.ModelState)); } else { _eventService.DeleteEvent(id); return(Ok()); } }
public async Task DeleteEventShouldDeleteTheCorrectEventAndCorrespondingPost() { await this.PopulateEvents(); await this.PopulatePosts(); var service = new EventsService( this.eventsRepository, this.postsService, this.postRepository); await service.DeleteEvent(2); var eventTo = this.eventsRepository.All().FirstOrDefault(e => e.Title == "ccc"); var post = this.postRepository.All().FirstOrDefault(p => p.Id == 2); Assert.Null(eventTo); Assert.Null(post); }
// Delete an event. public async Task <ActionResult> DeleteEvent(string id) { ResultsViewModel results = new ResultsViewModel(false); try { // Delete the event. results.Items = await eventsService.DeleteEvent(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("Events", results)); }