public async Task <IActionResult> Delete(int?id, string returnUrl)
        {
            if (id == null || !EventSeriesExists((int)id))
            {
                return(NotFound());
            }
            EventSeries es = await _eventService.EventSeries.GetEventSeriesWithEventsAndRegistrationsAsync((int)id);

            EventSeriesEditViewModel vm = new EventSeriesEditViewModel(es);

            ViewData["ActiveMenu"] = "Admin";
            ViewData["ActiveLink"] = "DeleteEventSeries";
            ViewData["Title"]      = "Delete Event Series?";
            ViewBag.ReturnUrl      = returnUrl;
            return(View(vm));
        }
 public async Task <IActionResult> Edit(int?id, [Bind("Id, Title, Description")] EventSeriesEditViewModel form, string returnUrl)
 {
     if ((int)id != form.Id)
     {
         return(NotFound());
     }
     if (!ModelState.IsValid)
     {
         form.InitializeEventList(await _eventService.Events.GetEventsWithRegistrationsForEventSeriesIdAsync(form.Id));
         ViewData["ActiveMenu"] = "Admin";
         ViewData["ActiveLink"] = "EventSeriesEdit";
         ViewData["Title"]      = "Edit Event Series: Error";
         ViewBag.ReturnUrl      = returnUrl;
         return(View(form));
     }
     else
     {
         if (!_eventService.UpdateEventSeries(form.Id, form.Title, form.Description, out string response))
         {
             form.InitializeEventList(await _eventService.Events.GetEventsWithRegistrationsForEventSeriesIdAsync(form.Id));
             ModelState.AddModelError("", response);
             ViewData["ActiveMenu"] = "Admin";
             ViewData["ActiveLink"] = "EventSeriesEdit";
             ViewData["Title"]      = "Edit Event Series: Error";
             ViewBag.ReturnUrl      = returnUrl;
             return(View(form));
         }
         else
         {
             if (!string.IsNullOrEmpty(returnUrl))
             {
                 return(Redirect(returnUrl));
             }
             else
             {
                 return(RedirectToAction(nameof(Index)));
             }
         }
     }
 }