public IEnumerable <ChipInHeat> GetChipsInHeatsForEvent(int eventId) { var heats = _heatService.GetHeatsForEvent(eventId); IEnumerable <ChipInHeat> result = Enumerable.Empty <ChipInHeat>(); foreach (var item in heats) { var r = GetChipsInHeatForHeat(item.Id); result.Concat(r); } return(result); }
public async void TestHeatReorder() { //Arrange await _service.AddAsync(1); await _service.AddAsync(1); await _service.AddAsync(1); await _service.AddAsync(1); await _service.RemoveAsync(3); //Act await _service.ReorderHeatsAsync(1); IEnumerable <Heat> result = _service.GetHeatsForEvent(1); var r = (from x in result select x).LastOrDefault(); int i = r.HeatNumber; //Assert Assert.Equal(expected: 2, actual: i); }
public IEnumerable <MarkersInEventViewModel> GetMarkersForEvent(int id) { var heats = _heatService.GetHeatsForEvent(id); var e = _eventService.GetEventById(id); var result = (from m in GetMarkersForCompetitionInstance(e.CompetitionInstanceId) join markersInHeat in _repo.GetMarkersInHeats() on m.Id equals markersInHeat.MarkerId join h in heats on markersInHeat.HeatId equals h.Id select new MarkersInEventViewModel { HeatNumber = h.HeatNumber, Marker = m }).ToList(); return(result); }
public async Task <IActionResult> EditContestantInEvent(string userId, int competitionInstanceId, int competitionId, int eventId) { var user = await _adminService.GetUserByIdAsync(userId); var competitionInstance = await _competitionService.GetCompetitionInstanceByIdAsync(competitionInstanceId); var competiton = await _competitionService.GetCompetitionByIdAsync(competitionId); var _event = await _eventService.GetEventByIdAsync(eventId); var heats = _heatService.GetHeatsForEvent(eventId); var dto = _competitionService.GetEditContestantChipHeatResultDtoFor(userId, eventId, competitionInstanceId); var nationName = _adminService.GetNationalityById((int)user.Nationality); var model = new EditContestantInEventDto { CompetitionName = competiton.Name, CompetitionInstanceName = competitionInstance.Name, EventName = _event.Name, UserName = user.Username, FirstName = user.FirstName, MiddleName = user.MiddleName, LastName = user.LastName, DateOfBirth = user.DateOfBirth, NationId = user.Nationality, Nationality = nationName, Phone = user.Phone, HeatNumber = dto.HeatNumber, Bib = dto.Bib, ChipNumber = dto.ChipNumber, HeatId = dto.HeatId, OldHeatId = dto.HeatId, ContestantInHeatModified = dto.ContestantInHeatModified, Notes = dto.Notes, Status = dto.Status, Team = dto.Team, HeatsInEvent = heats, OldChipCode = dto.ChipCode }; return(View(model)); }
public IActionResult Event(int competitionId, int competitionInstanceId, int eventId) { var eventObj = _eventService.GetEventByIdAsync(eventId); eventObj.Wait(); var heats = _heatService.GetHeatsForEvent(eventId); var models = new List <HeatViewModel>(); foreach (var heat in heats) { var model = new HeatViewModel { Deleted = heat.Deleted, EventId = heat.EventId, HeatNumber = heat.HeatNumber, Id = heat.Id, NumberOfContestants = _heatService.GetContestantsInHeat(heat.Id).Count() }; models.Add(model); } var competition = _competitionService.GetCompetitionByIdAsync(competitionId); competition.Wait(); var competitionInstance = _competitionService.GetCompetitionInstanceByIdAsync(competitionInstanceId); competitionInstance.Wait(); var eventDto = new EventDto() { Competition = competition.Result, CompetitionInstance = competitionInstance.Result, Event = eventObj.Result, Heats = models, }; return(View(eventDto)); }
public async Task <IActionResult> RegisterToEvent(RegisterToEventDto model, string userId, int eventId) { if (ModelState.IsValid) { var heatsInEvent = _heatService.GetHeatsForEvent(model.Event.Id); var heatId = (from x in heatsInEvent where x.HeatNumber == 0 select x.Id).SingleOrDefault(); var contestantInHeat = new ContestantInHeat { HeatId = heatId, UserId = model.UserId, Modified = DateTime.Now }; await _heatService.AddAsyncContestantInHeat(contestantInHeat); return(RedirectToAction("Events", "User", new { @competitionInstanceId = model.Instance.Id })); } return(View(model)); }