示例#1
0
        public ActionResult Create(AuctionEditVM auction)
        {
            // start time after end time
            if(auction.StartTime > auction.EndTime)
            {
                ModelState.AddModelError(
                "EndTime",
                "Should be after start time"
                );
            }

            if(ModelState.IsValid) {
            // Create Auction in database
                auction = _auctionApi.SaveAuction(auction);
            }

            return View(auction);
        }
示例#2
0
        public AuctionEditVM SaveAuction(AuctionEditVM auction)
        {
            var dbAuction = new Auction()
            {
                Id           = auction.Id,
                CurrentPrice = auction.CurrentPrice,
                Description  = auction.Description,
                EndTime      = auction.EndTime,
                StartPrice   = auction.StartPrice,
                StartTime    = auction.StartTime,
                Title        = auction.Title
            };

            _db.Auctions.Add(dbAuction);
            _db.SaveChanges();

            return auction;
        }