示例#1
0
    private async Task <RaceWithOptionsViewModel> CreateRegattaRaceAsync(
        string clubInitials,
        Guid?regattaId)
    {
        var model = await CreateClubRaceAsync(clubInitials);

        if (!regattaId.HasValue)
        {
            return(model);
        }

        var regatta = await _coreRegattaService.GetRegattaAsync(regattaId.Value);

        model.Regatta      = _mapper.Map <RegattaSummaryViewModel>(regatta);
        model.FleetOptions = regatta.Fleets;
        if (regatta.ScoringSystemId.HasValue)
        {
            var scoreSystem = await _coreScoringService
                              .GetScoringSystemAsync(regatta.ScoringSystemId.Value);

            model.ScoreCodeOptions =
                scoreSystem.ScoreCodes
                .Union(scoreSystem.InheritedScoreCodes)
                .ToList();
        }
        else
        {
            model.ScoreCodeOptions = (await _coreScoringService.GetScoreCodesAsync(model.ClubId))
                                     .OrderBy(s => s.Name).ToList();
        }
        model.CompetitorOptions = regatta.Fleets?.FirstOrDefault()?.Competitors;
        if (regatta.StartDate.HasValue && regatta.EndDate.HasValue &&
            DateTime.Today >= regatta.StartDate && DateTime.Today <= regatta.EndDate)
        {
            model.Date = DateTime.Today;
        }
        else if (regatta.StartDate.HasValue)
        {
            model.Date = regatta.StartDate.Value;
        }
        else
        {
            model.Date = DateTime.Today;
        }
        return(model);
    }
示例#2
0
 public async Task <Regatta> GetRegattaAsync(Guid regattaId)
 {
     return(await _coreRegattaService.GetRegattaAsync(regattaId));
 }