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));
        }
Exemplo n.º 2
0
        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));
 }
Exemplo n.º 4
0
 public IActionResult DeleteMatch([FromRoute] int id)
 {
     matchService.Delete(id);
     return(Ok());
 }
Exemplo n.º 5
0
        public IActionResult Delete(int id)
        {
            var result = _matchService.Delete(id);

            return(Ok(_mapper.ToDTO(result)));
        }