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)); }
private List <LotteryIndexLotteryViewModel> _getLotteriesList() { var lotteries = _lotteryService.Query() .Include(x => x.LotteryHistories) .Include(x => x.LotteryDetails) .Where(x => !x.IsDeleted && (x.LotteryHistories.Count() < x.Volume && (x.Status == (int)EnumLotteryGameStatus.ACTIVE || x.Status == (int)EnumLotteryGameStatus.DEACTIVATED))) .OrderByDescending(x => x.CreatedDate) .Select(x => Mapper.Map <LotteryIndexLotteryViewModel>(x)) .ToList(); return(lotteries); }
public IActionResult Index() { var activeLotteries = _lotteryService.Queryable() .Where(x => !x.IsDeleted && x.Status == (int)EnumLotteryGameStatus.ACTIVE).ToList(); var closestPricePrediction = _pricePredictionService.Query() .Include(x => x.PricePredictionDetails) .Where(x => !x.UpdatedDate.HasValue && x.CloseBettingTime > DateTime.Now && x.Status == (int)EnumPricePredictionGameStatus.ACTIVE) .OrderBy(x => x.CloseBettingTime) .FirstOrDefault(); int randomIndex = RandomPicker.Random.Next(activeLotteries.Count); var randomLottery = _lotteryService.Query().Include(x => x.LotteryDetails) .FirstOrDefault(x => x.Id == activeLotteries[randomIndex].Id && !x.IsDeleted); var viewModel = new HomeViewModel { RandomLotteryId = randomLottery?.Id, RandomLotteryCategoryId = randomLottery != null ? randomLottery.LotteryCategoryId : 0, RandomLotteryTitle = randomLottery?.Title, RandomLotteryDescription = randomLottery?.LotteryDetails.FirstOrDefault(x => x.LangId == HttpContext.Session.GetInt32("LangId").Value).ShortDescription, ClosestPricePredictionId = closestPricePrediction?.Id, ClosestPricePredictionTitle = closestPricePrediction?.PricePredictionDetails .FirstOrDefault(x => x.LangId == HttpContext.Session.GetInt32("LangId").Value).Title, ClosestPricePredictionDescription = closestPricePrediction?.PricePredictionDetails .FirstOrDefault(x => x.LangId == HttpContext.Session.GetInt32("LangId").Value).ShortDescription }; viewModel.Sliders = _sliderService.Queryable() .Include(x => x.Group) .Include(x => x.SliderDetails) .Where(x => x.Group.Name == EnumGroupName.HOMEPAGE.ToString() && x.Group.Filter == EnumGroupFilter.SLIDER.ToString() && x.Status == (int)EnumSliderStatus.ACTIVE) .Select(x => Mapper.Map <SliderViewModel>(x)) .ToList(); viewModel.FAQs = _faqService.Query() .Include(x => x.Group) .Where(x => x.Group.Filter == EnumGroupFilter.FAQ.ToString() && x.LangId == HttpContext.Session.GetInt32("LangId").Value) .Select(x => Mapper.Map <FAQViewModel>(x)) .ToList(); return(View(viewModel)); }
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 GetLotteryDetail(MobileModel mobileModel, int lotteryId) { try { var lottery = _lotteryService .Query() .Include(x => x.LotteryDetails) .Include(x => x.LotteryHistories) //.Include(x => x.LotteryPrizes) .FirstOrDefault(x => x.Id == lotteryId && !x.IsDeleted && (x.Status == (int)EnumLotteryGameStatus.ACTIVE || x.Status == (int)EnumLotteryGameStatus.DEACTIVATED)); if (lottery != null) { return(new JsonResult( new { code = EnumResponseStatus.SUCCESS, data = Mapper.Map <LotteryViewModel>(lottery) } )); } return(new JsonResult( new { code = EnumResponseStatus.WARNING, } )); } catch (Exception ex) { return(new JsonResult( new { code = EnumResponseStatus.ERROR, error_message_key = ex.Message } )); } }