public ActionResult ViewMyAuctions() { AuctionatorContext _context = new AuctionatorContext(); List <Auction> auctions = new List <Auction>(); User user = Session["user"] as User; if (user != null) { _context.Auctions.ToList().ForEach((a) => { if (a.Seller == user.Id) { auctions.Add(a); } }); ViewAuctionsViewModel viewAuctionsViewModel = new ViewAuctionsViewModel { auctions = auctions }; return(View(viewAuctionsViewModel)); } else { return(Redirect("/login/login")); } }
public ActionResult ViewAllAuctions() { List <Auction> auctions = new List <Auction>(); AuctionatorContext _context = new AuctionatorContext(); _context.Auctions.ToList().ForEach((a) => { auctions.Add(a); }); ViewAuctionsViewModel viewAuctionsViewModel = new ViewAuctionsViewModel { auctions = auctions }; return(View(viewAuctionsViewModel)); }