Пример #1
0
        public async Task <IActionResult> Put(Guid id, [FromBody] GameGoalieStatisticDTO value)
        {
            if (id != value.Id)
            {
                return(this.BadRequest("Posted game goalie statistic Id does not match the request."));
            }
            IActionResult result = await Execute(_log, async() => await _gameGoalieStatisticService.Upsert(value));

            return(result);
        }
Пример #2
0
        public async Task <GameGoalieStatisticDTO> Update(GameGoalieStatisticDTO dto)
        {
            var result = await this.Handler.Execute(_log, async() =>
            {
                GameGoalieStatistic gameGoalieStatistic = _gameGoalieStatisticFactory.CreateDomainObject(dto);
                gameGoalieStatistic.Validate();

                gameGoalieStatistic = await _gameGoalieStatisticRepository.Update(gameGoalieStatistic);
                return(_gameGoalieStatisticMapper.ToDto(gameGoalieStatistic));
            });

            return(result);
        }
Пример #3
0
        private async Task SaveGoalieStatistics(IList <GamePageGoalieStats> goalieStatistics, Guid gameId, Guid teamId)
        {
            foreach (var statistic in goalieStatistics)
            {
                var player = await GetOrCreatePlayer(statistic.GoalieName);

                GameGoalieStatisticDTO goalieStatistic = new GameGoalieStatisticDTO
                {
                    GameId       = gameId,
                    GoalsAllowed = statistic.GoalsAgainst,
                    ShotsAgainst = statistic.ShotsAgainst,
                    Saves        = statistic.Saves,
                    PlayerId     = player.Id,
                    TeamId       = teamId,
                    Result       = GetGoalieResult(statistic),
                    CreatedOnUtc = DateTime.Now
                };

                await _gameGoalieStatisticService.Upsert(goalieStatistic);
            }
        }
 public GameGoalieStatistic CreateDomainObject(GameGoalieStatisticDTO dto)
 {
     return(new GameGoalieStatistic(dto.Id, dto.GameId, dto.PlayerId, dto.TeamId, dto.ShotsAgainst, dto.GoalsAllowed, dto.Saves, dto.Result, dto.CreatedOnUtc));
 }
Пример #5
0
        public async Task <IActionResult> Post([FromBody] GameGoalieStatisticDTO value)
        {
            IActionResult result = await Execute(_log, async() => await _gameGoalieStatisticService.Upsert(value));

            return(result);
        }