예제 #1
0
        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);
        }
예제 #2
0
        public async Task <IActionResult> Post([FromBody] SeasonDto dto)
        {
            var season = _mapper.Map <Season>(dto);
            await _seasonService.AddAsync(season);

            return(Created("localhost", ""));
        }
예제 #3
0
        public async Task <Season> Add(SeasonDto season)
        {
            Season s = ConvertSeasonDtoToSeason(season);

            await _seasonManagementService.Add(s);

            return(s);
        }
예제 #4
0
        public ActionResult Delete([DataSourceRequest] DataSourceRequest request, SeasonDto seasonDto)
        {
            var season = Mapper.Map <SeasonDto, Season>(seasonDto);

            _seasonService.Delete(season.Id);

            return(Json(new { Data = seasonDto }));
        }
예제 #5
0
 private Season ConvertSeasonDtoToSeason(SeasonDto seasonDto)
 {
     return(new Season()
     {
         Id = seasonDto.Id,
         Year = seasonDto.Year
     });
 }
예제 #6
0
        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"));
        }
예제 #7
0
파일: Update.cs 프로젝트: dev027/Dealing
        /// <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();
        }
예제 #8
0
        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 }));
        }
예제 #9
0
파일: Create.cs 프로젝트: dev027/Dealing
        /// <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");
            }
        }
예제 #10
0
        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);
        }
예제 #11
0
        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);
        }
예제 #12
0
        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);
        }
예제 #13
0
        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));
        }
예제 #14
0
        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!"));
        }
예제 #16
0
        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));
        }
예제 #17
0
        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!"));
        }
예제 #19
0
 public async Task <Guid> SaveSeason(SeasonDto season)
 {
     return(await PostAsync <SeasonDto>($"/api/seasons/", season));
 }
예제 #20
0
        public ActionResult Update(SeasonDto dto)
        {
            var result = _seasonContract.Update(dto);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }