public IViewComponentResult Invoke() { var lotteries = _lotteryService.Query() .Include(x => x.LotteryHistories) .Where(x => !x.IsDeleted && (x.LotteryHistories.Count() < x.Volume && x.Status == (int)EnumLotteryGameStatus.ACTIVE)) .OrderByDescending(x => x.CreatedDate); var viewModel = new LotteryIndexViewModel(); viewModel.Lotteries = lotteries .Select(x => Mapper.Map <LotteryIndexLotteryViewModel>(x)) .ToList(); viewModel.Slides = lotteries .Select(x => Mapper.Map <LotteryIndexSlideViewModel>(x)) .ToList(); return(View(viewModel)); }
public IActionResult Index() { var lotteries = _lotteryService.Query() .Include(x => x.LotteryCategory) .Include(x => x.LotteryDetails) .Include(x => x.LotteryHistories) .Where(x => !x.IsDeleted && (x.LotteryHistories.Count() < x.Volume && (x.Status == (int)EnumLotteryGameStatus.ACTIVE || x.Status == (int)EnumLotteryGameStatus.DEACTIVATED))) .OrderByDescending(x => x.CreatedDate); var viewModel = new LotteryIndexViewModel(); viewModel.Lotteries = lotteries .Select(x => Mapper.Map <LotteryIndexLotteryViewModel>(x)) .ToList(); var lastNews = _newsService.Queryable().LastOrDefault(); viewModel.News = Mapper.Map <NewsViewModel>(lastNews); return(View(viewModel)); }