Esempio n. 1
0
        public static async Task <SongTableObject> UseSongKey(CsharpiEntities _db, string key)
        {
            var song = await _db.FindAsync <SongTableObject>(key);

            if (song != null)
            {
                return(song);
            }

            var result = await _db.SongTableObject
                         .AsNoTracking()
                         .Where(x => x.Key.ToLower().Equals(key.ToLower()))
                         .ToListAsync();

            return(result[0]);
        }
Esempio n. 2
0
 public static async Task<Embed> CalcTotalCorrect(CsharpiEntities _db, PlayersRulesService _service)
 {
     string successRates = "";
     foreach (string player in await _service.GetPlayersTracked())
     {
         float total = 0;
         float correct = 0;
         var Shows = await _db.PlayerStats
             .AsNoTracking()
             .Where(k => k.PlayerName.Equals(player))
             .ToListAsync();
         foreach (PlayerTableObject player1 in Shows)
         {
             total = total + player1.TotalTimesPlayed;
             correct = correct + player1.TimesCorrect;
         }
         successRates = successRates + player + " correct rate: " + Math.Round((double)(correct / total), 3) + "\n";
     }
     return await EmbedHandler.CreateBasicEmbed("Data", successRates, Color.Blue);
 }
Esempio n. 3
0
        public static async Task <List <PlayerTableObject> > AllObjectsForPlayer(CsharpiEntities _db, string name, bool onlyFromList)
        {
            if (onlyFromList)
            {
                var Query = await _db.PlayerStats
                            .AsNoTracking()
                            .Where(f => f.Rule.Equals(""))
                            .Where(j => j.PlayerName.Equals(name))
                            .Where(k => k.FromList > 0)
                            .ToListAsync();

                return(Query);
            }
            var PlayerQuery = await _db.PlayerStats
                              .AsNoTracking()
                              .Where(f => f.Rule.Equals(""))
                              .Where(j => j.PlayerName.Equals(name))
                              .ToListAsync();

            return(PlayerQuery);
        }
Esempio n. 4
0
 public DataService(CsharpiEntities database)
 {
     _db = database;
 }
Esempio n. 5
0
        public static async Task <List <PlayerTableObject> > PlayerStatsSearch(CsharpiEntities _db, string playerName, string showName, string type, string exactMatch)
        {
            List <PlayerTableObject> Shows;
            List <PlayerTableObject> Romajis;

            if (type.Equals("any"))
            {
                if (exactMatch.ToLower().Equals("exact") || exactMatch.ToLower().Equals("exactmatch"))
                {
                    //This will return player table objects where the showName is an exact match
                    Shows = await _db.PlayerStats
                            .AsNoTracking()
                            .Where(k => k.PlayerName.ToLower().Equals(playerName.ToLower()))
                            .Where(x => x.Show.ToLower().Equals(showName.ToLower()))
                            .Where(j => j.Rule.Equals(""))
                            .ToListAsync();

                    Romajis = await _db.PlayerStats
                              .AsNoTracking()
                              .Where(k => k.PlayerName.ToLower().Equals(playerName.ToLower()))
                              .Where(x => x.Romaji.ToLower().Equals(showName.ToLower()))
                              .Where(j => j.Rule.Equals(""))
                              .ToListAsync();
                }
                else
                {
                    Shows = await _db.PlayerStats
                            .AsNoTracking()
                            .Where(k => k.PlayerName.ToLower().Equals(playerName.ToLower()))
                            .Where(x => x.Show.ToLower().Contains(showName.ToLower()))
                            .Where(j => j.Rule.Equals(""))
                            .ToListAsync();

                    Romajis = await _db.PlayerStats
                              .AsNoTracking()
                              .Where(k => k.PlayerName.ToLower().Equals(playerName.ToLower()))
                              .Where(x => x.Romaji.ToLower().Contains(showName.ToLower()))
                              .Where(j => j.Rule.Equals(""))
                              .ToListAsync();
                }
            }
            else
            {
                if (exactMatch.ToLower().Equals("exact") || exactMatch.ToLower().Equals("exactmatch"))
                {
                    //this will return player table objects where the showname is an exact match
                    Shows = await _db.PlayerStats
                            .AsNoTracking()
                            .Where(k => k.PlayerName.ToLower().Equals(playerName.ToLower()))
                            .Where(x => x.Show.ToLower().Equals(showName.ToLower()))
                            .Where(j => j.Type.ToLower().Contains(type.ToLower()))
                            .Where(j => j.Rule.Equals(""))
                            .ToListAsync();

                    Romajis = await _db.PlayerStats
                              .AsNoTracking()
                              .Where(k => k.PlayerName.ToLower().Equals(playerName.ToLower()))
                              .Where(x => x.Romaji.ToLower().Equals(showName.ToLower()))
                              .Where(j => j.Type.ToLower().Contains(type.ToLower()))
                              .Where(j => j.Rule.Equals(""))
                              .ToListAsync();
                }
                else
                {
                    Shows = await _db.PlayerStats
                            .AsNoTracking()
                            .Where(k => k.PlayerName.ToLower().Equals(playerName.ToLower()))
                            .Where(x => x.Show.ToLower().Contains(showName.ToLower()))
                            .Where(j => j.Type.ToLower().Contains(type.ToLower()))
                            .Where(j => j.Rule.Equals(""))
                            .ToListAsync();

                    Romajis = await _db.PlayerStats
                              .AsNoTracking()
                              .Where(k => k.PlayerName.ToLower().Equals(playerName.ToLower()))
                              .Where(x => x.Romaji.ToLower().Contains(showName.ToLower()))
                              .Where(j => j.Type.ToLower().Contains(type.ToLower()))
                              .Where(j => j.Rule.Equals(""))
                              .ToListAsync();
                }
            }

            return(Shows.Union(Romajis, new PlayerTableObjectComparer()).ToList());
        }
