예제 #1
0
        public AuctionViewModel CreateAuction(string username, AuctionItemViewModel auctionItemViewModel, int auctionState = 1)
        {
            if (auctionItemViewModel == null)
            {
                throw new ArgumentNullException($"AuctionItemViewModel must be provided");
            }

            var user = GetUser(username);

            if (user == null)
            {
                throw new ArgumentException($"User {username} doesn't exist");
            }

            var newAuction = CreateNewAuctionViewModel(username, auctionItemViewModel, auctionState);
            var auction    = _auctionRepository.CreateAuction(newAuction.ToAuction(user));

            _auditRepository.CreateRecord(username, auction.AuctionId.ToString(), "Auction created");

            return(auction.ToAuctionViewModel());
        }