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));
        }
        // GET: Auctions
        public ActionResult Index()
        {
            var auctions = AuctionService.GetAllAuctions();

            this.Session["Auctions"]  = auctions;
            this.ViewData["Auctions"] = auctions;
            return(View());
        }
Beispiel #3
0
        public void GetAllAuctions()        //Service method is not done
        {
            //Arrange
            List <AuctionModel> auctions;

            //Act
            auctions = auctionService.GetAllAuctions();
            //Assert
            Assert.IsNotNull(auctions.Count);
        }
Beispiel #4
0
        public void GivenEmptyAuctionRepository_WhenGetAllAuctionsIsCalled_EmptyListIsReturned()
        {
            // Arrange
            var auctionService = new AuctionService(new AuctionRepositoryFake(), new UserRepositoryFake(), new AuditRepositoryFake());

            // Act
            var allAuctions = auctionService.GetAllAuctions();

            // Assert
            Assert.IsEmpty(allAuctions);
        }
        // GET: Auctions
        public ActionResult Index()
        {
            AuctionService service = new AuctionService();

            var auctions = service.GetAllAuctions();

            if (Request.IsAjaxRequest())
            {
                return(PartialView(auctions));
            }
            else
            {
                return(View(auctions));
            }
        }
Beispiel #6
0
        public void GivenRepositoriesWithOneAuctionAndOneUser_WhenGetAllAuctionsIsCalled_ListContainingThatAuctionIsReturned()
        {
            // Arrange
            const string username = "******";
            var          userFake = new UserRepositoryFake();

            userFake.CreateUser(username, "123456");
            var auctionService = new AuctionService(new AuctionRepositoryFake(), userFake, new AuditRepositoryFake());

            // Act
            auctionService.CreateAuction(username, new AuctionItemViewModel {
                Description = "description", MinAmount = "0", Name = "Item"
            });

            // Assert
            var allAuctions       = auctionService.GetAllAuctions();
            var auctionViewModels = allAuctions.ToList();
            var firstAuction      = auctionViewModels.FirstOrDefault();

            Assert.IsNotEmpty(auctionViewModels);
            Assert.AreEqual(username, firstAuction.Seller);
        }