Пример #1
0
        public async Task <ContractViewModel> Create(ListingParams apiParam)
        {
            string checkedOrder = apiParam.OrderBy;
            bool   checkedAsc   = apiParam.Asc;
            int    checkedPage  = apiParam.Page;

            //Default order
            if (string.IsNullOrEmpty(apiParam.OrderBy))
            {
                checkedOrder = nameof(Contract.CreateTime);
                checkedAsc   = false;
            }
            if (checkedPage < 1)
            {
                checkedPage = 1;
            }

            var model = new ContractViewModel
            {
                OnPage       = checkedPage,
                FilterBy     = apiParam.Type,
                FilterString = apiParam.Contain,
                OrderBy      = checkedOrder,
                OrderAsc     = checkedAsc
            };

            var query = GetFilteredContracts(apiParam, model.ItemPerPage, out var totalRows);

            model.TotalRows = totalRows;
            model.Items     = await query.ToListAsync();

            return(model);
        }
Пример #2
0
        public override IQueryable <IModel> GetListingItems(ListingParams <WinnerPointsModel> listingDataModel)
        {
            var winnerTeam = new WinnerResultRepository(this.Context).GetWinnerTeam();

            return
                (
                from globalBet in this.Context.GlobalBets
                join
                team in this.Context.Teams on globalBet.WinnerTeamID equals team.TeamID
                join
                user in this.Context.Users on globalBet.UserID equals user.UserID
                orderby(winnerTeam.ID == globalBet.WinnerTeamID) descending, user.PointsWonBonus descending, team.Points ascending
                select  new WinnerPointsModel
            {
                ID = team.TeamID,
                TeamName = team.Name,
                TeamFlagPrefix = team.FlagPrefix,
                TeamExternalID = team.ExternalID,
                TeamPoints = (int)team.Points,
                BetWon = (winnerTeam.ID == globalBet.WinnerTeamID),
                UserDisplayName = user.DisplayName,
                Username = user.Username
            }
                );
        }
Пример #3
0
        public IQueryable <TeamModel> GetWinnersForListing(ListingParams <TeamModel> listingDataModel)
        {
            var models =
                (
                    from team in this.GetAll()
                    join
                    allBet in Context.GlobalBets on UserID equals allBet.UserID into allBets
                    from globalBet in allBets.DefaultIfEmpty()
                    orderby team.Points, team.Name
                    select  new TeamModel
            {
                ID = team.TeamID,
                Name = team.Name,
                Flag = team.FlagPrefix,
                Points = (int)team.Points,
                ExternalID = team.ExternalID,
                BetMade = (globalBet != null && globalBet.WinnerTeamID != null && team.TeamID == globalBet.WinnerTeamID)
            }
                );

            if (listingDataModel != null && !string.IsNullOrEmpty(listingDataModel.Keyword))
            {
                models = models.Where(e => e.Name.Contains(listingDataModel.Keyword));
            }

            return(models);
        }
Пример #4
0
        public override IQueryable <IModel> GetListingItems(ListingParams <GoalscorerPointsModel> listingDataModel)
        {
            var goalscorerEntities = new GoalscorerResultRepository(this.Context).GetTopGoalscorerEntities();

            return
                (
                from globalBet in this.Context.GlobalBets
                join
                player in this.Context.Players on globalBet.GoalscorerID equals player.PlayerID
                join
                team in this.Context.Teams on player.TeamID equals team.TeamID
                join
                user in this.Context.Users on globalBet.UserID equals user.UserID
                join
                allTopGoalscorer in goalscorerEntities on player.PlayerID equals allTopGoalscorer.ID into allTopGoalscorers
                from topGoalscorer in allTopGoalscorers.DefaultIfEmpty()
                orderby(topGoalscorer != null) descending, user.PointsWonBonus descending, player.Points ascending
                select  new GoalscorerPointsModel
            {
                ID = player.PlayerID,
                PlayerName = player.Name,
                PlayerTeamFlagPrefix = team.FlagPrefix,
                PlayerExternalID = player.ExternalID,
                PlayerPoints = (int)player.Points,
                PlayerGoalsScored = player.GoalsScored,
                BetWon = (topGoalscorer != null),
                UserDisplayName = user.DisplayName,
                Username = user.Username
            }
                );
        }
