Ejemplo n.º 1
0
        public Dictionary<string, string> Read(Guid Id, TablesNames tableName)
        {
            TableInform table;
            DbConnection connection;
            DataRow result;

            connection = TableInform.Connection;
            table = new TableInform(tableName.ToString());

            DataRow dr = table.Table.AsEnumerable().SingleOrDefault(r => r.Field<Guid>("ID") == Id);
            var dict = table.ConvertRowToDict(dr);
            return dict;
        }
Ejemplo n.º 2
0
        public void Insert(Dictionary<string, string> dictionary, TablesNames tableName)
        {
            TableInform table;
            DbConnection connection;
            DataRow result;

            table = new TableInform(tableName.ToString());
            connection = TableInform.Connection;
            result = table.ConvertDictToRow(dictionary);

            table.Table.Rows.Add(result);
            table.Update(new DataRow[] { result });
        }
Ejemplo n.º 3
0
        public void Delete(Dictionary<string, string> dictionary, TablesNames tableName)
        {
            TableInform table;
            DbConnection connection;
            DataRow row;
            string IdValue;

            IdValue = null;
            table = new TableInform(tableName.ToString());
            table.Table.PrimaryKey = new DataColumn[] { table.Table.Columns["Id"] };
            connection = TableInform.Connection;

            if (dictionary.TryGetValue("Id", out IdValue))
            {
                row = table.Table.Rows.Find(IdValue);
                row.Delete();
                table.Update(new DataRow[] { row });
            }
        }
Ejemplo n.º 4
0
        public void Update(Dictionary<string, string> dictionary, TablesNames tableName)
        {
            TableInform table;
            DbConnection connection;
            string IdValue;
            DataRow row;

            IdValue = null;
            table = new TableInform(tableName.ToString());
            connection = TableInform.Connection;
            table.Table.PrimaryKey = new DataColumn[] { table.Table.Columns["Id"] };

            if (dictionary.TryGetValue("Id", out IdValue))
            {
                row = table.Table.Rows.Find(IdValue);
                foreach (KeyValuePair<string, string> pair in dictionary)
                {
                    row[pair.Key] = pair.Value;
                }

                table.Update(new DataRow[] { row });
            }
        }
Ejemplo n.º 5
0
        public List<Dictionary<string, string>> ReadAll(TablesNames tableName, Gender gender)
        {
            TableInform table;
            DbConnection connection;
            DataRow[] rows;
            List<Dictionary<string, string>> resultedList;

            connection = TableInform.Connection;
            resultedList = new List<Dictionary<string, string>>();
            table = new TableInform(tableName.ToString());

            if (gender == Gender.NotSpecified)
            {
                rows = table.Table.Select();
            }
            else
            {
                string param = String.Format("LEAGUE = '{0}'", gender.ToString());
                rows = table.Table.Select(param);
            }

            foreach (var row in rows)
            {
                var result = table.ConvertRowToDict(row);
                resultedList.Add(result);
            }
            return resultedList;
        }
Ejemplo n.º 6
0
        public List<Dictionary<string, string>> FindSerchResults(string serchableName, TablesNames tableName, Gender gender)
        {
            TableInform table;
            DbConnection connection;
            List<Dictionary<string, string>> result;

            result = new List<Dictionary<string, string>>();
            connection = TableInform.Connection;
            table = new TableInform(tableName.ToString());

            var rowList = table.Table.AsEnumerable().Where(r => r.Field<string>("Name").Contains(serchableName.ToUpper())).ToList();

            if (rowList.Count > 0)
            {
                foreach (var row in rowList)
                {
                    if (row.Field<string>("League") == gender.ToString())
                    {
                        result.Add(table.ConvertRowToDict(row));
                    }
                }
                return result;
            }
            return null;
        }
Ejemplo n.º 7
0
        private List<Dictionary<string, string>> ReadByIds(TablesNames tableName, List<Guid> idList)
        {
            TableInform table;
            List<Dictionary<string, string>> resultedList;

            resultedList = new List<Dictionary<string, string>>();
            table = new TableInform(tableName.ToString());

            if (idList.Count > 0)
            {
                foreach (var id in idList)
                {
                    var row = (from r in table.Table.AsEnumerable()
                               where r.Field<Guid>("Id") == id
                               select r).SingleOrDefault();

                    var result = table.ConvertRowToDict(row);
                    resultedList.Add(result);
                }
                return resultedList;
            }
            return null;
        }
Ejemplo n.º 8
0
        private List<Guid> GetTeamsByGameId(TablesNames tableName, Guid gameId)
        {
            TableInform table;
            List<Guid> result;

            table = new TableInform(tableName.ToString());

            var res = (from r in table.Table.AsEnumerable()
                       where r.Field<Guid>("Id") == gameId
                       select r).SingleOrDefault();
            result = new List<Guid>();
            result.Add((Guid)res["TeamOneId"]);
            result.Add((Guid)res["TeamTwoId"]);

            return result;
        }
Ejemplo n.º 9
0
        private List<Guid> GetPlayersByGameId(TablesNames tableName, Guid gameId)
        {
            TableInform table;

            table = new TableInform(tableName.ToString());

            var res = (from r in table.Table.AsEnumerable()
                       where r.Field<Guid>("GameId") == gameId
                       select r.Field<Guid>("PlayerId")).ToList();
            return res;
        }
Ejemplo n.º 10
0
        private List<Guid> GetGamesByTeamId(TablesNames tableName, Guid teamId)
        {
            TableInform table;
            List<Dictionary<string, string>> resultedList;

            resultedList = new List<Dictionary<string, string>>();
            table = new TableInform(tableName.ToString());

            var res = (from r in table.Table.AsEnumerable()
                       where r.Field<Guid>("TeamOneId") == teamId || r.Field<Guid>("TeamTwoId") == teamId
                       select r.Field<Guid>("Id")).ToList();
            return res;
        }
Ejemplo n.º 11
0
        private List<Guid> GetInfoByPlayerId(TablesNames tableName, Guid playerId)
        {
            TableInform table;

            table = new TableInform(tableName.ToString());
            string param = (tableName.ToString().Substring(8, 4) + "Id");

            var res = (from r in table.Table.AsEnumerable()
                       where r.Field<Guid>("PlayerId") == playerId
                       select r.Field<Guid>(param)).ToList();
            return res;
        }