public static AuctionDetailedViewModel CreateFromAuction(Auction auction) { if (auction == null) { return null; } AuctionDetailedViewModel result = new AuctionDetailedViewModel { CurrentPrice = auction.CurrentPrice, DateStarted = auction.DateStarted, Id = auction.Id, Product = ProductViewModel.CreateFromProduct(auction.Product), Type = auction.Type, Duration = auction.Duration, CurrentBuyer = auction.CurrentBuyer }; return result; }
public static AuctionDetailedViewModel CreateFromAuction(Auction auction) { if (auction == null) { return(null); } AuctionDetailedViewModel result = new AuctionDetailedViewModel { CurrentPrice = auction.CurrentPrice, DateStarted = auction.DateStarted, Id = auction.Id, Product = ProductViewModel.CreateFromProduct(auction.Product), Type = auction.Type, Duration = auction.Duration, CurrentBuyer = auction.CurrentBuyer }; return(result); }
public ProductDetailedViewModel(ProductViewModel product, AuctionDetailedViewModel auction) : this(product) { this.Auction = auction; }
public ActionResult Current(Guid? productId) { if (productId == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } Auction currentAuction = this.db.Auctions.All().Include("Product").FirstOrDefault(auction => auction.Product.Id == productId); if (currentAuction == null) { return Content("There isn't auction for this product any more. Please stay tuned up, for new auctions :)"); } if (DateTime.Compare(currentAuction.DateStarted.AddMinutes(currentAuction.Duration), DateTime.Now) < 0) { this.db.Auctions.Delete(currentAuction); this.db.SaveChanges(); return Content("There isn't auction for this product any more. Please stay tuned up, for new auctions :)"); } else { AuctionDetailedViewModel model = new AuctionDetailedViewModel { Id = currentAuction.Id, CurrentPrice = currentAuction.CurrentPrice, DateStarted = currentAuction.DateStarted, Product = ProductViewModel.CreateFromProduct(currentAuction.Product), Type = currentAuction.Type, Duration = currentAuction.Duration, CurrentBuyer = currentAuction.CurrentBuyer }; return View(model); } }