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 Create([Bind(Include = "ID,Name,Description")] Category category) { if (ModelState.IsValid) { db.Categories.Add(category); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
public bool AddBid(Bid bid) { AmigosAuctionContext context = new AmigosAuctionContext(); context.Bids.Add(bid); return(context.SaveChanges() > 0); }
public void DeleteAuction(Auction auction) { context = new AmigosAuctionContext(); context.Entry(auction).State = System.Data.Entity.EntityState.Deleted; //context.Auctions.Remove(auction); context.SaveChanges(); }
public bool LeaveComment(Comment comment) { context = new AmigosAuctionContext(); //Need to add EnityFramework from NuggetPackageManager context.Comments.Add(comment); return(context.SaveChanges() > 0); }
public int SavePicture(Picture picture) { context = new AmigosAuctionContext(); //Need to add EnityFramework from NuggetPackageManager context.Pictures.Add(picture); context.SaveChanges(); return(picture.ID); }
public ActionResult DeleteConfirmed(int id) { Comment comment = db.Comments.Find(id); db.Comments.Remove(comment); db.SaveChanges(); return(RedirectToAction("Index")); }
//save public void SaveCategory(Category category) { try { context = new AmigosAuctionContext(); //Need to add EnityFramework from NuggetPackageManager context.Categories.Add(category); context.SaveChanges(); } catch (Exception e) { Console.Write(e.Message); } }
public void SaveAuction(Auction auction) { try { context = new AmigosAuctionContext(); //Need to add EnityFramework from NuggetPackageManager context.Auctions.Add(auction); context.SaveChanges(); } catch (Exception e) { Console.Write(e.Message); } }
//Delete public void DeleteCategory(Category category) { context = new AmigosAuctionContext(); context.Entry(category).State = System.Data.Entity.EntityState.Deleted; context.SaveChanges(); }
public void UpdateAuction(Auction auction) { context = new AmigosAuctionContext(); context.Entry(auction).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); }