コード例 #1
0
        public async Task <IActionResult> Personal(int page = 1)
        {
            User user = await userManager.FindByNameAsync(User.Identity.Name);

            List <AuctionLot> userLots = new List <AuctionLot>();
            int count = 0;

            if (await userManager.IsInRoleAsync(user, "regular user"))
            {
                userLots = await lotLogic.GetPage(page, new AuctionLot
                {
                    User = user
                });

                count = await lotLogic.GetCount(new AuctionLot
                {
                    User = user
                });
            }

            PersonalAccountViewModel model = new PersonalAccountViewModel
            {
                UserName         = user.UserName,
                Email            = user.Email,
                TelegramId       = user.TelegramUsername,
                PersonalLotsList = new AuctionLotsViewModel
                {
                    AuctionLots   = userLots,
                    PageViewModel = new PageViewModel(count, page, ApplicationConstantsProvider.GetPageSize())
                }
            };

            return(View(model));
        }
コード例 #2
0
 public async Task <List <AuctionLot> > GetPage(int pageNumber, AuctionLot model)
 {
     return(await context.AuctionLots.Include(lot => lot.User).Include(lot =>
                                                                       lot.PriceInfo).Where(lot => model == null ||
                                                                                            !string.IsNullOrWhiteSpace(model.Status) && lot.Status == model.Status ||
                                                                                            model.User != null && lot.User == model.User)
            .OrderByDescending(lot => lot.StartDate)
            .Skip((pageNumber <= 0 ? 0 : pageNumber - 1) *
                  ApplicationConstantsProvider.GetPageSize())
            .Take(ApplicationConstantsProvider.GetPageSize())
            .ToListAsync());
 }
コード例 #3
0
        public async Task <IActionResult> Lots(int page = 1)
        {
            List <AuctionLot> lotsOnModeration = await paginationLotLogic.GetPage(page, new AuctionLot
            {
                Status = LotStatusProvider.GetOnModerationStatus()
            });

            int lotsCount = await paginationLotLogic.GetCount(new AuctionLot
            {
                Status = LotStatusProvider.GetOnModerationStatus()
            });

            return(View(new AuctionLotsViewModel
            {
                AuctionLots = lotsOnModeration,
                PageViewModel = new PageViewModel(lotsCount, page, ApplicationConstantsProvider.GetPageSize())
            }));
        }
コード例 #4
0
        public async Task <IActionResult> Lots(int page = 1)
        {
            List <AuctionLot> lotsToDisplay = await lotLogic.GetPage(page, new AuctionLot
            {
                Status = LotStatusProvider.GetAcceptedStatus()
            });

            int lotsCount = await lotLogic.GetCount(new AuctionLot
            {
                Status = LotStatusProvider.GetAcceptedStatus()
            });

            return(View(new AuctionLotsViewModel()
            {
                PageViewModel = new PageViewModel(lotsCount, page, ApplicationConstantsProvider.GetPageSize()),
                AuctionLots = lotsToDisplay
            }));
        }