private static MemberFacetFreeText CreateFreeTextMemberFacet(Member member, Facet textFacet)
        {
            var facet = new MemberFacetFreeText
            {
                FacetId       = textFacet.Id,
                MemberId      = member.Id,
                FreeTextValue = "Aardvark"
            };

            facet = new MemberFacets().Insert(facet);
            return(facet);
        }
Example #2
0
        public IEnumerable <MemberFacet> ForMember(int memberId)
        {
            var query = db.MemberFacets.FindAllByMemberId(memberId)
                        .Select(db.MemberFacets.ID, db.MemberFacets.FacetId, db.MemberFacets.FreeTextValue,
                                db.MemberFacets.MemberFacetValue.FacetValueId,
                                db.MemberFacets.MemberFacetValue.FacetValue.Value,
                                db.MemberFacets.MemberFacetValue.Id.As("MemberFacetValueId"),
                                db.MemberFacets.Facet.Type, db.MemberFacets.Facet.Name);

            var listCache = new Dictionary <int, MemberFacetList>();

            foreach (var row in query)
            {
                if (row.Type == FacetType.FreeText.ToString())
                {
                    MemberFacetFreeText facet = row;
                    facet.Facet = new Facet {
                        Id = row.FacetId, Name = row.Name, Type = FacetType.FreeText
                    };
                    yield return(facet);
                }
                else if (row.Type == FacetType.List.ToString())
                {
                    MemberFacetList facet;
                    if (listCache.ContainsKey(row.Id))
                    {
                        facet = listCache[row.Id];
                    }
                    else
                    {
                        facet       = row;
                        facet.Facet = new Facet {
                            Id = row.FacetId, Name = row.Name, Type = FacetType.List
                        };
                        facet.Values = new List <MemberFacetValue>();
                        listCache.Add(facet.Id, facet);
                    }
                    facet.Values.Add(new MemberFacetValue
                    {
                        Id            = row.MemberFacetValueId,
                        FacetValueId  = row.MemberFacetValueId,
                        MemberFacetId = row.Id
                    });
                }
            }

            foreach (var memberFacetList in listCache.Values)
            {
                yield return(memberFacetList);
            }
        }
Example #3
0
 public MemberFacetFreeText Insert(MemberFacetFreeText facet)
 {
     return(db.MemberFacets.Insert(facet));
 }
Example #4
0
 public MemberFacetFreeText Insert(MemberFacetFreeText facet)
 {
     return db.MemberFacets.Insert(facet);
 }