Exemplo n.º 1
0
        public ActionResult Index(string code)
        {
            var auctions = this.Session["Auctions"] as List <Auction>;

            if (auctions == null)
            {
                auctions = AuctionService.GetAllAuctions();
                this.Session["Auctions"] = auctions;
            }
            var auction = auctions.FirstOrDefault(a => a.Code == code);

            var items = this.Session[code] as List <Item>;

            if (items == null)
            {
                items = AuctionService.GetAuctionItems(code);
                this.Session[code] = items;
            }

            if (this.Session["RegistredInAuctions"] == null)
            {
                this.Session["RegistredInAuctions"] = new List <string>();
            }
            bool registered = ((List <string>) this.Session["RegistredInAuctions"]).Contains(auction.Code);
            var  model      = new AuctionDetailViewModel
            {
                Auction    = auction,
                Items      = items,
                Registred  = registered,
                ActiveItem = registered ? AuctionService.GetCurrentlyAuctionedItem(auction.Code) : null
            };

            return(this.View(model));
        }