예제 #1
0
        public ActionResult AddAuction(long startingBid, int auctionDuration, ImageOwner poster)
        {
            DateTime todaysDate = DateTime.Now;

            using (ImageHolderContext ihc = new ImageHolderContext())
            {
                if (todaysDate < todaysDate.AddDays(auctionDuration))
                {
                    Auction_ auctionToAdd = new Auction_ {
                        CurrentBid = startingBid, ExpirationDate = DateTime.Now.AddDays(auctionDuration), PosterID = poster.OwnerID, ImageID = poster.ImageID
                    };
                    ihc.Auction_.Add(auctionToAdd);
                }
            }
            return(View());
        }
예제 #2
0
        public ActionResult UpdateBid(ImageOwner image, long bid)
        {
            DateTime todaysDate = DateTime.Now;

            using (ImageHolderContext ihc = new ImageHolderContext())
            {
                Auction_ auction                 = ihc.Auction_.Where(x => x.ImageID == image.ImageID).FirstOrDefault();
                DateTime?expirationDate          = auction.ExpirationDate;
                Models.AccountModels.User bidder = AccountController.GetUserFromID(WebSecurity.CurrentUserId);

                if (todaysDate < expirationDate)
                {
                    if (bidder.Points >= image.Price && bidder.Points >= bid)
                    {
                        auction.CurrentBid = bid;
                        bidder.Points     -= (int)bid;
                    }
                }
            }
            return(RedirectToAction("Index", "Home"));
        }