Пример #5
0
        private void SendRoundNotificationToEmails(int roundID, List <UserModel> users, UserRepository userRepo)
        {
            var mailMessage      = new MailMessage();
            var listingDataModel = new ListingParams <MatchForRoundModel> {
                Model = new MatchForRoundModel {
                    RoundID = roundID, ForNotification = true
                }
            };

            var matchForRoundRepo = new MatchesForRoundRepository(userRepo.Context);

            ViewData.Model = matchRepo.GetMatchesForRound(listingDataModel).ToList();

            //send notification to all users
            foreach (var user in users)
            {
                if (!string.IsNullOrEmpty(user.Email))
                {
                    matchForRoundRepo.UserID = user.ID;

                    ViewBag.BonusPointsLeft = matchForRoundRepo.GetUserBonus();

                    PopulateBody(mailMessage, viewName: "RoundNotification");

                    Email.Send(new Email
                    {
                        Body    = mailMessage.Body,
                        Subject = "Notification for current round",
                        To      = user.Email
                    });
                }
            }
        }
Пример #6
0
        public override IQueryable <IModel> GetListingItems(ListingParams <GoalscorerModel> listingDataModel)
        {
            var models =
                (
                    from player in this.GetAll()
                    from setting in this.Context.Settings
                    join
                    match in this.Context.Matches on setting.CurrentRoundID equals match.RoundID
                    join
                    team in this.Context.Teams on player.TeamID equals team.TeamID
                    where   player.Active && (player.TeamID == match.FirstTeamID || player.TeamID == match.SecondTeamID)
                    orderby player.GoalsScored descending, player.Points ascending, player.Name
                    select new GoalscorerModel
            {
                ID = player.PlayerID,
                Name = player.Name,
                TeamFlag = team.FlagPrefix,
                GoalsScored = player.GoalsScored,
                Points = Convert.ToInt32(player.Points * setting.RoundGoalMultiplier),
                ExternalID = player.ExternalID
            }
                );


            if (!String.IsNullOrEmpty(listingDataModel.Keyword))
            {
                models = models.Where(e => e.Name.Contains(listingDataModel.Keyword));
            }

            return(models);
        }
Пример #7
0
        public override IQueryable <IModel> GetListingItems(ListingParams <MatchBetModel> listingDataModel)
        {
            var models =
                (
                    from matchBet in this.GetAll()
                    join
                    match in this.Context.Matches on matchBet.MatchID equals match.MatchID
                    join
                    user in new UserRepository(this.Context, this.UserID).GetActiveUsers() on matchBet.UserID equals user.UserID
                    where   matchBet.MatchID == listingDataModel.Model.MatchID             //bets for this match
                    &&
                    matchBet.UserID != this.UserID                                         //do not return bet made by current user
                    &&
                    DateTime.UtcNow >= match.Date.AddHours(-1 * DataConfig.HoursBeforeBet) //only expired matches
                    orderby matchBet.WinTypeID descending, matchBet.PointsWonBonus descending, matchBet.PointsWon descending, user.PointsWonBonus descending, user.DisplayName ascending
                    select  new MatchBetModel
            {
                ID = matchBet.BetID,
                UserDisplayName = user.DisplayName,
                Username = user.Username,
                FirstTeamGoals = matchBet.FirstTeamGoals,
                SecondTeamGoals = matchBet.SecondTeamGoals,
                Result = matchBet.Result,
                PointsWon = matchBet.PointsWon,
                PointsWonBonus = matchBet.PointsWonBonus,
                Bonus = matchBet.Bonus,
                WinTypeID = matchBet.WinTypeID ?? 0
            }
                );

            return(models);
        }
Пример #8
0
        public async Task<EventViewModel> Create(ListingParams apiParam)
        {
            string checkedOrder = apiParam.OrderBy;
            bool checkedAsc = apiParam.Asc;
            int checkedPage = apiParam.Page;
            //Default order
            if (string.IsNullOrEmpty(apiParam.OrderBy))
            {
                checkedOrder = nameof(Contract.CreateTime);
                checkedAsc = false;
            }
            if (checkedPage < 1) checkedPage = 1;

            var model = new EventViewModel
            {
                OnPage = checkedPage,
                OrderBy = checkedOrder,
                OrderAsc = checkedAsc
            };

            var query = GetEventsByContractId(apiParam, model.ItemPerPage, out var totalRows);
            model.TotalRows = totalRows;
            model.Items = await query.ToListAsync();
            return model;

        }
