示例#1
0
        public List <UISubCategory> GetUISubCategories(int id = 0)
        {
            string query = "SELECT  s.Id, s.Name, s.CategoryId, " +
                           "s.Description, c.Name as CategoryName " +
                           "FROM SubCategory  s LEFT JOIN Category c ON s.CategoryId = c.ID";

            using (CommanderBase commander = DBContext.CreateCommander())
            {
                if (id > 0)
                {
                    return(commander.Reader <UISubCategory>(query + " WHERE s.Id=" + id));
                }
                return(commander.Reader <UISubCategory>(query));
            }
        }
示例#2
0
        public List <UIUserRoles> GetUserRoles(int id)
        {
            string q = $"select * from UserRole u join Role r on u.RoleId=r.Id Where u.AppUserId={id}";

            using (CommanderBase commander = DBContext.CreateCommander())
            {
                var ur = commander.Reader <UIUserRoles>(q);
                return(ur);
            }
        }
示例#3
0
        public List <UIGames> GetUserGames(int id)
        {
            string q = $"select g.*, " +
                       $"u.UserName as AcceptUserName, " +
                       $"u1.UserName as RequestUserName " +
                       $"from Games g " +
                       $"LEFT JOIN AppUser u on u.Id = g.AcceptUser " +
                       $"LEFT JOIN AppUser u1 on u1.Id = g.RequestUser " +
                       $"where g.RequestUser = {id} or g.AcceptUser = {id}";

            using (CommanderBase commander = DBContext.CreateCommander())
                return(commander.Reader <UIGames>(q));
        }
示例#4
0
        public bool IsUserRole(int userId, int roleId)
        {
            string q = $"select * from UserRole u Where u.AppUserId={userId} and u.RoleId={roleId}";

            using (CommanderBase commander = DBContext.CreateCommander())
            {
                var ur = commander.Reader <UserRole>(q);
                if (ur.Count > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }