Esempio n. 1
0
        public ActionResult Details(int ID)
        {
            AuctionDetailsViewModel model = new AuctionDetailsViewModel();

            model.Auction = auctionsService.GetAuctionByID(ID);

            if (model.Auction == null)
            {
                return(HttpNotFound());
            }


            model.BidsAmount = model.Auction.ActualAmount + model.Auction.Bids.Sum(x => x.BidAmount);

            var latestBidder = model.Auction.Bids.OrderByDescending(x => x.TimeStamp).FirstOrDefault();

            model.LatestBider = latestBidder != null ? latestBidder.User : null;

            model.PageTitle       = "Auctions Details: " + model.Auction.Title;
            model.PageDescription = model.Auction.Summary;


            model.EntityID = (int)EntityEnums.Auction;
            model.RecordID = model.Auction.ID;
            model.Comments = sharedService.GetComments(model.EntityID, model.RecordID);

            return(View(model));
        }
Esempio n. 2
0
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            AuctionsService         auctionService = new AuctionsService();
            SharedService           sharedService  = new SharedService();
            AuctionDetailsViewModel model          = new AuctionDetailsViewModel();

            model.Auction    = auctionService.GetAuctionByID(id);
            model.BidsAmount = model.Auction.InitialPrice + model.Auction.Bids.Sum(x => x.BiddingRate);
            var latestbidder = model.Auction.Bids.OrderByDescending(x => x.TimeStamp).FirstOrDefault();

            model.LatestBidder = latestbidder != null ? latestbidder.User : null;
            model.EntityID     = (int)EntityEnums.Auction;
            model.Comments     = sharedService.GetComments((int)EntityEnums.Auction, model.Auction.ID);
            if (model == null)
            {
                return(RedirectToAction("Error", "Home"));
            }
            try
            {
                Auction auction = new Auction();
                auction = model.Auction;
                auction.InitialPrice    = model.Auction.InitialPrice + model.Auction.Bids.Sum(x => x.BiddingRate);
                db.Entry(auction).State = EntityState.Modified;
                db.SaveChanges();
            }
            catch {
            }
            return(View(model));
        }
        public ActionResult Details(int ID)
        {
            AuctionDetailViewModel model           = new AuctionDetailViewModel();
            AuctionsService        auctionsService = new AuctionsService();

            model.EntityID = (int)EntityEnums.Auction;

            model.Auction         = auctionsService.GetAuctionByID(ID);
            model.PageTitle       = "Auction Details:";
            model.PageDescription = model.Auction.Description.Substring(0, 10);
            model.BidsAmount      = model.Auction.ActualAmount + model.Auction.Bids.Sum(x => x.BidAmount);

            var latestBidder = model.Auction.Bids.OrderByDescending(x => x.Timestamp).FirstOrDefault();

            model.LatestBidder = latestBidder != null ? latestBidder.User : null;
            model.Comments     = SharedService.GetComments((int)EntityEnums.Auction, model.Auction.ID);

            return(View(model));
        }