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"); } }
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 })); }
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)); }
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()); }
public IActionResult DeleteConfirmed(int id) { repo.Delete(id); return(RedirectToAction(nameof(Index))); }
public void Delete(int id) { _bonusService.BatchClear(id, BonusType.Race); _abilityService.BatchClear(id); _raceRepository.Delete(id); }