Esempio n. 1
0
        protected override IEnumerable <IMemberGroup> PerformGetByQuery(IQuery <IMemberGroup> query)
        {
            var sqlClause  = GetBaseQuery(false);
            var translator = new SqlTranslator <IMemberGroup>(sqlClause, query);
            var sql        = translator.Translate();

            return(Database.Fetch <NodeDto>(sql).Select(x => MemberGroupFactory.BuildEntity(x)));
        }
Esempio n. 2
0
        protected override IMemberGroup PerformGet(int id)
        {
            var sql = GetBaseQuery(false);

            sql.Where(GetBaseWhereClause(), new { id = id });

            var dto = Database.Fetch <NodeDto>(SqlSyntax.SelectTop(sql, 1)).FirstOrDefault();

            return(dto == null ? null : MemberGroupFactory.BuildEntity(dto));
        }
Esempio n. 3
0
        public IMemberGroup Get(Guid uniqueId)
        {
            var sql = GetBaseQuery(false);

            sql.Where("umbracoNode.uniqueId = @uniqueId", new { uniqueId });

            var dto = Database.Fetch <NodeDto>(SqlSyntax.SelectTop(sql, 1)).FirstOrDefault();

            return(dto == null ? null : MemberGroupFactory.BuildEntity(dto));
        }
Esempio n. 4
0
        protected override IEnumerable <IMemberGroup> PerformGetAll(params int[] ids)
        {
            var sql = Sql()
                      .SelectAll()
                      .From <NodeDto>()
                      .Where <NodeDto>(dto => dto.NodeObjectType == NodeObjectTypeId);

            if (ids.Any())
            {
                sql.Where("umbracoNode.id in (@ids)", new { /*ids =*/ ids });
            }

            return(Database.Fetch <NodeDto>(sql).Select(x => MemberGroupFactory.BuildEntity(x)));
        }
Esempio n. 5
0
        public IEnumerable <IMemberGroup> GetMemberGroupsForMember(int memberId)
        {
            var sql = Sql()
                      .Select("umbracoNode.*")
                      .From <NodeDto>()
                      .InnerJoin <Member2MemberGroupDto>()
                      .On <NodeDto, Member2MemberGroupDto>(dto => dto.NodeId, dto => dto.MemberGroup)
                      .Where <NodeDto>(x => x.NodeObjectType == NodeObjectTypeId)
                      .Where <Member2MemberGroupDto>(x => x.Member == memberId);

            return(Database.Fetch <NodeDto>(sql)
                   .DistinctBy(dto => dto.NodeId)
                   .Select(x => MemberGroupFactory.BuildEntity(x)));
        }
Esempio n. 6
0
        public IEnumerable <IMemberGroup> GetMemberGroupsForMember(string username)
        {
            var sql = Sql()
                      .Select("un.*")
                      .From("umbracoNode AS un")
                      .InnerJoin("cmsMember2MemberGroup")
                      .On("cmsMember2MemberGroup.MemberGroup = un.id")
                      .InnerJoin("cmsMember")
                      .On("cmsMember.nodeId = cmsMember2MemberGroup.Member")
                      .Where("un.nodeObjectType=@objectType", new { objectType = NodeObjectTypeId })
                      .Where("cmsMember.LoginName=@loginName", new { loginName = username });

            return(Database.Fetch <NodeDto>(sql)
                   .DistinctBy(dto => dto.NodeId)
                   .Select(x => MemberGroupFactory.BuildEntity(x)));
        }