コード例 #1
0
 /// <summary>
 /// Check all lots for sale at the end of the trading period and sends a letter to the seller and the customer
 /// </summary>
 public void CheckAllLotEntities()
 {
     lock (padlock)
     {
         IEnumerable <LotEntity> lots = GetAllForSaleLotEntities().Where(lot => DateTime.Now >= (lot.StartDate + new TimeSpan(lot.Duration, 0, 0, 0)));
         if (lots != null)
         {
             bool isEntryChanges = false;
             foreach (var lot in lots)
             {
                 if (lot.LastPrice != null)
                 {
                     lot.State = LotStateEntity.Sold;
                     string     sellerMailSubject = "Your lot is sold";
                     string     sellerMailBody    = string.Format("Your lot {0} is sold for the {1} byn. Please come to the auction office for the completion of the sale transaction.", lot.Name, lot.LastPrice);
                     UserEntity seller            = lot.User;
                     seller.SendMessage(sellerMailSubject, sellerMailBody);
                     string         customerMailSubject = "You won the auction";
                     string         customerMailBody    = string.Format("You won lot {0} for the {1} byn. Please come to the auction office for the completion of the sale transaction.", lot.Name, lot.LastPrice);
                     UserEntity     customer            = GetMaxBidOwner(lot);
                     PurchaseEntity purchase            = new PurchaseEntity {
                         Lot = lot, LotId = lot.Id, User = customer, UserId = customer.Id, Date = DateTime.Now
                     };
                     purchaseRepository.Create(purchase.ToDalPurchase());
                     customer.SendMessage(customerMailSubject, customerMailBody);
                 }
                 else
                 {
                     lot.State = LotStateEntity.Unsold;
                     string     sellerMailSubject = "Your lot not sold";
                     string     sellerMailBody    = string.Format("Your lot {0} with the start price {1} byn not sold.", lot.Name, lot.StartPrice);
                     UserEntity seller            = lot.User;
                     seller.SendMessage(sellerMailSubject, sellerMailBody);
                 }
                 lotRepository.Update(lot.ToDalLot());
                 isEntryChanges = true;
             }
             if (isEntryChanges)
             {
                 uow.Commit();
             }
         }
     }
 }
コード例 #2
0
 public void UpdatePurchase(PurchaseEntity purchase)
 {
     purchaseRepository.Update(purchase.ToDalPurchase());
     uow.Commit();
 }