public async Task <ActionResult> Index(string lang = "en-Us", string auction = "Auction1", int page = 1) { var auctionModel = config.AuctionHouses.Search(auction); if (auctionModel != null) { Auctions.SetAuction(auctionModel); } else { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var listProducts = await _productService.ShowAwalaibleProductsAsync(); if (listProducts.IsNullOrEmpty()) { return(View("~/Views/Home/EmptyModel.cshtml")); } PageInfo pageInfo = new PageInfo { PageNumber = page, TotalItems = listProducts.Count() }; var listLastBid = await _bidService.ShowLastBidForListProductAsync(listProducts); var listViewProducts = listProducts.Select(pr => new ProductClientViewModel { Id = pr.Id, CategoryID = pr.CategoryID, Description = pr.Description, Duration = pr.Duration.TotalSeconds, Name = pr.Name, Picture = pr.Picture, StartDate = pr.StartDate, StartPrice = pr.StartPrice }); IEnumerable <ProductClientViewModel> productPerPages = listViewProducts.Skip((page - 1) * pageInfo.PageSize).Take(pageInfo.PageSize); var listBidViewModel = listLastBid.Select(b => Mapper.Map <BidViewModel>(b)); var userResult = await _customUserManager.GetAllUsersAsync(); var userVM = userResult.Select(u => Mapper.Map <ProfileViewModel>(u)); ProductsWithBidViewModel categoryWithBids = new ProductsWithBidViewModel() { Products = productPerPages, PageInfo = pageInfo, Bids = listBidViewModel, Users = userVM }; ViewBag.BidStep = BidStep; ViewBag.Auction = auctionModel.Name; return(View("~/Views/Home/Index.cshtml", categoryWithBids)); }
public async Task <ActionResult> Category(Guid?id, string lang = "en-Us", string auction = "Auction1") { var auctionModel = config.AuctionHouses.Search(auction); if (auctionModel != null) { Auctions.SetAuction(auctionModel); } else { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (id == null) { return(null); } var products = await _productService.ShowProductsFromCategoryAsync(id.GetValueOrDefault()); if (products == null || products.IsNullOrEmpty()) { return(View("~/Views/Home/EmptyModel.cshtml")); } var listLastBid = await _bidService.ShowLastBidForListProductAsync(products); var listViewProducts = products.Select(pr => new ProductClientViewModel { Id = pr.Id, CategoryID = pr.CategoryID, Description = pr.Description, Duration = pr.Duration.TotalSeconds, Name = pr.Name, Picture = pr.Picture, StartDate = pr.StartDate }); var listBidViewModel = listLastBid.Select(b => Mapper.Map <BidViewModel>(b)); var userResult = await _customUserManager.GetAllUsersAsync(); var userVM = userResult.Select(u => Mapper.Map <ProfileViewModel>(u)); ProductsWithBidViewModel categoryWithBids = new ProductsWithBidViewModel() { Products = listViewProducts, Bids = listBidViewModel, Users = userVM }; ViewBag.BidStep = BidStep; ViewBag.Auction = auctionModel.Name; return(View("~/Views/Home/Index.cshtml", categoryWithBids)); }