private async Task <SeasonDto> MakeNewSeason() { Console.Write("Enter the new season name > "); var className = Console.ReadLine().Trim(); Console.Write("The season will be created for the full year. "); var year = GetYear(); var start = new DateTime(year, 1, 1); var season = new SeasonDto { Name = className, Start = start, End = start.AddYears(1), ClubId = _club.Id }; try { var guid = await _apiClient.SaveSeason(season); season.Id = guid; } catch (Exception ex) { Console.WriteLine($"Oh Noes! There was an exception: {ex}"); throw; } return(season); }
public async Task <IActionResult> Post([FromBody] SeasonDto dto) { var season = _mapper.Map <Season>(dto); await _seasonService.AddAsync(season); return(Created("localhost", "")); }
public async Task <Season> Add(SeasonDto season) { Season s = ConvertSeasonDtoToSeason(season); await _seasonManagementService.Add(s); return(s); }
public ActionResult Delete([DataSourceRequest] DataSourceRequest request, SeasonDto seasonDto) { var season = Mapper.Map <SeasonDto, Season>(seasonDto); _seasonService.Delete(season.Id); return(Json(new { Data = seasonDto })); }
private Season ConvertSeasonDtoToSeason(SeasonDto seasonDto) { return(new Season() { Id = seasonDto.Id, Year = seasonDto.Year }); }
public async Task <IActionResult> Put([FromRoute] int id, [FromBody] SeasonDto dto) { var season = _mapper.Map <Season>(dto); season.Id = id; await _seasonService.UpdateAsync(season); return(Ok("Updated")); }
/// <inheritdoc/> public void UpdateSeason(ISeason season) { SeasonDto seasonDto = SeasonDto.ToDto(season); this.Context.Entry( this.Context.Seasons .Single(s => s.Id == seasonDto.Id)) .CurrentValues.SetValues(seasonDto); this.Context.SaveChanges(); }
public ActionResult Update([DataSourceRequest] DataSourceRequest request, SeasonDto seasonDto) { var season = Mapper.Map <SeasonDto, Season>(seasonDto); if (season != null) { _seasonService.Update(season); } return(Json(new { Data = seasonDto })); }
/// <inheritdoc /> public void CreateSeason(ISeason season) { SeasonDto seasonDto = SeasonDto.ToDto(season); this.Context.Seasons.Add(seasonDto); int count = this.Context.SaveChanges(); if (count != 1) { throw new ApplicationException($"Unexpectedly created {count} rows"); } }
public async Task WriteSwSeriesToSS(SwObjects.Series series) { _club = await GetClub(); _boatClass = await GetBoatClass(); _fleet = await GetFleet(); _season = await GetSeason(); _series = await MakeSeries(series); _competitors = await GetCompetitors(series); await SaveRaces(series); }
public static SeasonDto FromQueryResponse(this SeasonDto dto, GetSeasonsResponse.Season response, string tvShowTitle) { if (response == null) { return(dto); } var seasonDto = new SeasonDto { Id = response.id.ToString(), Number = response.season_number }; return(seasonDto); }
public static SeasonDto FromQueryResponse(this SeasonDto dto, GetSeasonsResponse.MediaContainerDirectory queryResult) { if (queryResult == null) { return(dto); } var seasonDto = new SeasonDto { Episodes = null, Number = queryResult.index, IdPlex = queryResult.ratingKey }; return(seasonDto); }
public async Task <ActionResult <Guid> > Post([FromBody] SeasonDto season) { if (!await _authService.CanUserEdit(User, season.ClubId)) { return(Unauthorized()); } var seasonBizObj = _mapper.Map <Season>(season); await _clubService.SaveNewSeason(seasonBizObj); var savedSeason = (await _clubService.GetFullClubExceptScores(season.ClubId)) .Seasons .First(c => c.Name == season.Name); return(Ok(savedSeason.Id)); }
public async Task <IActionResult> UpdateSeason([FromBody] SeasonDto season) { if (season == null) { return(BadRequest("SeasonDto object is null")); } var seasonEntity = await _repository.Season.GetSeasonAsync(season.Id, trackChanges : true); if (seasonEntity == null) { return(NotFound()); } _mapper.Map(season, seasonEntity); await _repository.SaveAsync(); return(NoContent()); }
public async Task <ActionResult> InsertTournamentSeason(SeasonDto seasonDto) { var tour = await unitOfWork.BilliardsTournamentRepository.GetTournamentById(seasonDto.TournamentId); if (tour == null) { return(BadRequest("Tournamend invalid!")); } unitOfWork.BilliardsRepository.InsertSeasonForTournament(mapper.Map <Season>(seasonDto)); if (await unitOfWork.Complete()) { return(NoContent()); } return(BadRequest("Insert failed!")); }
private static DateTime GetDate(SwObjects.Race swRace, SeasonDto season) { // assume race name format of "6-22 R1" or "6-23" var datepart = swRace.Name.Split(' ')[0]; if (String.IsNullOrWhiteSpace(datepart)) { return(DateTime.Today); } var parts = datepart.Split(new[] { '-', '/' }); int month = season.Start.Month; int day = season.Start.Day; Int32.TryParse(parts[0], out month); Int32.TryParse(parts[1], out day); return(new DateTime(season.Start.Year, month, day)); }
public static string ToCustomString(this SeasonDto season) { switch (season) { case SeasonDto.PreSeason3: return("PRESEASON3"); case SeasonDto.Season3: return("SEASON3"); case SeasonDto.PreSeason2014: return("PRESEASON2014"); case SeasonDto.Season2014: return("SEASON2014"); case SeasonDto.PreSeason2015: return("PRESEASON2015"); case SeasonDto.Season2015: return("SEASON2015"); case SeasonDto.PreSeason2016: return("PRESEASON2016"); case SeasonDto.Season2016: return("SEASON2016"); case SeasonDto.PreSeason2017: return("PRESEASON2017"); case SeasonDto.Season2017: return("SEASON2017"); case SeasonDto.PreSeason2018: return("PRESEASON2018"); case SeasonDto.Season2018: return("SEASON2018"); default: return(string.Empty); } }
public async Task <ActionResult> UpdateTournamentSeason(SeasonDto seasonDto) { var cur = await unitOfWork.BilliardsRepository.GetSeasonForTournamentAsync(seasonDto.Id); if (cur == null) { return(BadRequest("No such season!")); } // update to done, season cannot be updated or deleted anymore cur.IsDone = true; unitOfWork.BilliardsRepository.UpdateSeason(cur); if (await unitOfWork.Complete()) { return(NoContent()); } return(BadRequest("Update failed!")); }
public async Task <Guid> SaveSeason(SeasonDto season) { return(await PostAsync <SeasonDto>($"/api/seasons/", season)); }
public ActionResult Update(SeasonDto dto) { var result = _seasonContract.Update(dto); return(Json(result, JsonRequestBehavior.AllowGet)); }