Esempio n. 1
0
        public IActionResult GetConfirmPurchaseTicket(int amount, int lotteryId)
        {
            var viewModel = new LotteryTicketPurchaseViewModel();

            viewModel.TicketPrice         = _lotteryService.Queryable().FirstOrDefault(x => !x.IsDeleted && x.Id == lotteryId).UnitPrice;
            viewModel.TotalTickets        = amount;
            viewModel.TotalPriceOfTickets = viewModel.TotalTickets * viewModel.TicketPrice;

            return(new JsonResult(viewModel));
        }
Esempio n. 2
0
        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));
        }