Пример #9
0
        public IQueryable <GoalscorerModel> GetGoalscorersForListing(ListingParams <GoalscorerModel> listingDataModel)
        {
            var models =
                (
                    from player in this.GetAll()
                    join
                    team in this.Context.Teams on player.TeamID equals team.TeamID
                    join
                    allBet in this.Context.GlobalBets on this.UserID equals allBet.UserID into allBets
                    from bet in allBets.DefaultIfEmpty()
                    orderby player.GoalsScored descending, player.Points ascending, player.Name
                    select  new GoalscorerModel
            {
                ID = player.PlayerID,
                Name = player.Name,
                TeamFlag = team.FlagPrefix,
                GoalsScored = player.GoalsScored,
                ExternalID = player.ExternalID,
                Points = player.Points,
                BetMade = (bet != null && bet.GoalscorerID != null && player.PlayerID == bet.GoalscorerID)
            }
                );

            if (listingDataModel != null && !string.IsNullOrEmpty(listingDataModel.Keyword))
            {
                models = models.Where(e => e.Name.Contains(listingDataModel.Keyword));
            }

            return(models);
        }
Пример #10
0
        public PagedList <IModel> GetLookupData(ListingParams <M> listingDataModel, bool forIndex = false)
        {
            this.SetData(listingDataModel, forIndex);
            ViewBag.Type = this.Name;

            return(new PagedList <IModel>(repo.GetLookupItems(listingDataModel), listingDataModel.PageIndex ?? -1, listingDataModel.ItemsPerPage));
        }
Пример #11
0
 private IQueryable<EventLog> GetEventsByContractId(ListingParams apiParam, int take, out int totalRows)
 {
     int excludedRows = (apiParam.Page - 1) * take;
     var query = _context.EventLog.Where(e => e.ContractId == apiParam.Id);
     totalRows = query.Count();
     var ordered = OrderTranslater(query, apiParam.OrderBy, apiParam.Asc);
     return ordered.Skip(excludedRows).Take(take);
 }
Пример #12
0
        public override IQueryable <IModel> GetListingItems(ListingParams <GoalscorerModel> listingDataModel)
        {
            var models = (IQueryable <GoalscorerModel>) new GoalscorerRepository(this.Context, this.UserID).GetGoalscorersForListing(listingDataModel);

            return
                (
                from goalscorer in models
                orderby goalscorer.GoalsScored descending, goalscorer.Points ascending, goalscorer.Name ascending
                select goalscorer
                );
        }
Пример #13
0
 public override IQueryable <IModel> GetListingItems(ListingParams <TeamModel> listingDataModel)
 {
     if (listingDataModel.Model.BetExpired)
     {
         return(this.GetSelectedWinner(listingDataModel));
     }
     else
     {
         return(this.GetWinnersForListing(listingDataModel));
     }
 }
Пример #14
0
        /// <summary>
        /// Sets general data for listing pages
        /// </summary>
        /// <param name="pageType"></param>
        /// <param name="isLookup"></param>
        /// <param name="listingDataModel"></param>
        private void SetListingParameters(string pageType, bool?isLookup, ListingParams <M> listingDataModel)
        {
            this.IsLookup = isLookup ?? false;
            this.PageType = pageType;
            this.SetControllerData();

            if (listingDataModel.Model != null)
            {
                listingDataModel.Model.SetMetaData();
            }
        }
Пример #15
0
        public virtual ActionResult Index(int?id, string pageType, bool?isLookup, M model = null, ListingParams <M> listingParams = null)
        {
            this.PageType = pageType;
            this.IsLookup = isLookup ?? false;

            //if subpage, reset id
            if (pageType != null)
            {
                id = null;
            }

            var listingDataModel = new ListingParams <M>
            {
                PageIndex    = id,
                ItemsPerPage = 0,
                Model        = (M)model,
                Origin       = (listingParams == null) ? null : listingParams.Origin
            };

            //set params
            this.ListingViewModel.PageIndex    = id;
            this.ListingViewModel.ItemsPerPage = 0;

            this.SetDefaultListingData(model);
            this.CopyViewModelToDataModel(listingDataModel);
            this.ListingViewModel.Items   = this.IsLookup ? this.GetLookupData(listingDataModel, true) : this.GetData(listingDataModel, true);
            this.ListingViewModel.Keyword = listingDataModel.Keyword;
            this.CopyDataModelToViewModel(listingDataModel);

            model.SetMetaData();
            if (this.IsLookup)
            {
                this.SetLookupIndexData((M)model);
            }
            else
            {
                this.SetIndexData((M)model);
            }
            model.SetMetaData();

            //make sure these are at the end
            this.SetListingData((M)model);
            this.SetControllerData();

            //if there is at least one advanced filter, show container by default
            if (this.ListingViewModel.AdvancedFilterValues != null && this.ListingViewModel.AdvancedFilterValues.Keys.Count > 0)
            {
                this.ListingViewModel.IsAdvancedFilterOn = true;
            }

            return(View(GetViewName(ViewType.Index), this.ListingViewModel));
        }
