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)); }
public async Task <IActionResult> Delete(Guid id) { var loggedUser = LoggedInUser.Current?.Id; if (loggedUser.HasValue) { var user = await _userService.GetAsync(LoggedInUser.Current.Id) .ConfigureAwait(true); await _matchService.Delete(user.Id, id); return(Ok()); } return(BadRequest()); }
public ActionResult Details(int id, MatchViewModel collection) { try { if (id > 0) { var model = _matchService.GetById(id); if (model != null) { //model.UpdaterId = LogedInMatch.Id; _matchService.Delete(model); 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)); }
public IActionResult DeleteMatch([FromRoute] int id) { matchService.Delete(id); return(Ok()); }
public IActionResult Delete(int id) { var result = _matchService.Delete(id); return(Ok(_mapper.ToDTO(result))); }