Beispiel #1
0
        public async Task <ActionResult> MyBidHistory(AuctionsIndexViewModel model)
        {
            IQueryable <Auction> modelAuctions;

            ViewBag.Title      = "My Bids";
            model.LoggedInUser = await auctionService.GetCurrentUser();

            modelAuctions = auctionService.GetAuctionsAsQueryable().Where(a => a.AuctionBids.Any(b => b.UserID == model.LoggedInUser.Id));
            List <String> destNames = new List <String>()
            {
                allbidsDestName
            };

            model.FullNavList = CreateAuctionNavList(destNames);

            model.ActionName = "MyBidHistory";

            PopulateAuctionModel(model, modelAuctions);

            model.Auctions = model.Auctions.OrderByDescending(a => a.EndTime).ToList();

            ModelState.Clear();

            return(View("Index", model));
        }
Beispiel #2
0
 private void FilterAuctions(AuctionsIndexViewModel model, string titleFilter, string descriptionFilter)
 {
     if (!String.IsNullOrEmpty(titleFilter) || !String.IsNullOrEmpty(descriptionFilter))
     {
         titleFilter       = titleFilter ?? "";
         descriptionFilter = descriptionFilter ?? "";
         model.Auctions    = model.Auctions.Where(a => a.Title.ToLower().Contains(titleFilter.ToLower()) && a.Description.ToLower().Contains(descriptionFilter.ToLower())).ToList();
     }
 }
Beispiel #3
0
        public async Task <IActionResult> Index(string sortOrder, string titleFilter, string descriptionFilter, bool?animateOkSymbol)
        {
            var model = new AuctionsIndexViewModel(sortOrder, titleFilter, descriptionFilter, animateOkSymbol);
            var auctionViewModelList = Mapper.Map <IList <Auction>, IList <AuctionViewModel> >(await _auctions.GetAllAuctions(groupCode, User));

            model.Auctions    = auctionViewModelList as List <AuctionViewModel>;
            model.CurrentUser = await _userManager.GetUserAsync(User);

            FilterAuctions(model, titleFilter, descriptionFilter);
            SortAuctions(model, sortOrder);
            return(View(model));
        }
Beispiel #4
0
        public async Task <ActionResult> Index()
        {
            AuctionsIndexViewModel model = new AuctionsIndexViewModel();
            IQueryable <Auction>   modelAuctions;

            ViewBag.Title = "Open Auctions";
            modelAuctions = auctionService.GetAuctionsAsQueryable().Where(a => a.EndTime >= DateTime.Now); //a.IsOpen());
            List <String> destNames = new List <String>()
            {
                openDestName
            };

            model.FullNavList  = CreateAuctionNavList(destNames);
            model.LoggedInUser = await auctionService.GetCurrentUser();

            model.ActionName = "Index";

            PopulateAuctionModel(model, modelAuctions);

            return(View(model));
        }
Beispiel #5
0
        private void SortAuctions(AuctionsIndexViewModel model, string sortOrder)
        {
            switch (sortOrder)
            {
            case "endDate_desc":
                model.Auctions = model.Auctions.OrderByDescending(a => a.EndDate).ToList();
                break;

            case "reservationPrice":
                model.Auctions = model.Auctions.OrderBy(a => a.ReservationPrice).ToList();
                break;

            case "reservationPrice_desc":
                model.Auctions = model.Auctions.OrderByDescending(a => a.ReservationPrice).ToList();
                break;

            default:
                model.Auctions = model.Auctions.OrderBy(a => a.EndDate).ToList();
                break;
            }
        }
Beispiel #6
0
        public async Task <ActionResult> MyWinningBids()
        {
            IQueryable <Auction>   modelAuctions;
            AuctionsIndexViewModel model = new AuctionsIndexViewModel();

            ViewBag.Title      = "Winning Bids";
            model.LoggedInUser = await auctionService.GetCurrentUser();

            modelAuctions = auctionService.GetAuctionsAsQueryable().Where(a => a.EndTime >= DateTime.Now && a.IsSilent == false && a.AuctionBids.Count > 0 && a.AuctionBids.OrderByDescending(c => c.BidAmount).ThenBy(d => d.BidDate).FirstOrDefault().UserID == model.LoggedInUser.Id);
            List <String> destNames = new List <String>()
            {
                mywinningDestName
            };

            model.FullNavList = CreateAuctionNavList(destNames);

            model.ActionName = "MyWinningBids";

            PopulateAuctionModel(model, modelAuctions);

            return(View("Index", model));
        }
Beispiel #7
0
        public async Task <ActionResult> MyCurrentBids()
        {
            IQueryable <Auction>   modelAuctions;
            AuctionsIndexViewModel model = new AuctionsIndexViewModel();

            model.ActionName = "MyCurrentBids";

            ViewBag.Title      = "My Bids";
            model.LoggedInUser = await auctionService.GetCurrentUser();

            modelAuctions = auctionService.GetAuctionsAsQueryable().Where(a => a.EndTime >= DateTime.Now && a.AuctionBids.Any(b => b.UserID == model.LoggedInUser.Id)); //ContainsBidBy(model.LoggedInUser) && a.IsOpen());
            List <String> destNames = new List <String>()
            {
                livebidsDestName
            };

            model.FullNavList = CreateAuctionNavList(destNames);

            PopulateAuctionModel(model, modelAuctions);

            return(View("Index", model));
        }