Пример #16
0
 public override IQueryable <IModel> GetListingItems(ListingParams <UserModel> listingDataModel)
 {
     return
         (
         from user in new UserRepository(this.Context, this.UserID).GetActiveUsers()
         orderby user.PointsWonBonus descending, user.DisplayName ascending
         select  new UserModel
     {
         ID = user.UserID,
         Username = user.Username,
         DisplayName = user.DisplayName,
         Points = user.PointsWonBonus
     }
         );
 }
Пример #17
0
        private IQueryable <Contract> GetFilteredContracts(ListingParams apiParam, int take, out int totalRows)
        {
            int excludedRows = (apiParam.Page - 1) * take;
            //Apply logic/what to show based on layer here
            var baseQuery = ContractLayer.GetContractSet(apiParam.HttpContext, apiParam.DbContext);

            //var baseQuery = _context.Contract.AsQueryable();
            totalRows = baseQuery.Count();
            //Check if filter is applied
            if (!string.IsNullOrEmpty(apiParam.Type) && !string.IsNullOrEmpty(apiParam.Contain))
            {
                baseQuery = FilterTranslater(baseQuery, apiParam.Type, apiParam.Contain);
                totalRows = baseQuery.Count();
            }
            var ordered = OrderTranslater(baseQuery, apiParam.OrderBy, apiParam.Asc);

            return(ordered.Skip(excludedRows).Take(take));
        }
Пример #18
0
 public override IQueryable <IModel> GetListingItems(ListingParams <UserModel> listingDataModel)
 {
     return
         ((
              from user in new UserRepository(this.Context, this.UserID).GetActiveUsers()
              join
              pointForRound in this.Context.PointsForRounds on user.UserID equals pointForRound.UserID
              join
              setting in this.Context.Settings on pointForRound.RoundID equals listingDataModel.Model.RoundID
              join
              round in this.Context.Rounds on pointForRound.RoundID equals round.RoundID
              where   (this.IsAdmin || round.Finished)
              orderby pointForRound.MatchPointsBonus + pointForRound.GoalscorerPoints ascending
              select  new UserModel
     {
         ID = user.UserID,
         Username = user.Username,
         DisplayName = user.DisplayName,
         Points = pointForRound.MatchPointsBonus + pointForRound.GoalscorerPoints
     }
              ).Take(5));
 }
Пример #19
0
        protected PagedList <IModel> GetData(ListingParams <M> listingDataModel, bool forIndex = false)
        {
            this.SetData(listingDataModel, forIndex);

            return(new PagedList <IModel>(repo.GetListingItems(listingDataModel), listingDataModel.PageIndex ?? -1, listingDataModel.ItemsPerPage));
        }
Пример #20
0
 public IQueryable <TeamModel> GetSelectedWinner(ListingParams <TeamModel> listingDataModel)
 {
     return(this.GetWinnersForListing(listingDataModel).Where(e => e.BetMade));
 }
Пример #21
0
 public override ActionResult Index(int?id, string pageType, bool?isLookup, WinnerPointsModel model = null, ListingParams <WinnerPointsModel> listingParams = null)
 {
     if (!TournamentEnded)
     {
         return(Content("Not yet"));
     }
     else
     {
         return(base.Index(id, pageType, isLookup, model, listingParams));
     }
 }
Пример #22
0
 public override IQueryable <IModel> GetListingItems(ListingParams <GoalscorerModel> listingDataModel)
 {
     return(this.GetTopGoalscorerEntities());
 }
Пример #23
0
 public IQueryable <IModel> GetSelectedGoalscorer(ListingParams <GoalscorerModel> listingDataModel)
 {
     return(this.GetGoalscorersForListing(listingDataModel).Where(e => e.BetMade));
 }
Пример #24
0
 public override IQueryable <IModel> GetListingItems(ListingParams <MatchForRoundModel> listingDataModel)
 {
     return(new MatchesForRoundRepository(this).GetListingItems(listingDataModel));
 }
