public async Task <ActionResult> DeleteEvent(string eventId) { var context = this.Request.GetOwinContext(); var userObjectId = context.Authentication.User.GetUserObjectId(); var fetchedEvent = await this.eventDataProvider.GetEventByIdAsync(eventId, userObjectId); if (fetchedEvent != null) { await this.eventDataProvider.DeleteEventAsync(eventId, userObjectId); await this.eventDataProvider.DeleteEventOccurrencesByEventIdAsync(eventId); await this.eventDataProvider.DeleteEventMessagesByEventIdAsync(eventId); } else { this.logProvider.LogInfo($"Could not find event {eventId} belonging to {userObjectId}"); } var viewModel = new EventsTabViewModel { Events = await this.GetEventsByOwnerObjectIdAsync(userObjectId), MaxUserEventsCount = Convert.ToInt32(this.configProvider.GetSetting(ApplicationConfig.MaxUserEventsCount)), }; return(this.PartialView("EventsData", viewModel)); }
public ActionResult Events() { var viewModel = new EventsTabViewModel { MaxUserEventsCount = Convert.ToInt32(this.configProvider.GetSetting(ApplicationConfig.MaxUserEventsCount)), }; return(this.View(viewModel)); }
public async Task <ActionResult> EventsData() { var context = this.Request.GetOwinContext(); var userObjectId = context.Authentication.User.GetUserObjectId(); var viewModel = new EventsTabViewModel { Events = await this.GetEventsByOwnerObjectIdAsync(userObjectId), MaxUserEventsCount = Convert.ToInt32(this.configProvider.GetSetting(ApplicationConfig.MaxUserEventsCount)), }; return(this.PartialView(viewModel)); }
public async Task <ActionResult> SaveEvent(CelebrationEvent celebrationEvent) { var context = this.Request.GetOwinContext(); var userObjectId = context.Authentication.User.GetUserObjectId(); if (this.ModelState.IsValid) { celebrationEvent.OwnerAadObjectId = userObjectId; await this.eventDataProvider.AddEventAsync(celebrationEvent); } var viewModel = new EventsTabViewModel { Events = await this.GetEventsByOwnerObjectIdAsync(userObjectId), MaxUserEventsCount = Convert.ToInt32(this.configProvider.GetSetting(ApplicationConfig.MaxUserEventsCount)), }; return(this.PartialView("EventsData", viewModel)); }
public async Task <ActionResult> UpdateEvent(CelebrationEvent celebrationEvent) { var context = this.Request.GetOwinContext(); var userObjectId = context.Authentication.User.GetUserObjectId(); if (this.ModelState.IsValid) { // Ensure that the provided event is actually owned by the current user var fetchedEvent = await this.eventDataProvider.GetEventByIdAsync(celebrationEvent.Id, userObjectId); if (fetchedEvent != null) { celebrationEvent.OwnerAadObjectId = userObjectId; await this.eventDataProvider.UpdateEventAsync(celebrationEvent); // If event date or timezone is changed then delete record from Occurrences and EventMessages collections if (fetchedEvent.Date != celebrationEvent.Date || fetchedEvent.TimeZoneId != celebrationEvent.TimeZoneId) { await this.eventDataProvider.DeleteEventOccurrencesByEventIdAsync(celebrationEvent.Id); await this.eventDataProvider.DeleteEventMessagesByEventIdAsync(celebrationEvent.Id); // The next run of the preview function will handle scheduling the preview } } else { this.logProvider.LogInfo($"Could not find event {celebrationEvent.Id} belonging to {userObjectId}"); } } var viewModel = new EventsTabViewModel { Events = await this.GetEventsByOwnerObjectIdAsync(userObjectId), MaxUserEventsCount = Convert.ToInt32(this.configProvider.GetSetting(ApplicationConfig.MaxUserEventsCount)), }; return(this.PartialView("EventsData", viewModel)); }