Esempio n. 6
0
        public static async Task <List <SongTableObject> > ShowSearch(CsharpiEntities _db, string name, string type, string exactMatch)
        {
            List <SongTableObject> Shows;
            List <SongTableObject> Romajis;

            if (type.Equals("any"))
            {
                if (exactMatch.ToLower().Equals("exact") || exactMatch.ToLower().Equals("exactmatch"))
                {
                    Shows = await _db.SongTableObject
                            .AsNoTracking()
                            .Where(x => x.Show.ToLower().Equals(name.ToLower()))
                            .ToListAsync();

                    Romajis = await _db.SongTableObject
                              .AsNoTracking()
                              .Where(x => x.Romaji.ToLower().Equals(name.ToLower()))
                              .ToListAsync();
                }
                else
                {
                    Shows = await _db.SongTableObject
                            .AsNoTracking()
                            .Where(x => x.Show.ToLower().Contains(name.ToLower()))
                            .ToListAsync();

                    Romajis = await _db.SongTableObject
                              .AsNoTracking()
                              .Where(x => x.Romaji.ToLower().Contains(name.ToLower()))
                              .ToListAsync();
                }
            }
            else
            {
                if (exactMatch.ToLower().Equals("exact") || exactMatch.ToLower().Equals("exactmatch"))
                {
                    Shows = await _db.SongTableObject
                            .AsNoTracking()
                            .Where(k => k.Type.ToLower().Contains(type.ToLower()))
                            .Where(x => x.Show.ToLower().Equals(name.ToLower()))
                            .ToListAsync();

                    Romajis = await _db.SongTableObject
                              .AsNoTracking()
                              .Where(k => k.Type.ToLower().Contains(type.ToLower()))
                              .Where(x => x.Romaji.ToLower().Equals(name.ToLower()))
                              .ToListAsync();
                }
                else
                {
                    Shows = await _db.SongTableObject
                            .AsNoTracking()
                            .Where(k => k.Type.ToLower().Contains(type.ToLower()))
                            .Where(x => x.Show.ToLower().Contains(name.ToLower()))
                            .ToListAsync();

                    Romajis = await _db.SongTableObject
                              .AsNoTracking()
                              .Where(k => k.Type.ToLower().Contains(type.ToLower()))
                              .Where(x => x.Romaji.ToLower().Contains(name.ToLower()))
                              .ToListAsync();
                }
            }

            return(Shows.Union(Romajis, new SongTableObjectComparer()).ToList());
        }