Exemplo n.º 1
0
        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"));
            }
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        public ActionResult CreateAuction(CreateAuctionViewModel createAuctionViewModel)
        {
            AuctionatorContext _context = new AuctionatorContext();
            User    user    = Session["user"] as User;
            Auction auction = new Auction();

            auction.Seller     = user.Id;
            auction.Item       = createAuctionViewModel.Item;
            auction.Amount     = createAuctionViewModel.Amount;
            auction.StartPrice = createAuctionViewModel.StartPrice;
            auction.Deadline   = createAuctionViewModel.Deadline;
            Auction newAuc = _context.Auctions.Add(auction);

            user.Auctions.Add(newAuc.Id);
            _context.SaveChanges();
            Session["user"] = user;
            return(Redirect("/auctions/ViewMyAuctions"));
        }
Exemplo n.º 4
0
        public override string ToString()
        {
            AuctionatorContext Context = new AuctionatorContext();
            string             bid     = "Bid: " + BidPrice.ToString() + " , Is Highestbid: ";

            Context.Auctions.ToList().ForEach(a =>
            {
                if (a.Id == Auction)
                {
                    if (a.HighestBid == Id)
                    {
                        bid += "You are highest Bidder!";
                    }
                    else
                    {
                        bid += "You are over bid!";
                    }
                }
            });
            return(bid);
        }
Exemplo n.º 5
0
        public override string ToString()
        {
            AuctionatorContext Context = new AuctionatorContext();
            string             auction = "Item: " + Item + " ,Amount: " + Amount.ToString() + " ,StartPrice: " + StartPrice.ToString();
            bool found = false;
            int  price = 0;

            Context.Bids.ToList().ForEach(b =>
            {
                if (b.Id == HighestBid)
                {
                    found = true;
                    price = b.BidPrice;
                }
            });
            if (found)
            {
                auction += " ,Highest Bid: " + price.ToString() + " by: ";
                Context.Users.ToList().ForEach(u =>
                {
                    if (u.Id == HighestBid)
                    {
                        auction += u.Name;
                    }
                });
            }
            else
            {
                auction += " ,Highest Bid: None";
            }
            Context.Users.ToList().ForEach(u =>
            {
                if (u.Id == Seller)
                {
                    auction += " ,Sold by: " + u.Name;
                }
            });
            return(auction);
        }