protected override DriverResult Display(WishListListPart part, string displayType, dynamic shapeHelper) { var shapes = new List <DriverResult>(3); var user = part.ContentItem.As <CommonPart>().Owner; //get the elements out of the wishlist List <dynamic> elementsShapes = new List <dynamic>(); foreach (var wlItem in part.WishListItems) { var itemPart = wlItem.As <WishListItemPart>(); if (itemPart != null) { elementsShapes.Add(_contentManager.BuildDisplay(itemPart)); } } //Get the additional shapes form the extensions List <dynamic> extensionsShapes = new List <dynamic>(); foreach (var ext in _wishListExtensionProviders) { extensionsShapes.Add(ext.BuildWishListDisplayShape(part)); } shapes.Add(ContentShape("Parts_WishListList", () => shapeHelper.Parts_WishListList(new WishListListViewModel { ElementsShapes = elementsShapes, ExtensionShapes = extensionsShapes }))); shapes.Add(ContentShape("Parts_ListOfWishLists", () => shapeHelper.Parts_ListOfWishLists( WishLists: _wishListServices.GetWishLists(user) ))); shapes.Add(ContentShape("Parts_WishListsActions", () => shapeHelper.Parts_WishListsActions( CreateShape: _wishListsUIServices.CreateShape(user), SettingsShape: _wishListsUIServices.SettingsShape(user, part.ContentItem.Id) ))); return(Combined(shapes.ToArray())); }
protected override DriverResult Display(ProductPart part, string displayType, dynamic shapeHelper) { var user = _wca.GetContext().CurrentUser; //usually, wishlists only apply to authenticated users. //however, we are still going to show the "Add to list" functionalities, to drive sign-up / login var wishLists = user == null ? new List <WishListListPart>() : _wishListServices.GetWishLists(user).ToList(); // Get attributes and add them to the add to list shape var attributeShapes = _attributeDrivers .Select(p => p.GetAttributeDisplayShape(part.ContentItem, shapeHelper)) .ToList(); return(ContentShape("Parts_Product_AddToWishlistButton", () => shapeHelper.Parts_Product_AddToWishlistButton( ProductId: part.Id, User: user, WishLists: wishLists, Prefix: Prefix, CreateShape: _wishListsUIServices.CreateShape(user, part), //in case we want a "new wishlist" link AttributeShapes: attributeShapes ))); }
public ActionResult Create() { var model = _wishListsUIServices.CreateShape(_wca.GetContext().CurrentUser); return(View("WishListEditor", model)); }