Ejemplo n.º 1
0
 public async Task Delete(int id)
 {
     try
     {
         await _RaceRepository.Delete(id);
     }
     catch (Exception ex)
     {
         File.WriteAllText("log.txt", ex.Message + " - " + ex.StackTrace);
         throw new Exception("Erro no banco de dados, contate o administrador");
     }
 }
Ejemplo n.º 2
0
        public ActionResult CalculateDistances(int id)
        {
            RaceDetails details = _raceRepository.GetRaceDetails(UserContext.User.Id, UserContext.User.OrganizationId, id);

            if (details.Detail == null || details.Detail.EntityStateId != Dom.EntityType.Race.State.Open)
            {
                return(NotFoundResult());
            }

            Race race = _raceRepository.Get <Race>(id);

            race.RaceDistances.ToList().ForEach(x => _raceRepository.Delete(x));
            var members = race.RacePigeons.Select(m => m.Pigeon.Member).Distinct().ToList();

            foreach (var member in members)
            {
                race.RaceDistances.Add(new RaceDistance
                {
                    Distance = member.Address?.Latitude == null
                                                ? 0
                                                : CoordinatesManager.CalculateDistance(member.Address.Latitude, member.Address.Longitude,
                                                                                       race.Point.Address.Latitude, race.Point.Address.Longitude),
                    MemberId = member.Id
                });
            }
            _raceRepository.UnitOfWork.SaveChanges();

            return(RedirectToAction(Mvc.Controller.Race.Details, Mvc.Controller.Race.Name, new { id }));
        }
Ejemplo n.º 3
0
        public Race Delete(int id)
        {
            Race model = IRaceRepository.Get(id);

            IEnumerable <TeamRace> teamRaces = ITeamRaceRepository.GetAll().Where(x => x.RaceId == id);

            foreach (TeamRace teamRace in teamRaces)
            {
                ITeamRaceRepository.Delete(teamRace);
            }

            return(IRaceRepository.Delete(model));
        }
Ejemplo n.º 4
0
        public IActionResult Delete([FromRoute] int id, RaceViewModel model)
        {
            if (ModelState.IsValid)
            {
                _raceRepository.Delete(id);

                return(RedirectToAction("/Index"));
            }

            ModelState.AddModelError("", "Errore generico");

            return(View(model));
        }
        public IActionResult Delete([FromBody] DeleteGameRequest deleteReq)
        {
            Player player = (Player)HttpContext.Items["Player"];

            NotAllowedResponse     na  = new NotAllowedResponse();
            BadRequestObjectResult res = new BadRequestObjectResult(na);

            res.StatusCode = 400; // TODO, find correct HTTP resp. code

            Race race = raceRepo.Find(deleteReq.gameId);

            if (race == null)
            {
                na.message = "No such race with id '" + deleteReq.gameId + "' exists.";
            }

            if (!race.getOwner().Equals(player))
            {
                na.message = "You're not the owner of this race.";
            }

            if (race.GetState() != Race.State.notStarted)
            {
                na.message = "You can't delete a game in progress.";
            }

            bool deletionOk = raceRepo.Delete(race);

            if (!deletionOk)
            {
                // TODO, Internal 500?
            }

            if (na.message != "")
            {
                return(res);
            }

            return(new OkResult());
        }
Ejemplo n.º 6
0
        public IActionResult DeleteConfirmed(int id)
        {
            repo.Delete(id);

            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 7
0
 public void Delete(int id)
 {
     _bonusService.BatchClear(id, BonusType.Race);
     _abilityService.BatchClear(id);
     _raceRepository.Delete(id);
 }