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 RaceDetailsDTO Get(int id) { Race race = IRaceRepository.Get(id); RaceDetailsDTO raceDetails = new RaceDetailsDTO() { Duration = race.Duration, Location = race.Location, NumberOfSpectators = race.NumberOfSpectators, Image = race.Image }; IEnumerable <TeamRace> teamRaces = ITeamRaceRepository.GetAll().Where(x => x.RaceId == id); if (teamRaces != null) { List <String> teamNames = new List <string>(); foreach (TeamRace teamRace in teamRaces) { Team team = ITeamRepository.GetAll().SingleOrDefault(x => x.Id == teamRace.TeamId); teamNames.Add(team.Team_name); } raceDetails.ParticipantTeams = teamNames; } return(raceDetails); }
public RaceEditModel GetForEdit(int?id) { if (id == null) { return(new RaceEditModel()); } var model = _raceRepository.Get(id.Value).ProjectTo <RaceEditModel>(MapperConfig).FirstOrDefault(); return(model ?? new RaceEditModel()); }
public IActionResult EnableDisable(int id) { var race = _raceRepository.Get(id); var model = new EnableDisableRaceViewModel(); model.IsEnabled = race.IsEnabled; return(View(model)); }
public static CharactersVM CreateCharacterVm(IRaceRepository raceRepository) { return(new CharactersVM() { Character = new Character(), RaceSelectList = new SelectList(raceRepository.Get(), "RaceId", "Name") }); }
public static CharactersVM EditCharacterVm(IRaceRepository raceRepository, Character c) { return(new CharactersVM() { Character = c, RaceSelectList = new SelectList(raceRepository.Get(), "RaceId", "Name") }); }
public void HandleEvent(TeamCreated teamCreated) { var xxx = Stopwatch.StartNew(); var race = _raceRepository.Get(teamCreated.RaceId); race.RegisterTeam(teamCreated.TeamId); _raceRepository.Update(race); StatsPrinter.Print("TeamCreated", xxx.ElapsedMilliseconds); }
// GET: Race public IActionResult Index() { return(View(repo.Get())); }
public async Task <List <Race> > Get() { var races = await raceRepository.Get(); return(races); }