Beispiel #1
0
 private void Create(AuctionArgs auctionArgs, bool compareToNow)
 {
     ValidateDates(auctionArgs.StartDate, auctionArgs.EndDate, compareToNow);
     if (BuyNowOnly && BuyNowPrice.Value == 0)
     {
         throw new DomainException("Cannot create buyNowOnly auction with buyNowPrice 0");
     }
     BuyNowPrice = auctionArgs.BuyNowPrice;
     StartDate   = auctionArgs.StartDate;
     EndDate     = auctionArgs.EndDate;
     Owner       = auctionArgs.Creator;
     Product     = auctionArgs.Product;
     Category    = auctionArgs.Category;
     BuyNowOnly  = auctionArgs.BuyNowOnly;
     Name        = auctionArgs.Name;
     if (auctionArgs.Tags.Length < MIN_TAGS)
     {
         throw new DomainException("Not enough auction tags");
     }
     else
     {
         if (!(auctionArgs.Tags.Select(tag => tag.Value).Distinct().Count() == auctionArgs.Tags.Length))
         {
             throw new DomainException("Tags array does not contain unique tags");
         }
         Tag[] tagsToCpy = auctionArgs.Tags;
         Tags = new Tag[tagsToCpy.Length];
         Array.Copy(tagsToCpy, Tags, tagsToCpy.Length);
     }
     if (auctionArgs.AuctionImages != null)
     {
         var i = 0;
         foreach (var img in auctionArgs.AuctionImages)
         {
             if (img != null)
             {
                 _auctionImages[i++] = img;
             }
         }
     }
 }
Beispiel #2
0
 internal Auction(AuctionArgs auctionArgs)
 {
     Create(auctionArgs, true);
     AddEvent(new AuctionCreated(AggregateId, auctionArgs));
 }
Beispiel #3
0
 public Builder From(AuctionArgs args)
 {
     this.args = args;
     return(this);
 }