Beispiel #8
0
        public async Task <ActionResult> MyAuctions()
        {
            IQueryable <Auction>   modelAuctions;
            AuctionsIndexViewModel model = new AuctionsIndexViewModel();

            ViewBag.Title      = "My Auctions";
            model.LoggedInUser = await auctionService.GetCurrentUser();

            modelAuctions = model.LoggedInUser.Auctions.AsQueryable();
            List <String> destNames = new List <String>()
            {
                myaucsDestName
            };

            model.FullNavList = CreateAuctionNavList(destNames);

            model.ActionName = "MyAuctions";

            PopulateAuctionModel(model, modelAuctions);

            return(View("Index", model));
        }
Beispiel #9
0
        public async Task <ActionResult> Closed()
        {
            AuctionsIndexViewModel model = new AuctionsIndexViewModel();
            IQueryable <Auction>   modelAuctions;

            ViewBag.Title = "Closed Auctions";
            modelAuctions = auctionService.GetAuctionsAsQueryable().Where(a => a.EndTime < DateTime.Now);
            List <String> destNames = new List <String>()
            {
                closedDestName
            };

            model.FullNavList  = CreateAuctionNavList(destNames);
            model.LoggedInUser = await auctionService.GetCurrentUser();

            model.ActionName = "Closed";

            PopulateAuctionModel(model, modelAuctions);

            model.Auctions = model.Auctions.OrderByDescending(a => a.EndTime).ToList();

            return(View("Index", model));
        }
Beispiel #10
0
        public void PopulateAuctionModel(AuctionsIndexViewModel model, IQueryable <Auction> auctions)
        {
            if (model.FilterAll == true)
            {
                model.PreviousFilterPublic   = false;
                model.PreviouslyFilterSilent = false;
            }

            if (model.FilterPublic == true)
            {
                model.PreviouslyFilterSilent = false;
                model.PreviousFilterPublic   = !model.PreviousFilterPublic;
            }

            if (model.FilterSilent == true)
            {
                model.PreviousFilterPublic   = false;
                model.PreviouslyFilterSilent = !model.PreviouslyFilterSilent;
            }

            if (model.PreviousFilterPublic == true)
            {
                auctions = auctions.Where(a => a.IsSilent == false);
            }

            if (model.PreviouslyFilterSilent == true)
            {
                auctions = auctions.Where(a => a.IsSilent == true);
            }

            if (String.IsNullOrEmpty(model.SearchText) == false)
            {
                auctions = auctions.Where(a => (a.Listing != null && a.Listing.ListingName.ToLower().Contains(model.SearchText.Trim().ToLower()) || a.AlternativePrize.ToLower().Contains(model.SearchText.Trim().ToLower())));   //GetPrize().ToLower().Contains(model.SearchText.Trim().ToLower()));
            }

            model.TotalItems = auctions.Count();

            if (model.LoggedInUser.PaginationPreference != 0)
            {
                if (model.SelectedPage != 0)
                {
                    model.CurrentPage = model.SelectedPage;
                }
                if (model.CurrentPage < 1)
                {
                    model.CurrentPage = 1;
                }
                model.UserPaginationPreference = model.LoggedInUser.PaginationPreference;
                if (model.ActionName.CompareTo("Closed") == 0)
                {
                    auctions = auctions.OrderByDescending(a => a.EndTime).Skip((model.CurrentPage - 1) * model.UserPaginationPreference).Take(model.UserPaginationPreference);
                    //var query = new { AuctionCount = auctions.Select(x => x).Count(), Auctions = auctions.OrderByDescending(a => a.EndTime).Skip((model.CurrentPage - 1) * model.UserPaginationPreference).Take(model.UserPaginationPreference) };
                    //model.TotalItems = query.AuctionCount;
                    //auctions = query.Auctions;
                }
                else
                {
                    auctions = auctions.OrderBy(a => a.EndTime).Skip((model.CurrentPage - 1) * model.UserPaginationPreference).Take(model.UserPaginationPreference);
                    //var query = new { AuctionCount = auctions.Select(x => x).Count(), Auctions = auctions.OrderBy(a => a.EndTime).Skip((model.CurrentPage - 1) * model.UserPaginationPreference).Take(model.UserPaginationPreference) };
                    //model.TotalItems = query.AuctionCount;
                    //auctions = query.Auctions;
                }
            }
            else
            {
                model.CurrentPage = 1;
                auctions          = auctions.OrderBy(a => a.EndTime);
            }

            model.Auctions = auctions.ToList <Auction>();
        }