Пример #25
0
 private void CopyDataModelToViewModel(ListingParams <M> listingDataModel)
 {
     this.ListingViewModel.AdvancedFilterValues = listingDataModel.AdvancedFilters;
     this.ListingViewModel.Keyword = listingDataModel.Keyword;
 }
Пример #26
0
 private void CopyViewModelToDataModel(ListingParams <M> listingDataModel)
 {
     listingDataModel.AdvancedFilters = this.ListingViewModel.AdvancedFilterValues;
     listingDataModel.Keyword         = this.ListingViewModel.Keyword;
 }
Пример #27
0
        /// <summary>
        /// Sets listing data (search keyword, sorting, advanced filters, pagination, saved search)
        /// </summary>
        /// <param name="listingDataModel"></param>
        /// <param name="forIndex"></param>
        private void SetData(ListingParams <M> listingDataModel, bool forIndex)
        {
            //read data from session only if the page is loaded for the first time (not AJAX search)
            //but only if the page is not a lookup modal (these don't need to retain search parameters)
            //for AJAX search, all parameters are sent by the client
            var searchParams = (forIndex && !this.IsLookup) ? (Session[searchParamsSessionKey] as SearchParams) : null;

            if (searchParams == null)
            {
                searchParams = new SearchParams();
            }

            var pages       = this.IsSubDetailPage ? new string[] { "5", "15", "50" } : new string[] { "15", "25", "50", "100" };
            var minPageSize = this.ListingViewModel.MinPageSize ?? (this.IsLookup ? 10 : (this.IsSubDetailPage ? 5 : 15));

            //if no advanced filters, try to retrieve from value providers
            if (listingDataModel.AdvancedFilters == null || listingDataModel.AdvancedFilters.Count == 0)
            {
                listingDataModel.AdvancedFilters = DataExtensions.JSONToDictionary(this.ValueProvider.GetValue("advancedFilters"));
            }

            //if no advanced filters, try to retrieve from session
            if (listingDataModel.AdvancedFilters == null || listingDataModel.AdvancedFilters.Count == 0)
            {
                listingDataModel.AdvancedFilters = DataExtensions.JSONToDictionary(searchParams.AdvancedFilters);
            }

            //current page index
            listingDataModel.PageIndex = (listingDataModel.PageIndex.HasValue) ? listingDataModel.PageIndex.Value - 1 : Convert.ToInt32(searchParams.PageIndex ?? 0);

            //number of rows per page
            if (listingDataModel.ItemsPerPage == 0)
            {
                //on lookup pages, the items per page is constant
                if (this.IsLookup)
                {
                    listingDataModel.ItemsPerPage = minPageSize;
                }
                else
                {
                    listingDataModel.ItemsPerPage = Convert.ToInt32(searchParams.ItemsPerPage ?? minPageSize);
                }
            }

            //keyword search
            if (listingDataModel.Keyword == null)
            {
                listingDataModel.Keyword = "";
            }

            if (String.IsNullOrEmpty(listingDataModel.Keyword))
            {
                listingDataModel.Keyword = (searchParams.Keyword ?? "").ToString();
            }

            //sorting; if not set from request, retrieve data from session
            if (listingDataModel.Sort == null)
            {
                listingDataModel.Sort = new ListingSortModel
                {
                    Column = (searchParams.SortByColumn ?? "").ToString(),
                    Asc    = Convert.ToBoolean(searchParams.SortAsc ?? true)
                };
            }

            if (listingDataModel.Model == null)
            {
                listingDataModel.Model = new M();
            }

            //save data into session
            if (!this.IsLookup && !this.IsSubDetailPage)
            {
                searchParams.ItemsPerPage    = listingDataModel.ItemsPerPage;
                searchParams.PageIndex       = listingDataModel.PageIndex;
                searchParams.Keyword         = listingDataModel.Keyword;
                searchParams.SortByColumn    = listingDataModel.Sort.Column;
                searchParams.SortAsc         = listingDataModel.Sort.Asc;
                searchParams.AdvancedFilters = listingDataModel.AdvancedFilters.ToJSON();

                //disable session
                //Session[this.searchParamsSessionKey] = searchParams;
            }

            //set view data
            ViewBag.ItemsPerPage = listingDataModel.ItemsPerPage;

            ViewBag.Pager     = pages.ToSelectList(listingDataModel.ItemsPerPage.ToString(), false);
            ViewBag.Sorted    = listingDataModel.Sort.Column;
            ViewBag.SortedAsc = listingDataModel.Sort.Asc;
        }
