示例#1
0
        public async Task <GetOrderDto> AddOrderGameAsync(OrderGameDto orderGame, CancellationToken ct = default)
        {
            _logger.LogInformation(
                "Add game to active order for user, {AccountId}, {GameId}",
                orderGame.AccountId,
                orderGame.GameId);

            OrderBase currentOrder = await GetCurrentOrderAsync(orderGame.AccountId, ct);

            await ValidateAddingGameToOrderAsync(currentOrder, orderGame.GameId, ct);

            currentOrder.AddGame(orderGame.GameId);

            _unitOfWork.OrderRepository.Update(currentOrder);
            await _unitOfWork.SaveAsync(ct);

            currentOrder = await GetCurrentOrderAsync(orderGame.AccountId, ct);

            return(_mapper.Map <GetOrderDto>(currentOrder));
        }