public ActionResult Details(int id, EventViewModel collection) { try { if (id > 0) { var model = _eventService.GetById(id); if (model != null) { //model.UpdaterId = LogedInEvent.Id; _eventService.Delete(model); var lstMatchsId = _matchService.Find(new Match() { EventId = collection.Id }).Select(x => (long)x.Id.Value).ToArray(); if (lstMatchsId.Any()) { _matchService.Delete(lstMatchsId); } var lstClubsId = _clubService.Find(new Club() { EventId = collection.Id }).Select(x => (long)x.Id.Value).ToArray(); if (lstClubsId.Any()) { _clubService.Delete(lstClubsId); } if (!string.IsNullOrEmpty(collection.PreviousUrl)) { return(Redirect(collection.PreviousUrl)); } return(RedirectToAction("Index")); } } else { ModelState.AddModelError(string.Empty, GeneralMessages.EmptyId); } } catch (Exception ex) { _logger.Error(ex); if (ex.InnerException != null && ex.InnerException.Source.Equals(GeneralMessages.ExceptionSource)) { ModelState.AddModelError(string.Empty, ex.Message); } else { ModelState.AddModelError(string.Empty, GeneralMessages.UnexpectedError); } } return(View(collection)); }