Exemplo n.º 1
0
        //another approach
        // public async Task<AuctionDto> CreateAuctionDto(Auction auction)
        // {
        //     // var aDto = auctions.Select(_mapper.Map<AuctionDto>);
        //     // auction: Id, title, startedOn, endedOn
        //     var auctionDto = new AuctionDto
        //     {
        //         Id = auction.Id,
        //         Title = auction.Title,
        //         EndedOn = auction.EndedOn,
        //         AuctionSlotDtoItems = await GetAuctionSlots(auction.Id),
        //         CategoryNames = await GetDistinctCategoryNames(auction.Id)
        //     };
        //
        //     return auctionDto;
        // }
        // return dto form of slot
        // private async Task<IReadOnlyCollection<AuctionSlotDto>> GetAuctionSlots(Guid auctionId)
        // {
        //     var auctionSlotsSpecification = new AuctionSlotsSpecification(auctionId);
        //     var auctionSlots = await _slotRepository.ListAsync(auctionSlotsSpecification);
        //
        //     return null;
        // }

        public async Task AddSlotsToAuction(Auction auction, IEnumerable <Guid> slotIds)
        {
            foreach (var slotId in slotIds)
            {
                var slot = await _slotRepository.GetByIdAsync(slotId);

                if (slot != null)
                {
                    auction.AddSlot(slot);
                }
            }
        }