public async Task <SeriesWithOptionsViewModel> GetBlankVmForCreate(string clubInitials) { var clubId = await _coreClubService.GetClubId(clubInitials); var seasons = await _coreSeasonService.GetSeasons(clubId); var vm = new SeriesWithOptionsViewModel { SeasonOptions = seasons }; var selectedSeason = seasons.FirstOrDefault(s => s.Start <DateTime.Now && s.End> DateTime.Now); if (selectedSeason == null && seasons.Count() == 1) { selectedSeason = seasons.First(); } if (selectedSeason != null) { vm.SeasonId = selectedSeason.Id; } var scoringSystemOptions = await _coreScoringService.GetScoringSystemsAsync(clubId, true); scoringSystemOptions.Add(new ScoringSystem { Id = Guid.Empty, Name = "<Use Club Default>" }); vm.ScoringSystemOptions = scoringSystemOptions.OrderBy(s => s.Name).ToList(); return(vm); }
public async Task <Competitor> GetCompetitorAsync(string clubInitials, string sailNumber) { var clubId = await _coreClubService.GetClubId(clubInitials); var comps = await _coreCompetitorService.GetCompetitorsAsync(clubId, null, false); return(comps.FirstOrDefault(c => String.Equals(c.SailNumber, sailNumber, StringComparison.OrdinalIgnoreCase))); }
public async Task <IList <FleetSummary> > GetAllFleetSummary(string clubInitials) { var clubId = await _coreClubService.GetClubId(clubInitials); var coreFleets = await _coreFleetService.GetAllFleetsForClub(clubId); return(_mapper.Map <IList <FleetSummary> >(coreFleets)); }
public async Task <ActionResult> Options(string clubInitials) { var clubId = await _clubService.GetClubId(clubInitials); if (!await _authService.CanUserEdit(User, clubId)) { return(Unauthorized()); } IList <Core.Model.Competitor> competitors = await _competitorService.GetCompetitorsAsync(clubId, false); var vm = new MergeCompetitorViewModel { TargetCompetitorOptions = competitors.OrderBy(c => c.Name).ToList() }; return(View("SelectTarget", vm)); }
public async Task <JsonResult> Current(string clubInitials) { var clubId = await _clubService.GetClubId(clubInitials); var weatherVm = await _weatherService.GetCurrentWeatherForClubAsync(clubId); return(Json(weatherVm)); }
public async Task <ActionResult> Create( string clubInitials, RaceWithOptionsViewModel race, string returnUrl = null) { ViewData["ReturnUrl"] = returnUrl; if (!ModelState.IsValid) { RaceWithOptionsViewModel raceOptions = await _raceService.GetBlankRaceWithOptions( clubInitials, race.RegattaId, race.SeriesIds?.FirstOrDefault()); race.ScoreCodeOptions = raceOptions.ScoreCodeOptions; race.FleetOptions = raceOptions.FleetOptions; race.CompetitorBoatClassOptions = raceOptions.CompetitorBoatClassOptions; race.CompetitorOptions = raceOptions.CompetitorOptions; race.SeriesOptions = raceOptions.SeriesOptions; race.WeatherIconOptions = raceOptions.WeatherIconOptions; race.UseAdvancedFeatures = raceOptions.UseAdvancedFeatures; return(View(race)); } var clubId = await _clubService.GetClubId(clubInitials); if (!await _authService.CanUserEdit(User, clubId)) { return(Unauthorized()); } race.ClubId = clubId; race.UpdatedBy = await GetUserStringAsync(); await _raceService.SaveAsync(race); if (!string.IsNullOrWhiteSpace(returnUrl)) { return(Redirect(returnUrl)); } return(RedirectToAction("Index", "Admin")); }
public async Task <ActionResult> Details( string clubInitials, string season, string seriesName) { ViewData["ClubInitials"] = clubInitials; var series = await _seriesService.GetSeriesAsync(clubInitials, season, seriesName); if (series == null) { return(new NotFoundResult()); } var canEdit = false; if (User != null && (User.Identity?.IsAuthenticated ?? false)) { var clubId = await _clubService.GetClubId(clubInitials); canEdit = await _authService.CanUserEdit(User, clubId); } return(View(new ClubItemViewModel <Core.Model.Series> { Item = series, ClubInitials = clubInitials, CanEdit = canEdit })); }
public async Task <IEnumerable <RegattaSummaryViewModel> > GetAllRegattaSummaryAsync(string clubInitials) { var clubId = await _clubService.GetClubId(clubInitials); var regattas = await _coreRegattaService.GetAllRegattasAsync(clubId); var orderedRegattas = regattas .OrderByDescending(s => s.Season.Start) .ThenBy(s => s.StartDate) .ThenBy(s => s.Name); return(_mapper.Map <IList <RegattaSummaryViewModel> >(orderedRegattas)); }
public async Task <ActionResult> Create(string clubInitials) { var clubId = await _clubService.GetClubId(clubInitials); if (!await _authService.CanUserEdit(User, clubId)) { return(Unauthorized()); } var vm = await _regattaService.GetBlankRegattaWithOptions(clubId); return(View(vm)); }
public async Task UpdateStatsDescription(string clubInitials, string statisticsDescription) { var clubId = await _coreClubService.GetClubId(clubInitials); await _coreClubService.UpdateStatsDescription(clubId, statisticsDescription); }
public async Task <Season> GetCurrentSeasonAsync(string clubInitials) { var clubId = await _coreClubService.GetClubId(clubInitials); return(await _coreRaceService.GetMostRecentRaceSeasonAsync(clubId)); }