public void RolloverDailyDeal() { DiscountedListing discountedListing = listingRepository.GetDiscountedListings().Where(d => d.DailyDeal).FirstOrDefault(); if (discountedListing != null) { listingRepository.DeleteDiscountedListing(discountedListing.DiscountedListingID); } List <DiscountedListing> expiredListings = listingRepository.GetDiscountedListings().Where(d => d.IsLive() == false).ToList(); if (expiredListings != null) { foreach (DiscountedListing listing in expiredListings) { listingRepository.DeleteDiscountedListing(listing.DiscountedListingID); } } DiscountedListing newDiscountedListing = new DiscountedListing(); Listing randomListing = listingRepository.GetListings().Where(l => l.Quantity > 0).OrderBy(x => Guid.NewGuid()).FirstOrDefault(); if (randomListing == null) { unitOfWork.Save(); return; } SelectDealPercent(newDiscountedListing); DateTime expiry = DateTime.Now.AddDays(1).AddMinutes(-5); newDiscountedListing.DailyDeal = true; newDiscountedListing.ItemSaleExpiry = expiry; randomListing.AddDiscountedListing(newDiscountedListing); listingRepository.UpdateListing(randomListing); SiteNotification notification = new SiteNotification() { Notification = "Today's daily deal is " + randomListing.ListingName + ", now on sale for " + randomListing.SaleOrDefaultPrice() + " points!", NotificationDate = DateTime.Now }; siteRepository.InsertSiteNotification(notification); unitOfWork.Save(); }
public void DeleteDiscountedListing(int id) { listingRepository.DeleteDiscountedListing(id); unitOfWork.Save(); }