Last active
August 23, 2016 10:58
-
-
Save mhwelander/14ddf5bc2acaf56b2227b60e273d8d90 to your computer and use it in GitHub Desktop.
xDB facet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Sitecore.Analytics.Model.Framework; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
namespace xDB.Workshop.Facets | |
{ | |
/// <summary> | |
/// | |
/// </summary> | |
public interface IHotelMembershipDetails : IFacet | |
{ | |
int MembershipNumber { get; set; } | |
} | |
public class HotelMembershipFacet : Facet, IHotelMembershipFacet | |
{ | |
private const string _membershipNumber = "MEMBERSHIP"; | |
public HotelMembershipFacet() | |
{ | |
// TODO: Ensure that favourite hotels attribute | |
// HINT: Use the correct 'this.Ensure*' method for the type of attribute | |
this.EnsureAttribute<int>(_membershipNumber); | |
} | |
// TODO: Add PreferredHotels property | |
// HINT: Use IElementCollection for collections | |
// HINT: Collections only need a get { } | |
// TODO: Add PreferredWelcomeDrink property | |
public int MembershipNumber | |
{ | |
get | |
{ | |
return this.GetAttribute<int>(_membershipNumber); | |
} | |
set | |
{ | |
this.SetAttribute<int>(_membershipNumber, value); | |
} | |
} | |
} | |
public interface IHotel : IElement | |
{ | |
int HotelID { get; set; } | |
// TODO: Add hotel name property | |
} | |
public class Hotel : Element, IHotel | |
{ | |
// TODO: Implement interface | |
// HINT: Get and set attributes just like you did for HotelMembershipFacet | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment