Example #1
0
 /// <summary>
 /// Change SystemX Value
 /// </summary>
 public static void ChangeSystemX(int val, TicketStates state, Ticket newTicket)
 {
     if (val > 0 || TipListInfo.MinCombination < TipListInfo.SystemX + TipListInfo.PathCount)
     {
         newTicket.SystemX += val;
         UpdateSystemOrCombiticket(newTicket);
     }
 }
Example #2
0
 public static void SetSystemX(int val, TicketStates state)
 {
     if (val > 0 || TipListInfo.MinCombination < TipListInfo.SystemX + TipListInfo.PathCount)
     {
         TipListInfo.SystemX = val;
         UpdateSystemOrCombiticket(null);
     }
 }
Example #3
0
 /// <summary>
 /// Change SystemX Value
 /// </summary>
 public static void ChangeSystemX(int val, TicketStates state)
 {
     if (val > 0 || _tipListInfo.MinCombination < _tipListInfo.NumSystemX + _tipListInfo.PathCount)
     {
         _tipListInfo.NumSystemX += val;
         UpdateSystemOrCombiticket(false, state);
     }
 }
Example #4
0
        //private decimal CalculateConfidenceFactor(Ticket ticket)
        //{
        //    string localDelimeter = "*";
        //    string serverDelimeter = "|";

        //    decimal matchConfidenceFactor = 0;
        //    decimal maxBetLiability = 0;
        //    decimal marketConfidenceFactor = 0;

        //    for (int i = 0; i < ticket.TipItems.Count; i++)
        //    {
        //        string matchId = ticket.TipItems.ElementAt(i).Match.MatchId.ToString();
        //        string oddTag = ticket.TipItems.ElementAt(i).Odd.OddTag.Value;
        //        string tournamentId = ticket.TipItems.ElementAt(i).Match.MatchView.TournamentView.LineObject.SvrGroupId.ToString();
        //        string sportId = ticket.TipItems.ElementAt(i).Match.MatchView.SportView.LineObject.SvrGroupId.ToString();
        //        LiabilityLn liab = LineSr.Instance.AllObjects.Liabilities.SafelyGetValue(matchId + localDelimeter + LineSr.MATCH_FACTOR);
        //        if (liab != null && (liab.factor.Value < matchConfidenceFactor || matchConfidenceFactor == 0))
        //        {
        //            matchConfidenceFactor = liab.factor.Value;
        //        }

        //        liab = LineSr.Instance.AllObjects.Liabilities.SafelyGetValue(tournamentId + localDelimeter + LineSr.TOURN_CONF_RATING);
        //        if (liab != null)
        //        {
        //            LiabilityLn franchisorRating = LineSr.Instance.AllObjects.Liabilities.SafelyGetValue(liab.factor.Value.ToString() + localDelimeter + LineSr.CONF_RATING_VALUES);
        //            if (franchisorRating != null && (franchisorRating.factor.Value < maxBetLiability || maxBetLiability == 0))
        //                maxBetLiability = franchisorRating.factor.Value;
        //        }
        //        else
        //        {
        //            LiabilityLn franchisorRating = LineSr.Instance.AllObjects.Liabilities.SafelyGetValue("3" + localDelimeter + LineSr.CONF_RATING_VALUES);
        //            if (franchisorRating != null && (franchisorRating.factor.Value < maxBetLiability || maxBetLiability == 0))
        //                maxBetLiability = franchisorRating.factor.Value;
        //        }

        //        //marketConfidenceFactor "MATCH|180201|BD_TAG_0_1*LIMIT_FACTORS"
        //        liab = LineSr.Instance.AllObjects.Liabilities.SafelyGetValue("MATCH" + serverDelimeter + matchId + serverDelimeter + oddTag + localDelimeter + LineSr.LIMIT_FACTORS);
        //        if (liab == null)
        //        {
        //            liab = LineSr.Instance.AllObjects.Liabilities.SafelyGetValue("TOURNAMENT" + serverDelimeter + tournamentId + serverDelimeter + oddTag + localDelimeter + LineSr.LIMIT_FACTORS);
        //            if (liab == null)
        //            {
        //                liab = LineSr.Instance.AllObjects.Liabilities.SafelyGetValue("SPORT" + serverDelimeter + sportId + serverDelimeter + oddTag + localDelimeter + LineSr.LIMIT_FACTORS);
        //                if (liab == null)
        //                {
        //                    liab = LineSr.Instance.AllObjects.Liabilities.SafelyGetValue("SPORT" + serverDelimeter + sportId + serverDelimeter + "DEFAULT" + localDelimeter + LineSr.LIMIT_FACTORS);
        //                    if (liab != null && (liab.factor.Value < marketConfidenceFactor || marketConfidenceFactor == 0))
        //                    {
        //                        marketConfidenceFactor = liab.factor.Value;
        //                    }
        //                }
        //                else if (liab.factor.Value < marketConfidenceFactor || marketConfidenceFactor == 0)
        //                {
        //                    marketConfidenceFactor = liab.factor.Value;
        //                }
        //            }
        //            else if (liab.factor.Value < marketConfidenceFactor || marketConfidenceFactor == 0)
        //            {
        //                marketConfidenceFactor = liab.factor.Value;
        //            }
        //        }
        //        else if(liab.factor.Value < marketConfidenceFactor || marketConfidenceFactor == 0)
        //        {
        //            marketConfidenceFactor = liab.factor.Value;
        //        }
        //    }

        //    if (matchConfidenceFactor == 0)
        //        matchConfidenceFactor = 1;

        //    if (marketConfidenceFactor == 0)
        //        marketConfidenceFactor = 1;

        //    return matchConfidenceFactor * maxBetLiability * marketConfidenceFactor;
        //}

        public void UpdateTicket()
        {
            lock (_lockUpdate)
            {
                var ticketsInBasket = TicketsInBasket.ToSyncList();
                foreach (var ticket in ticketsInBasket)
                {
                    ticket.User = ChangeTracker.CurrentUser;
                    if (TicketState == TicketStates.Single && ticket.TipItems.ToSyncList().Count(x => x.IsChecked) >= 2)
                    {
                        TicketState = TicketStates.Multy;
                    }
                    if (TicketState != TicketStates.Single && ticket.TipItems.ToSyncList().Count(x => x.IsChecked) < 2)
                    {
                        if (ticketsInBasket.Count == 1)
                        {
                            ticketsInBasket.First().TicketState = TicketStates.Single;
                        }
                        TicketState = TicketStates.Single;
                    }

                    DataBinding.UpdateSystemOrCombiticket(ticket);
                    if (ticket.Stake > ticket.MaxBet && ChangeTracker.CurrentUser.Cashpool > 0)
                    {
                        OnChangeStake("max", ticket, ChangeTracker.CurrentUser.Cashpool);
                    }
                }
                UpdateStake();
            }



            OnPropertyChanged("MaxBet");
            OnPropertyChanged("MaxWin");
            OnPropertyChanged("MinBet");
            OnPropertyChanged("CurrentTicketPossibleWin");

            OnPropertyChanged("Count");
            OnPropertyChanged("TotalOddDisplay");
            OnPropertyChanged("ManipulationFeeValue");
            OnPropertyChanged("ManipulationFeePercentage");
            OnPropertyChanged("BonusValue");
            OnPropertyChanged("BonusValueRounded");
            OnPropertyChanged("IsVisibleBank");
            OnPropertyChanged("BonusPercentage");
        }
Example #5
0
        public static TicketWS CreateNewTicketWS(ObservableCollection <TipItem> tipItems, TicketStates ticketState, TipListInfo tipListInfo)
        {
            try
            {
                Nbt.Common.Utils.PasswordGenerator PWGen = new Nbt.Common.Utils.PasswordGenerator();
                TicketWS rTicketWs = new TicketWS();
                if (BetConfirmedCount > 0)
                {
                    rTicketWs.TicketNbr = LastTicketNbr;
                }
                else
                {
                    rTicketWs.TicketNbr = Catel.IoC.ServiceLocator.Instance.ResolveType <IStationProperties>().FullTicketNumber(NewTicketNumber);
                }
                //rTicketWs.TicketNbr = StationSettings.GetSettings.StationNumber+DateTime.Now.ToString("yy")+StationSettings.GetSettings.NewTicketNumber.ToString("0000000");
                //rTicketWs.TicketNbr = PWGen.Generate(14, 14, true);
                rTicketWs.CheckSum = PWGen.Generate(4, 4, true);


                rTicketWs.PaidBy          = StationTyp;
                rTicketWs.PaidTime        = DateTime.Now;
                rTicketWs.Paid            = false;
                rTicketWs.AcceptedBy      = StationTyp;
                rTicketWs.AcceptedTime    = DateTime.Now;
                rTicketWs.Stake           = tipListInfo.Bet;
                rTicketWs.Bets            = new ObservableCollection <BetWS>();
                rTicketWs.CancelledTime   = DateTimeUtils.DATETIMENULL;
                rTicketWs.EnablePayTime   = DateTime.MaxValue;
                rTicketWs.WonExpireTime   = DateTimeUtils.DATETIMENULL;
                rTicketWs.ManipulationFee = tipListInfo.ManipulationFeePercentage;
                BetWS bets = new BetWS();
                bets.SystemX = bets.SystemY = tipListInfo.NumOfTipps;

                switch (ticketState)
                {
                case TicketStates.Combi:
                    bets.BetType = BetBO.BET_TYPE_COMBI;
                    break;

                case TicketStates.System:
                    bets.BetType = BetBO.BET_TYPE_SYSTEM;
                    bets.SystemX = tipListInfo.NumSystemX;
                    bets.SystemY = tipListInfo.NumSystemY;
                    break;

                default:
                    bets.BetType = BetBO.BET_TYPE_SINGLE;
                    break;
                }
                bets.MaxOdd = tipListInfo.FullOddFactor;
                //bets.MaxWin = rTicketWs.Stake * bets.MaxOdd;
                bets.MaxWin      = tipListInfo.PossWin;
                bets.Stake       = rTicketWs.Stake;
                bets.IsMaxOddBet = tipListInfo.IsMaxOddBet;

                bets.BankTips      = new ObservableCollection <TipWS>();
                bets.Tips2BetMulti = new ObservableCollection <TipWS>();
                rTicketWs.Bets.Add(bets);
                rTicketWs.SuperBonus = tipListInfo.BonusFactor;

                Dictionary <int, int> matchIDCountDictionary = new Dictionary <int, int>();

                foreach (TipItem t in tipItems)
                {
                    int iMatchCode = t.Match.Code;

                    if (matchIDCountDictionary.ContainsKey(iMatchCode))
                    {
                        matchIDCountDictionary[iMatchCode]++;
                    }
                    else
                    {
                        matchIDCountDictionary.Add(iMatchCode, 1);
                    }
                }

                int liveBetTipCount  = 0;
                int sportBetTipCount = 0;
                foreach (TipItem t in tipItems)
                {
                    if (t.Odd != null)
                    {
                        if (t.Odd.IsLiveBet)
                        {
                            liveBetTipCount++;
                        }
                        else
                        {
                            sportBetTipCount++;
                        }
                    }
                    TipWS tip = new TipWS();
                    tip.Bank = t.IsBank;

                    if (t.Odd != null)
                    {
                        tip.Odd             = t.Odd.Value;
                        tip.SvrOddID        = (int)t.Odd.SvrOddID;                  //TODO: Wurde auf ServerOddID umgewandelt *g* 05.03.2008 by GMU
                        tip.BetDomainNumber = t.Odd.BetDomain.BetDomainNumber;
                        tip.MatchCode       = t.Odd.BetDomain.Match.Code;
                    }

                    if (tip.Bank || matchIDCountDictionary[tip.MatchCode] != 1)
                    {
                        tip.BankGroupID = (int)t.Match.SvrMatchID;
                        tip.Bank        = matchIDCountDictionary[tip.MatchCode] == 1;                 //Mehrwege haben kein Bank-Flag
                        if (ticketState == TicketStates.Combi)
                        {
                            bets.BetType = BetBO.BET_TYPE_COMBIPATH;
                        }
                        else if (ticketState == TicketStates.System)
                        {
                            bets.BetType = BetBO.BET_TYPE_SYSTEMPATH;
                        }
                        bets.Tips2BetMulti.Add(tip);                            //banken von system mit banken
                    }
                    else
                    {
                        bets.BankTips.Add(tip);                                         //system, kombi, einzeln
                    }
                }

                if (liveBetTipCount > 0 && sportBetTipCount == 0)
                {
                    rTicketWs.TicketTyp = TicketBO.TICKET_TYP_LIVEBET;
                }
                else if (liveBetTipCount == 0 && sportBetTipCount > 0)
                {
                    rTicketWs.TicketTyp = TicketBO.TICKET_TYP_SPORTBET;
                }
                else
                {
                    rTicketWs.TicketTyp = TicketBO.TICKET_TYP_BOTH;
                }
                int rowCount = 1;
                int[,] temp;
                if (ticketState == TicketStates.System)
                {
                    Nbt.Common.Odd.OddUtilities.SetPermutations(out temp, bets.SystemY, bets.SystemX);
                    rowCount = temp.GetLength(0);
                }
                Dictionary <int, int> tempMatchCodeCountDict = new Dictionary <int, int>();
                foreach (TipWS t in bets.Tips2BetMulti)
                {
                    if (tempMatchCodeCountDict.ContainsKey(t.MatchCode))
                    {
                        tempMatchCodeCountDict[t.MatchCode]++;
                    }
                    else
                    {
                        tempMatchCodeCountDict.Add(t.MatchCode, 1);
                    }
                }
                foreach (int curCount in tempMatchCodeCountDict.Values)
                {
                    rowCount *= curCount;
                }
                bets.Rows = rowCount;
                return(rTicketWs);
            }
            catch (Exception ex)
            {
                //WCFService.LogRemoteError(ex.Message, 1, ex.GetType().ToString(), EntityObject.Common.NBTLogBO.MSG_TERMINAL);
                return(null);
            }
        }
Example #6
0
 public static void UpdateSystemOrCombiticket(bool reset, TicketStates ticketState)
 {
     UpdateSystemOrCombiticket(reset, ticketState, ref _tipListInfo, _tipItems);
 }
Example #7
0
        /// <summary>
        /// Eintrag aus Ticket löschen
        /// </summary>
        /// <param name="p"></param>



        public static void UpdateSystemOrCombiticket(bool reset, TicketStates ticketState, ref TipListInfo tipListInfo, ObservableCollection <TipItem> tipItems)
        {
            decimal oddVal         = 1;
            decimal multiWayOddVal = 1;
            int     minCombMax     = 0;
            int     bonusTipsCount = 0;

            Dictionary <int, List <TipItem> > tipItemDict = new Dictionary <int, List <TipItem> >();

            foreach (TipItem t in tipItems)
            {
                int iSvrMatchId = (int)t.Match.SvrMatchID;

                if (tipItemDict.ContainsKey(iSvrMatchId))
                {
                    tipItemDict[iSvrMatchId].Add(t);
                }
                else
                {
                    List <TipItem> list = new List <TipItem>();
                    list.Add(t);
                    tipItemDict.Add(iSvrMatchId, list);
                }
            }
            // de: Anzahl der Wege berechnen                // en: Number of ways to calculate
            // de: höchste Quote der Mehrwege finden        // en: highest rate of multipath are
            //
            int pathCount = 0;
            int rowCount  = 1;

            foreach (List <TipItem> list in tipItemDict.Values)
            {
                if (list.Count >= 1)
                {
                    decimal maxOdd = 1;
                    foreach (TipItem tip in list)
                    {
                        if (maxOdd < tip.Odd.Value)
                        {
                            maxOdd = tip.Odd.Value;
                        }
                    }
                    TipItem t = list[0];
                    if (t.IsBank || list.Count > 1)
                    {
                        pathCount++;
                        rowCount       *= list.Count;
                        multiWayOddVal *= maxOdd;
                    }
                    else
                    {
                        oddVal *= maxOdd;
                    }
                    int curCombMax = minCombinationOfAll(t);
                    if (curCombMax > minCombMax)
                    {
                        minCombMax = curCombMax;
                    }
                    if (list.Count == 1 && ticketState == TicketStates.Combi)
                    {
                        if (t.Odd.Value >= BonusFromOdd)
                        {
                            //Bonus gibt es nicht bei Mehrwegen
                            bonusTipsCount++;
                        }
                    }
                }
            }

            tipListInfo.MinCombination    = minCombMax;
            tipListInfo.NumOfTipps        = tipItemDict.Count;
            tipListInfo.PathCount         = pathCount;
            tipListInfo.RowCount          = rowCount;
            tipListInfo.MultiWayOddFactor = multiWayOddVal;

            if (tipItems.Count > 0 && tipItems[0] != null && tipItems[0].Match != null)
            {
                if (!tipItems[0].Match.IsLiveBet)
                {
                    //Use manipulationFee only on Sport Bet, not on Live Bet according to Harri 2010-02-22 GMU
                    tipListInfo.ManipulationFeePercentage =
                        LimitHandling.ManipulationFeePercentage(tipListInfo.NumOfTipps);
                    tipListInfo.BonusFactor = LimitHandling.CombiBetSuperBonus(bonusTipsCount);
                }
                else
                {
                    // ale 14.07.2011: use manipulationfee also on livebet
                    tipListInfo.ManipulationFeePercentage =
                        LimitHandling.ManipulationFeeLivebetPercentage(tipListInfo.NumOfTipps);
                    tipListInfo.BonusFactor = 1;
                }
            }
            else
            {
                tipListInfo.ManipulationFeePercentage = 0;
                tipListInfo.BonusFactor = 1;
            }
            switch (ticketState)
            {
            case TicketStates.Single:
                UpdateSingleticketItems(ref tipListInfo, tipItems);
                break;

            case TicketStates.Combi:
                tipListInfo.FullOddFactor = oddVal * multiWayOddVal * tipListInfo.BonusFactor;
                if (tipListInfo.FullOddFactor >= MaxOdd)
                {
                    tipListInfo.IsMaxOddBet = true;
                    if (tipListInfo.FullOddFactor > MaxOdd)
                    {
                        tipListInfo.IllegalOddFactor = tipListInfo.FullOddFactor;
                    }
                    tipListInfo.FullOddFactor = MaxOdd;
                    tipListInfo.OddOfTipps    = MaxOdd;
                }
                else
                {
                    tipListInfo.OddOfTipps       = oddVal * multiWayOddVal;
                    tipListInfo.IllegalOddFactor = 0;
                    tipListInfo.IsMaxOddBet      = false;
                }
                tipListInfo.MinBet = MinStakeCombiBet;
                tipListInfo.MaxBet = Math.Round(LimitHandling.CombiMaxStake(tipListInfo.FullOddFactor * (100 - tipListInfo.ManipulationFeePercentage) / 100, tipItems.Count) * rowCount, 1);

                tipListInfo.MinWin = tipListInfo.FullOddFactor * tipListInfo.MinBet / rowCount * (100 - tipListInfo.ManipulationFeePercentage) / 100;
                tipListInfo.MaxWin = tipListInfo.FullOddFactor * tipListInfo.MaxBet / rowCount * (100 - tipListInfo.ManipulationFeePercentage) / 100;

                tipListInfo.PossWin = (tipListInfo.FullOddFactor * tipListInfo.Bet / rowCount * (100 - tipListInfo.ManipulationFeePercentage) / 100);

                tipListInfo.NumOfBets = 1;
                if ((tipListInfo.BonusFactor < 0.999m || tipListInfo.BonusFactor > 1.001m)
                    )
                {
                    tipListInfo.BonusDesc = "!TERMINAL_BONUS!";
                }

                break;

            case TicketStates.System:
                tipListInfo.BonusFactor      = 1;
                tipListInfo.FullOddFactor    = 0;                      //TODO: Calc system
                tipListInfo.IllegalOddFactor = 0;

                int ind = 0;
                TicketError = TicketError.NoError;
                if (!LimitHandling.SystemBetYAllowed(tipListInfo.NumSystemY))
                {                          //avoid useless time and memory consuming calculations
                    tipListInfo.ResetNumXY();
                    tipListInfo.NumOfBets          = 0;
                    tipListInfo.MinBet             = 0;
                    tipListInfo.OddOfTipps         = 0;
                    tipListInfo.MaxBet             = 0;
                    tipListInfo.MinWin             = 0;
                    tipListInfo.MaxWin             = 0;
                    tipListInfo.EnableSystemAddBtn = false;
                    tipListInfo.EnableSystemSubBtn = false;
                    return;
                }


                if (reset)
                {
                    tipListInfo.ResetNumXY();
                }

                tipListInfo.EnableSystemAddBtn = tipListInfo.NumSystemX < tipListInfo.NumSystemY - 1;
                tipListInfo.EnableSystemSubBtn = minCombMax <tipListInfo.NumSystemX + pathCount && tipListInfo.NumSystemX> TipListInfo.MinSystemX;


                decimal[] oddVals        = new decimal[tipListInfo.NumSystemY];
                bool      disableBankBtn = tipListInfo.PathCount + TipListInfo.MinSystemY >= tipListInfo.NumOfTipps;

                foreach (TipItem t in tipItems)
                {
                    if (!t.IsBank && t.Odd != null)
                    {
                        if (ind < oddVals.Length)
                        {
                            oddVals[ind++] = t.Odd.Value;
                        }
                        else
                        {
                            //_logger.Error("System Y value smaller as expected");


                            t.EnableBankBtn = !disableBankBtn;
                        }
                    }
                }
                tipListInfo.NumOfBets = (decimal)MathNet.Numerics.Fn.BinomialCoefficient(tipListInfo.NumSystemY, tipListInfo.NumSystemX) * tipListInfo.RowCount;
                decimal maxOdd = Nbt.Common.Odd.OddUtilities.AllCombinationsSum(oddVals, tipListInfo.NumSystemX);
                if (oddVals.Length < tipListInfo.NumSystemX)
                {                        //GMU 2011-02-01 fixed wrong || statement
                    string msg = ("in UpdateSystemOfCombiTicket reset=" + reset + " OddVals.Length: " + oddVals.Length + " smaller than " + tipListInfo.NumSystemX);
                    //_logger.Debug(msg);
                    //NbtLogSr.WriteNbtLogEntry(msg, NBTLogBO.PRIORITY_MEDIUM, StationSettings.GetSettings.StationNumber, NBTLogBO.MSG_TERMINAL);
                    return;
                }
                decimal minOdd = Nbt.Common.Odd.OddUtilities.MinCombinationsSum(oddVals, tipListInfo.NumSystemX);
                if (!LimitHandling.SystemBetOddAllowed(maxOdd, tipListInfo.MultiWayOddFactor, tipListInfo.RowCount))
                {
                    throw new Exception(TicketError.SystemItemsRangeError.ToString());
                }
                else
                {
                    //ViewControl.SetTicketErrorMessage(TicketError.NoError);
                    tipListInfo.MinBet = MinStakeSystemBet;
                    //tipListInfo.MaxBet = StationSettings.Station.MaxStakeSystemBet;
                    tipListInfo.OddOfTipps = maxOdd;
                    tipListInfo.MaxBet     = LimitHandling.SystemMaxStake(maxOdd * tipListInfo.MultiWayOddFactor) * tipListInfo.RowCount;

                    tipListInfo.MinWin  = tipListInfo.MinBet * maxOdd * tipListInfo.MultiWayOddFactor / tipListInfo.RowCount;
                    tipListInfo.MaxWin  = tipListInfo.MaxBet * maxOdd * tipListInfo.MultiWayOddFactor / tipListInfo.RowCount;
                    tipListInfo.PossWin = tipListInfo.Bet * maxOdd * tipListInfo.MultiWayOddFactor / tipListInfo.RowCount;
                }
                tipListInfo.FullOddFactor = maxOdd;
                tipListInfo.OddOfTipps    = maxOdd;

                break;
            }

            if (tipListInfo.ManipulationFeePercentage > 0)
            {
                tipListInfo.ManipulationFeeDesc = BetDomainSr.ManipulationFeeString + " " + String.Format("{0:F2}%", tipListInfo.ManipulationFeePercentage);
            }
            //ViewControl.UpdateBetNowButton();TODO: Removed by GMU 2008-09-04 because of beeing redundant
        }
Example #8
0
        public async Task <IEnumerable <Ticket> > GetTicketsAsync(string userEmail, List <string> userInRoles, TicketStates ticketState)
        {
            List <Ticket> results = new List <Ticket>();

            if (userInRoles.Contains("Administrators") || userInRoles.Contains("Support"))
            {
                switch (ticketState)
                {
                case TicketStates.New:
                    results = await _dbContext.Tickets.Include(p => p.Priority).Include(s => s.Status).Where(e => e.Status.TicketStatus == "New").OrderByDescending(i => i.Id).ToListAsync();

                    break;

                case TicketStates.Open:
                    results = await _dbContext.Tickets.Include(p => p.Priority).Include(s => s.Status).Where(t => t.Status.TicketStatus == "Open").OrderByDescending(i => i.Id).ToListAsync();

                    break;

                case TicketStates.OnHold:
                    results = await _dbContext.Tickets.Include(p => p.Priority).Include(s => s.Status).Where(t => t.Status.TicketStatus == "On Hold").OrderByDescending(i => i.Id).ToListAsync();

                    break;

                case TicketStates.Closed:
                    results = await _dbContext.Tickets.Include(p => p.Priority).Include(s => s.Status).Where(t => t.Status.TicketStatus == "Closed").OrderByDescending(i => i.Id).ToListAsync();

                    //results = await _dbContext.Tickets.Where(t => t.Status.TicketStatus == "Closed").OrderByDescending(i => i.Id).ToListAsync();
                    break;

                case TicketStates.Incomplete:
                    results = await _dbContext.Tickets.Include(p => p.Priority).Include(s => s.Status).Where(t => t.Status.TicketStatus != "Closed").OrderByDescending(i => i.Id).ToListAsync();

                    break;

                case TicketStates.All:
                    results = await _dbContext.Tickets.Include(p => p.Priority).Include(s => s.Status).OrderByDescending(i => i.Id).Take(1000).ToListAsync();

                    break;

                default: break;
                }
            }
            else
            {
                switch (ticketState)
                {
                case TicketStates.New:
                    results = await _dbContext.Tickets.Include(p => p.Priority).Include(s => s.Status).Where(e => e.EmailAddress == userEmail && e.Status.TicketStatus == "New").OrderByDescending(i => i.Id).ToListAsync();

                    break;

                case TicketStates.Open:
                    results = await _dbContext.Tickets.Include(p => p.Priority).Include(s => s.Status).Where(e => e.EmailAddress == userEmail && e.Status.TicketStatus == "Open").OrderByDescending(i => i.Id).ToListAsync();

                    break;

                case TicketStates.OnHold:
                    results = await _dbContext.Tickets.Include(p => p.Priority).Include(s => s.Status).Where(e => e.EmailAddress == userEmail && e.Status.TicketStatus == "On Hold").OrderByDescending(i => i.Id).ToListAsync();

                    break;

                case TicketStates.Closed:
                    results = await _dbContext.Tickets.Include(p => p.Priority).Include(s => s.Status).Where(e => e.EmailAddress == userEmail && e.Status.TicketStatus == "Closed").OrderByDescending(i => i.Id).ToListAsync();

                    break;

                case TicketStates.Incomplete:
                    results = await _dbContext.Tickets.Include(p => p.Priority).Include(s => s.Status).Where(e => e.EmailAddress == userEmail && e.Status.TicketStatus != "Closed").OrderByDescending(i => i.Id).ToListAsync();

                    break;

                case TicketStates.All:
                    results = await _dbContext.Tickets.Include(p => p.Priority).Include(s => s.Status).Where(e => e.EmailAddress == userEmail).OrderByDescending(i => i.Id).ToListAsync();

                    break;

                default: break;
                }
            }

            return(results);
        }