Exemplo n.º 1
0
        public int CountActivGames(int acceptUserId, int requestUserId)
        {
            string q = $"select Count(Id) from Games g where (g.RequestUser={requestUserId} and g.AcceptUser={acceptUserId} and g.Status <> 'Close') or (g.RequestUser={acceptUserId} and g.AcceptUser={requestUserId}) and g.Status <> 'Close'";

            using (CommanderBase commander = DBContext.CreateCommander())
            {
                var obj = commander.Scaller(q);
                return(obj != null?Convert.ToInt32(obj) : default(int));
            }
        }
Exemplo n.º 2
0
        public int GetIdByColumName(string columName, object value)
        {
            string q = $"Select u.Id from AppUser u Where u.{columName} = @{columName}";

            using (CommanderBase commander = DBContext.CreateCommander())
            {
                var obj = commander.Scaller(q, new List <System.Data.Common.DbParameter>()
                {
                    commander.SetParametr(columName, value)
                });
                if (obj != null)
                {
                    return(Convert.ToInt32(obj));
                }
                else
                {
                    return(default(int));
                }
            }
        }