Ejemplo n.º 1
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));
        }
Ejemplo n.º 2
0
 public void DeleteAuction(Auction auction)
 {
     context = new AmigosAuctionContext();
     context.Entry(auction).State = System.Data.Entity.EntityState.Deleted;
     //context.Auctions.Remove(auction);
     context.SaveChanges();
 }
Ejemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "ID,Name,Description")] Category category)
 {
     if (ModelState.IsValid)
     {
         db.Entry(category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(category));
 }
Ejemplo n.º 4
0
 //Delete
 public void DeleteCategory(Category category)
 {
     context = new AmigosAuctionContext();
     context.Entry(category).State = System.Data.Entity.EntityState.Deleted;
     context.SaveChanges();
 }
Ejemplo n.º 5
0
 public void UpdateAuction(Auction auction)
 {
     context = new AmigosAuctionContext();
     context.Entry(auction).State = System.Data.Entity.EntityState.Modified;
     context.SaveChanges();
 }