예제 #1
0
    public async Task SaveNew(FleetWithOptionsViewModel fleet)
    {
        var coreModel = _mapper.Map <Fleet>(fleet);

        if (fleet.FleetType == Api.Enumerations.FleetType.SelectedClasses &&
            fleet.BoatClassIds != null)
        {
            coreModel.BoatClasses =
                (await _coreClubService.GetAllBoatClasses(fleet.ClubId))
                .Where(c => fleet.BoatClassIds.Contains(c.Id))
                .ToList();
        }
        else if (fleet.FleetType == Api.Enumerations.FleetType.SelectedBoats &&
                 fleet.CompetitorIds != null)
        {
            coreModel.Competitors =
                (await _coreCompetitorService.GetCompetitorsAsync(fleet.ClubId, null, false))
                .Where(c => fleet.CompetitorIds.Contains(c.Id))
                .ToList();
        }
        var fleetId = await _coreFleetService.SaveNew(coreModel);

        if (fleet.RegattaId.HasValue)
        {
            await _regattaService.AddFleetToRegattaAsync(fleetId, fleet.RegattaId.Value);
        }
    }
예제 #2
0
    private async Task <RaceWithOptionsViewModel> CreateClubRaceAsync(string clubInitials)
    {
        var club = await _coreClubService.GetMinimalClub(clubInitials);

        var model = new RaceWithOptionsViewModel
        {
            ClubId           = club.Id,
            FleetOptions     = await _coreClubService.GetActiveFleets(club.Id),
            SeriesOptions    = await _coreSeriesService.GetAllSeriesAsync(club.Id, DateTime.Today, false),
            ScoreCodeOptions = (await _coreScoringService.GetScoreCodesAsync(club.Id))
                               .OrderBy(s => s.Name).ToList(),
            CompetitorOptions          = new List <Competitor>(),
            CompetitorBoatClassOptions = (await _coreClubService.GetAllBoatClasses(club.Id)).OrderBy(c => c.Name),
            Date                = DateTime.Today,
            Weather             = await _weatherService.GetCurrentWeatherForClubAsync(club),
            WeatherIconOptions  = GetWeatherIconOptions(),
            ClubHasCompetitors  = await _coreClubService.DoesClubHaveCompetitors(club.Id),
            NeedsLocalDate      = true,
            UseAdvancedFeatures = club.UseAdvancedFeatures ?? false
        };

        return(model);
    }