Пример #28
0
        public ActionResult GetListing(string pageType, bool?isLookup, bool searchCriteriaChanged, ListingParams <M> listingDataModel)
        {
            this.SetListingParameters(pageType, isLookup, listingDataModel);

            this.SetListingData(listingDataModel.Model);
            this.ListingViewModel.Items = this.IsLookup ? this.GetLookupData(listingDataModel) : this.GetData(listingDataModel);

            return(View(GetViewName(ViewType.List), this.ListingViewModel.Items));
        }
Пример #29
0
        public ActionResult GetDataIDs(string pageType, bool?isLookup, bool searchCriteriaChanged, ListingParams <M> listingDataModel, List <int> excludedIDs)
        {
            this.SetListingParameters(pageType, isLookup, listingDataModel);
            this.SetData(listingDataModel, false);

            IEnumerable <int> ids = repo.GetLookupItems(listingDataModel).Select(e => e.ID).ToList();

            if (excludedIDs != null && excludedIDs.Count > 0)
            {
                ids = ids.Except(excludedIDs);
            }

            return(Json(ids));
        }
Пример #30
0
        public IQueryable <MatchForRoundModel> GetMatchesForRound(ListingParams <MatchForRoundModel> listingDataModel = null)
        {
            //if the round is not the current one, retrive matches from the next round
            int offset = (listingDataModel != null && listingDataModel.Model.Current) ? 0 : 1;
            int userID = this.UserID;

            var entities = this.GetAll();

            if (listingDataModel != null)
            {
                //if round ID is not set, return only matches in the current round
                if (listingDataModel.Model.RoundID == 0)
                {
                    entities =
                        (
                            from match in entities
                            join
                            setting in this.Context.Settings on match.RoundID equals setting.CurrentRoundID + offset
                            select match
                        );
                }
                //otherwise, return only matches in the given round, but only if the round is finished or permission is granted
                else
                {
                    entities =
                        (
                            from match in entities
                            join
                            round in this.Context.Rounds on match.RoundID equals round.RoundID
                            where   (this.IsAdmin || round.Finished || listingDataModel.Model.ForNotification) && match.RoundID == listingDataModel.Model.RoundID
                            select match
                        );
                }
                //if user id is received, default to that, otherwise the query will run for the logged in user
                if (listingDataModel.Model.UserID != null)
                {
                    userID = listingDataModel.Model.UserID.Value;
                }
            }

            var models =
                (
                    from match in entities
                    join
                    firstTeam in this.Context.Teams on match.FirstTeamID equals firstTeam.TeamID
                    join
                    secondTeam in this.Context.Teams on match.SecondTeamID equals secondTeam.TeamID
                    join
                    allBet in this.Context.MatchBets on new { MatchID = match.MatchID, UserID = userID } equals new { MatchID = allBet.MatchID, UserID = allBet.UserID } into allBets
                    from bet in allBets.DefaultIfEmpty()
                    orderby match.Date
                    select  new MatchForRoundModel
            {
                ID = match.MatchID,
                FirstTeamID = firstTeam.TeamID,
                FirstTeamName = firstTeam.Name,
                SecondTeamID = secondTeam.TeamID,
                SecondTeamName = secondTeam.Name,
                Points1 = match.Points1,
                PointsX = match.PointsX,
                Points2 = match.Points2,
                Date = match.Date,
                RoundID = match.RoundID,
                FirstTeamFlag = firstTeam.FlagPrefix,
                SecondTeamFlag = secondTeam.FlagPrefix,
                FirstTeamGoals = match.FirstTeamGoals,
                SecondTeamGoals = match.SecondTeamGoals,
                Result = match.Result,
                BetFirstTeamGoals = bet.FirstTeamGoals,
                BetSecondTeamGoals = bet.SecondTeamGoals,
                BetResult = bet.Result,
                BetPointsWon = bet.PointsWon,
                BetPointsWonBonus = bet.PointsWonBonus,
                Bonus = bet.Bonus,
                Expired = IsExpired(match.Date),
                WinTypeID = bet.WinTypeID ?? 0
            }
                );

            if (listingDataModel != null && !String.IsNullOrEmpty(listingDataModel.Keyword))
            {
                models = models.Where(e => e.FirstTeamName.Contains(listingDataModel.Keyword) || e.SecondTeamName.Contains(listingDataModel.Keyword));
            }

            return(models);
        }