// GET: Events/Delete/Hackference2017 public async Task <ActionResult> Delete(string eventName, IFormCollection collection) { var evnt = await _apiRepository.GetEventByEventName(eventName); //check security if (evnt.Owner.ToLower() == CurrentUser().ToLower()) { try { var isSucess = await _apiRepository.DeleteEventByEventName(eventName); if (isSucess) { return(RedirectToAction(nameof(Index))); } else { ViewData["message"] = "There was a problem deleting the event."; return(View()); } } catch { return(View()); } } else { var message = $"You cannot view events that you did not create. Please contact {evnt.Owner} who is the owner of this event."; return(RedirectToAction("Index", new { message = message })); } }