diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..781976b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,27 @@
+#Visual Studio files
+*.[Oo]bj
+*.user
+*.aps
+*.pch
+*.vspscc
+*.vssscc
+*_i.c
+*_p.c
+*.ncb
+*.suo
+*.tlb
+*.tlh
+*.bak
+*.[Cc]ache
+*.ilk
+*.log
+*.lib
+*.sbr
+*.sdf
+*.pyc
+ipch/
+obj/
+[Bb]in
+[Dd]ebug*/
+[Rr]elease*/
+/Storefront/packages/
\ No newline at end of file
diff --git a/Storefront/CS/CSF/App_Config/Include/Reference.Storefront/Reference.Storefront.WishLists.config b/Storefront/CS/CSF/App_Config/Include/Reference.Storefront/Reference.Storefront.WishLists.config
new file mode 100644
index 0000000..744ffd1
--- /dev/null
+++ b/Storefront/CS/CSF/App_Config/Include/Reference.Storefront/Reference.Storefront.WishLists.config
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Storefront/CS/CSF/Commerce.Storefront.csproj b/Storefront/CS/CSF/Commerce.Storefront.csproj
index 1c55a18..2c58f4f 100644
--- a/Storefront/CS/CSF/Commerce.Storefront.csproj
+++ b/Storefront/CS/CSF/Commerce.Storefront.csproj
@@ -33,6 +33,7 @@
..\..\
true
+
true
@@ -91,6 +92,7 @@
False
..\..\Lib\CommerceServer.Core.CrossTier.dll
+
False
..\..\..\Lib\CommerceServer.Core.Profiles.dll
@@ -314,7 +316,9 @@
Designer
-
+
+ Designer
+
Designer
@@ -322,15 +326,8 @@
Designer
-
-
- web.config
-
-
- web.config
-
@@ -370,6 +367,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -379,6 +389,7 @@
+
Default.aspx
ASPXCodeBehind
@@ -441,12 +452,15 @@
CustomDictionary.xml
-
+
-
+
diff --git a/Storefront/CS/CSF/Connect/Pipelines/Constants.cs b/Storefront/CS/CSF/Connect/Pipelines/Constants.cs
new file mode 100644
index 0000000..a4d6092
--- /dev/null
+++ b/Storefront/CS/CSF/Connect/Pipelines/Constants.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace Sitecore.Reference.Storefront.Connect.Pipelines
+{
+ ///
+ ///
+ ///
+ public static class Constants
+ {
+ ///
+ ///
+ ///
+ public const string WishListNameBeginning = "WishList_";
+
+ ///
+ ///
+ ///
+ public const string TranslateOrderGroupToWishList = "translate.ordergrouptowishlist";
+ public const string TranslateOrderGroupToWishListHeader = "translate.ordergrouptowishlistheader";
+
+ }
+}
\ No newline at end of file
diff --git a/Storefront/CS/CSF/Connect/Pipelines/Utilities/OrderGroupUtility.cs b/Storefront/CS/CSF/Connect/Pipelines/Utilities/OrderGroupUtility.cs
new file mode 100644
index 0000000..3e3d257
--- /dev/null
+++ b/Storefront/CS/CSF/Connect/Pipelines/Utilities/OrderGroupUtility.cs
@@ -0,0 +1,49 @@
+using CommerceServer.Core.Runtime.Orders;
+using Sitecore.Commerce.Connect.CommerceServer.Pipelines;
+using Sitecore.Commerce.Services;
+using Sitecore.Globalization;
+using Sitecore.Reference.Storefront.Connect.Pipelines.WishLists;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace Sitecore.Reference.Storefront.Connect.Pipelines.Utilities
+{
+ public static class OrderGroupUtility
+ {
+
+ ///
+ /// Executes vaidation of the wish list order group
+ ///
+ ///
+ ///
+ ///
+ public static bool ValidOrderGroupForWishList(TranslateOrderGroupRequest request, CommerceResult result)
+ {
+ SystemMessage systemMessage = null;
+
+ if (!(request.OrderGroup is Basket))
+ {
+ systemMessage = new SystemMessage()
+ {
+ Message = Translate.Text("TranslateOrderGroupToEntity recieved an invalid OrderGroup type \"{0}\".", (object)request.OrderGroup.GetType().Name)
+ };
+ }
+ else if (request.OrderGroup.OrderForms != null && request.OrderGroup.OrderForms.Count > 1)
+ {
+ systemMessage = new SystemMessage()
+ {
+ Message = Translate.Text("TranslateOrderGroupToEntity recieved an invalid OrderGroup with more than one OrderForm \"{0}\".", request.OrderGroup.OrderForms.Count)
+ };
+ }
+ else
+ {
+ return true;
+ }
+
+ result.SystemMessages.Add(systemMessage);
+ return false;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Storefront/CS/CSF/Connect/Pipelines/Utilities/UserUtility.cs b/Storefront/CS/CSF/Connect/Pipelines/Utilities/UserUtility.cs
new file mode 100644
index 0000000..fd99f41
--- /dev/null
+++ b/Storefront/CS/CSF/Connect/Pipelines/Utilities/UserUtility.cs
@@ -0,0 +1,41 @@
+using CommerceServer.Core.Runtime.Profiles;
+using Sitecore.Commerce.Connect.CommerceServer;
+using Sitecore.Commerce.Connect.CommerceServer.Profiles.Pipelines;
+using Sitecore.Pipelines;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace Sitecore.Reference.Storefront.Connect.Pipelines.Utilities
+{
+ ///
+ ///
+ ///
+ public static class UserUtility
+ {
+ /// Resolves the user identifier.
+ /// The given user identifier.
+ /// The cs user identifier.
+ /// true if the userId has been resolved; Otherwise false.
+ public static bool ResolveUserId(string givenUserId, out Guid csUserId)
+ {
+ bool flag = Guid.TryParse(givenUserId, out csUserId);
+ if (!flag)
+ {
+ GetProfileArgs getProfileArgs = new GetProfileArgs();
+ getProfileArgs.InputParameters.Name = "UserObject";
+ getProfileArgs.InputParameters.Id = givenUserId;
+ getProfileArgs.InputParameters.Field = CommerceTypeLoader.ConfigurationProvider.CurrentConfiguration.Profiles.SitecoreLinkProperty;
+ CorePipeline.Run("GetProfile", (PipelineArgs)getProfileArgs);
+ Profile commerceProfile = getProfileArgs.OutputParameters.CommerceProfile;
+ if (commerceProfile != null)
+ {
+ csUserId = Guid.Parse(commerceProfile["GeneralInfo.user_id"].Value as string);
+ flag = true;
+ }
+ }
+ return flag;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Storefront/CS/CSF/Connect/Pipelines/WishLists/AddLinesToWishList.cs b/Storefront/CS/CSF/Connect/Pipelines/WishLists/AddLinesToWishList.cs
new file mode 100644
index 0000000..0c03f6b
--- /dev/null
+++ b/Storefront/CS/CSF/Connect/Pipelines/WishLists/AddLinesToWishList.cs
@@ -0,0 +1,115 @@
+using Sitecore.Commerce.Pipelines.WishLists.Common;
+using Sitecore.Diagnostics;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using Sitecore.Commerce.Pipelines;
+using Sitecore.Commerce.Services.WishLists;
+using Sitecore.Commerce.Connect.CommerceServer.Orders.Pipelines;
+using Sitecore.Commerce.Services;
+using Sitecore.Commerce.Entities.WishLists;
+using Sitecore.Commerce.Connect.CommerceServer.Orders.Models;
+using Sitecore.Commerce.Connect.CommerceServer.Connect.Utility;
+using CommerceServer.Core.Runtime.Orders;
+using System.Collections.ObjectModel;
+using Sitecore.Commerce;
+using Sitecore.Commerce.Connect.CommerceServer.Orders;
+using Sitecore.Commerce.Connect.CommerceServer;
+using Sitecore.Reference.Storefront.Connect.Pipelines.Utilities;
+using Sitecore.Globalization;
+using Sitecore.Commerce.Connect.CommerceServer.Pipelines;
+
+namespace Sitecore.Reference.Storefront.Connect.Pipelines.WishLists
+{
+ ///
+ ///
+ ///
+ public class AddLinesToWishList : WishListPipelineProcessor
+ {
+ /// Processes the specified arguments.
+ /// The arguments.
+ public override void Process(ServicePipelineArgs args)
+ {
+ Assert.ArgumentNotNull(args, "args");
+ Assert.ArgumentNotNull(args.Request, "args.Request");
+ Assert.ArgumentNotNull(args.Result, "args.Result");
+ Assert.IsTrue(args.Request is AddLinesToWishListRequest, "args.Request is AddLinesToWishListRequest");
+ Assert.IsTrue(args.Result is AddLinesToWishListResult, "args.Result is AddLinesToWishListResult");
+
+ var request = (AddLinesToWishListRequest)args.Request;
+ var result = (AddLinesToWishListResult)args.Result;
+
+ Assert.ArgumentNotNull(request.Lines, "request.Lines");
+ Assert.ArgumentNotNull(request.WishList, "request.WishList");
+ Assert.IsNotNullOrEmpty(request.WishList.ExternalId, "request.WishList.ExternalId");
+
+ var userId = request.WishList.UserId;
+ var wishListId = Guid.Parse(request.WishList.ExternalId);
+
+ Guid csUserId;
+ if (!UserUtility.ResolveUserId(userId, out csUserId))
+ {
+ result.Success = false;
+ var systemMessage = new SystemMessage()
+ {
+ Message = Translate.Text("GetWishList was unable to retrieve user \"{0}\".", (object)userId)
+ };
+ result.SystemMessages.Add(systemMessage);
+
+ return;
+ }
+
+ var instance = CommerceTypeLoader.CreateInstance();
+ var basket = instance.GetBasket(csUserId, wishListId);
+
+ foreach (WishListLine line in request.Lines)
+ {
+ if (line != null)
+ {
+ var commerceCartProduct = (CommerceCartProduct)line.Product;
+ var lineItem = OrderUtility.CreateLineItem(commerceCartProduct.ProductCatalog, line.Product.ProductId, commerceCartProduct.ProductVariantId, (Decimal)line.Quantity);
+ this.AppendedLineItemProperties(line, lineItem);
+
+ if (basket.OrderForms == null || basket.OrderForms.Count == 0)
+ {
+ basket.OrderForms.Add(OrderUtility.CreateOrderForm());
+ }
+
+ basket.OrderForms[0].LineItems.Add(lineItem, true);
+ }
+ }
+
+ basket.Save();
+
+ result.AddedLines = request.Lines.ToList().AsReadOnly();
+ result.WishList = this.TranslateBasketToWishList(userId,basket);
+ }
+
+ ///
+ /// Add any appended custom properties to the
+ ///
+ /// The request.
+ /// The cart line.
+ /// The line item.
+ protected virtual void AppendedLineItemProperties(WishListLine cartLine, LineItem lineItem)
+ {
+ foreach (PropertyItem property in (Collection)cartLine.Properties)
+ lineItem[property.Key] = property.Value;
+ }
+
+ ///
+ /// Translates the commerce server basekt to the wish list entity
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected virtual WishList TranslateBasketToWishList(string userId, Basket basket)
+ {
+ var request = new TranslateOrderGroupToWishListRequest(userId, "", basket);
+ var result = PipelineUtility.RunCommerceConnectPipeline(Constants.TranslateOrderGroupToWishList, request);
+ return result.WishList;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Storefront/CS/CSF/Connect/Pipelines/WishLists/CreateWishList.cs b/Storefront/CS/CSF/Connect/Pipelines/WishLists/CreateWishList.cs
new file mode 100644
index 0000000..468865a
--- /dev/null
+++ b/Storefront/CS/CSF/Connect/Pipelines/WishLists/CreateWishList.cs
@@ -0,0 +1,117 @@
+using Sitecore.Commerce.Pipelines.WishLists.Common;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using Sitecore.Commerce.Pipelines;
+using Sitecore.Diagnostics;
+using Sitecore.Commerce.Services.WishLists;
+using Sitecore.Commerce.Connect.CommerceServer.Orders.Pipelines;
+using Sitecore.Commerce.Connect.CommerceServer.Orders;
+using Sitecore.Commerce.Connect.CommerceServer;
+using Sitecore.Commerce.Connect.CommerceServer.Profiles.Pipelines;
+using Sitecore.Pipelines;
+using CommerceServer.Core.Runtime.Profiles;
+using Sitecore.Commerce.Services;
+using Sitecore.Globalization;
+using Sitecore.Commerce.Entities.WishLists;
+using CommerceServer.Core.Runtime.Orders;
+using Sitecore.Commerce.Connect.CommerceServer.Pipelines;
+
+namespace Sitecore.Reference.Storefront.Connect.Pipelines.WishLists
+{
+ ///
+ ///
+ ///
+ public class CreateWishList : WishListPipelineProcessor
+ {
+ ///
+ ///
+ ///
+ ///
+ public override void Process(ServicePipelineArgs args)
+ {
+ try
+ {
+ Assert.ArgumentNotNull(args, "args");
+ Assert.ArgumentNotNull(args.Request, "args.Request");
+ Assert.ArgumentNotNull(args.Result, "args.Result");
+ Assert.IsTrue(args.Request is CreateWishListRequest, "args.Request is CreateWishListRequest");
+ Assert.IsTrue(args.Result is CreateWishListResult, "args.Result is CreateWishListResult");
+
+ var createWishListRequest = (CreateWishListRequest)args.Request;
+ var createWishListResult = (CreateWishListResult)args.Result;
+
+ Assert.IsNotNullOrEmpty(createWishListRequest.UserId, "createWishListRequest.UserId");
+ Assert.IsNotNullOrEmpty(createWishListRequest.ShopName, "createWishListRequest.ShopName");
+ Assert.IsNotNullOrEmpty(createWishListRequest.WishListName, "createWishListRequest.WishListName");
+
+ string userId = createWishListRequest.UserId;
+ string shopName = createWishListRequest.ShopName;
+ string wishListName = Constants.WishListNameBeginning + createWishListRequest.WishListName;
+
+ Guid csUserId;
+ if (!this.ResolveUserId(createWishListRequest.UserId, out csUserId))
+ {
+ createWishListResult.Success = false;
+ SystemMessage systemMessage = new SystemMessage()
+ {
+ Message = Translate.Text("CreateWishList was unable to retrieve user \"{0}\".", (object)createWishListRequest.UserId)
+ };
+ createWishListResult.SystemMessages.Add(systemMessage);
+
+ return;
+ }
+
+ var instance = CommerceTypeLoader.CreateInstance();
+ var basket = instance.GetBasket(csUserId, wishListName);
+ basket.Save();
+ createWishListResult.WishList = this.TranslateBasketToWishList(userId, shopName, basket);
+ }
+ catch (Exception ex)
+ {
+ Log.Error("Unhandled Exception in CreateWishList.", ex, (object)this);
+ args.Result.Success = false;
+ throw;
+ }
+ }
+
+ /// Resolves the user identifier.
+ /// The given user identifier.
+ /// The cs user identifier.
+ /// true if the userId has been resolved; Otherwise false.
+ protected virtual bool ResolveUserId(string givenUserId, out Guid csUserId)
+ {
+ bool flag = Guid.TryParse(givenUserId, out csUserId);
+ if (!flag)
+ {
+ GetProfileArgs getProfileArgs = new GetProfileArgs();
+ getProfileArgs.InputParameters.Name = "UserObject";
+ getProfileArgs.InputParameters.Id = givenUserId;
+ getProfileArgs.InputParameters.Field = CommerceTypeLoader.ConfigurationProvider.CurrentConfiguration.Profiles.SitecoreLinkProperty;
+ CorePipeline.Run("GetProfile", (PipelineArgs)getProfileArgs);
+ Profile commerceProfile = getProfileArgs.OutputParameters.CommerceProfile;
+ if (commerceProfile != null)
+ {
+ csUserId = Guid.Parse(commerceProfile["GeneralInfo.user_id"].Value as string);
+ flag = true;
+ }
+ }
+ return flag;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected virtual WishList TranslateBasketToWishList(string userId, string shopName, Basket basket)
+ {
+ var request = new TranslateOrderGroupToWishListRequest(userId, shopName, basket);
+ var result = PipelineUtility.RunCommerceConnectPipeline(Constants.TranslateOrderGroupToWishList, request);
+ return result.WishList;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Storefront/CS/CSF/Connect/Pipelines/WishLists/GetWishList.cs b/Storefront/CS/CSF/Connect/Pipelines/WishLists/GetWishList.cs
new file mode 100644
index 0000000..c5b2444
--- /dev/null
+++ b/Storefront/CS/CSF/Connect/Pipelines/WishLists/GetWishList.cs
@@ -0,0 +1,85 @@
+using CommerceServer.Core;
+using CommerceServer.Core.Orders;
+using CommerceServer.Core.Runtime.Orders;
+using Sitecore.Commerce.Connect.CommerceServer;
+using Sitecore.Commerce.Connect.CommerceServer.Orders;
+using Sitecore.Commerce.Connect.CommerceServer.Orders.Pipelines;
+using Sitecore.Commerce.Connect.CommerceServer.Pipelines;
+using Sitecore.Commerce.Entities.WishLists;
+using Sitecore.Commerce.Pipelines;
+using Sitecore.Commerce.Pipelines.WishLists.Common;
+using Sitecore.Commerce.Services;
+using Sitecore.Commerce.Services.WishLists;
+using Sitecore.Diagnostics;
+using Sitecore.Globalization;
+using Sitecore.Reference.Storefront.Connect.Pipelines.Utilities;
+using Sitecore.Reference.Storefront.Connect.Pipelines.WishLists;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Globalization;
+using System.Linq;
+using System.Web;
+
+namespace Sitecore.Reference.Storefront.Connect.Pipelines.WishLists
+{
+ ///
+ ///
+ ///
+ public class GetWishList : WishListPipelineProcessor
+ {
+ ///
+ ///
+ ///
+ ///
+ public override void Process(ServicePipelineArgs args)
+ {
+ Assert.ArgumentNotNull((object)args, "args");
+ Assert.ArgumentNotNull((object)args.Request, "args.Request");
+ Assert.ArgumentNotNull((object)args.Result, "args.Result");
+ Assert.IsTrue(args.Request is GetWishListRequest, "args.Request is GetWishListRequest");
+ Assert.IsTrue(args.Result is GetWishListResult, "args.Result is GetWishListResult");
+
+ var request = (GetWishListRequest)args.Request;
+ var result = (GetWishListResult)args.Result;
+
+ Assert.IsNotNullOrEmpty(request.UserId, "getWishListRequest.UserId");
+ Assert.IsNotNullOrEmpty(request.ShopName, "getWishListRequest.ShopName");
+
+ var userId = request.UserId;
+ var shopName = request.ShopName;
+ var wishListId = Guid.Parse(request.WishListId);
+
+ Guid csUserId;
+ if (!UserUtility.ResolveUserId(request.UserId, out csUserId))
+ {
+ result.Success = false;
+ var systemMessage = new SystemMessage()
+ {
+ Message = Translate.Text("GetWishList was unable to retrieve user \"{0}\".", (object)request.UserId)
+ };
+ result.SystemMessages.Add(systemMessage);
+
+ return;
+ }
+
+ var instance = CommerceTypeLoader.CreateInstance();
+ var basket = instance.GetBasket(csUserId, wishListId);
+ result.WishList = this.TranslateBasketToWishList(userId, shopName, basket);
+ }
+
+ ///
+ /// Translates the commerce server basekt to the wish list entity
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected virtual WishList TranslateBasketToWishList(string userId, string shopName, Basket basket)
+ {
+ var request = new TranslateOrderGroupToWishListRequest(userId, shopName, basket);
+ var result = PipelineUtility.RunCommerceConnectPipeline(Constants.TranslateOrderGroupToWishList, request);
+ return result.WishList;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Storefront/CS/CSF/Connect/Pipelines/WishLists/GetWishLists.cs b/Storefront/CS/CSF/Connect/Pipelines/WishLists/GetWishLists.cs
new file mode 100644
index 0000000..982d688
--- /dev/null
+++ b/Storefront/CS/CSF/Connect/Pipelines/WishLists/GetWishLists.cs
@@ -0,0 +1,152 @@
+using Sitecore.Commerce.Pipelines.WishLists.Common;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using Sitecore.Commerce.Pipelines;
+using Sitecore.Diagnostics;
+using Sitecore.Commerce.Services.WishLists;
+using CommerceServer.Core;
+using Sitecore.Commerce.Connect.CommerceServer;
+using CommerceServer.Core.Orders;
+using Sitecore.Commerce.Connect.CommerceServer.Orders.Pipelines;
+using System.Data;
+using Sitecore.Commerce.Services;
+using Sitecore.Commerce.Connect.CommerceServer.Orders;
+using System.Globalization;
+using Sitecore.Commerce.Entities.WishLists;
+using CommerceServer.Core.Runtime.Orders;
+using Sitecore.Reference.Storefront.Connect.Pipelines.Utilities;
+using Sitecore.Globalization;
+using Sitecore.Commerce.Connect.CommerceServer.Pipelines;
+
+namespace Sitecore.Reference.Storefront.Connect.Pipelines.WishLists
+{
+ ///
+ ///
+ ///
+ public class GetWishLists : WishListPipelineProcessor
+ {
+ ///
+ ///
+ ///
+ ///
+ public override void Process(ServicePipelineArgs args)
+ {
+ Assert.ArgumentNotNull((object)args, "args");
+ Assert.ArgumentNotNull((object)args.Request, "args.Request");
+ Assert.ArgumentNotNull((object)args.Result, "args.Result");
+ Assert.IsTrue(args.Request is GetWishListsRequest, "args.Request is GetWishListsRequest");
+ Assert.IsTrue(args.Result is GetWishListsResult, "args.Result is GetWishListsResult");
+
+ var getWishListsRequest = (GetWishListsRequest)args.Request;
+ var getWishListsResult = (GetWishListsResult)args.Result;
+
+ Assert.IsNotNullOrEmpty(getWishListsRequest.UserId, "getWishListsRequest.UserId");
+ Assert.IsNotNullOrEmpty(getWishListsRequest.ShopName, "getWishListsRequest.ShopName");
+
+ var userId = getWishListsRequest.UserId;
+ var shopName = getWishListsRequest.ShopName;
+
+ Guid csUserId;
+ if (!UserUtility.ResolveUserId(getWishListsRequest.UserId, out csUserId))
+ {
+ getWishListsResult.Success = false;
+ var systemMessage = new SystemMessage()
+ {
+ Message = Translate.Text("GetWishLists was unable to retrieve user \"{0}\".", (object)getWishListsRequest.UserId)
+ };
+ getWishListsResult.SystemMessages.Add(systemMessage);
+
+ return;
+ }
+
+ var basketManager = CommerceTypeLoader.CreateInstance().OrderManagementContext.BasketManager;
+
+ var requestInformation = GetCartsRequestInformation.Get((ServiceProviderRequest)getWishListsRequest);
+ var searchableProperties = basketManager.GetSearchableProperties(requestInformation == null || string.IsNullOrWhiteSpace(requestInformation.SearchLanguage) ? "en-us" : requestInformation.SearchLanguage);
+
+ var searchClauseFactory = basketManager.GetSearchClauseFactory(searchableProperties, "Basket");
+ var searchClause = this.PrepareSearchClauses(searchClauseFactory, csUserId);
+
+ var searchOptions = new SearchOptions();
+ searchOptions.PropertiesToReturn = string.Format(
+ (IFormatProvider)CultureInfo.InvariantCulture,
+ "{0},{1}",
+ new object[2]{
+ (object) "OrderGroupId",
+ (object) "SoldToId"
+ }
+ );
+
+ var dataSet = basketManager.SearchBaskets(searchClause, searchOptions);
+
+ if (dataSet == null)
+ {
+ return;
+ }
+
+ var wishLists = new List();
+ foreach (DataRow row in (InternalDataCollectionBase)dataSet.Tables["Baskets"].Rows)
+ {
+ var orderGroupId = (Guid)row["OrderGroupId"];
+ var basket = CommerceTypeLoader.CreateInstance().GetBasket(csUserId, orderGroupId);
+ wishLists.Add(this.TranslateBasketToWishListHeader(userId, shopName, basket));
+ }
+
+ getWishListsResult.WishLists = wishLists.AsReadOnly();
+
+
+ //List wishListList = new List();
+ //foreach (DataRow row in (InternalDataCollectionBase)dataSet.Tables["Baskets"].Rows)
+ //{
+ // Guid orderGroupId = (Guid)row["OrderGroupId"];
+ // Basket basket = CommerceTypeLoader.CreateInstance().GetBasket(csUserId, orderGroupId);
+ // wishListList.Add(this.TranslateBasketToWishList(userId, shopName, basket));
+ //}
+ }
+
+ ///
+ /// Adds the search clauses to the given searchClauseList.
+ ///
+ /// The search clause factory.
+ /// The user id.
+ protected virtual SearchClause PrepareSearchClauses(SearchClauseFactory searchClauseFactory, Guid csUserId)
+ {
+ var userIdClause = searchClauseFactory.CreateClause(ExplicitComparisonOperator.Equal, "SoldToId", csUserId.ToString());
+
+ // I'm not sure if it's more efficient to do this in the search or in memory after retrieving all carts for the sure.
+ var nameClause = searchClauseFactory.CreateClause(ExplicitComparisonOperator.BeginsWith, "Name", Constants.WishListNameBeginning);
+
+ return searchClauseFactory.IntersectClauses(userIdClause, nameClause);
+ }
+
+ ///
+ /// Translates the commerce server basekt to the wish list entity
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected virtual WishListHeader TranslateBasketToWishListHeader(string userId, string shopName, Basket basket)
+ {
+ var request = new TranslateOrderGroupToWishListHeaderRequest(userId, shopName, basket);
+ var result = PipelineUtility.RunCommerceConnectPipeline(Constants.TranslateOrderGroupToWishListHeader, request);
+ return result.WishList;
+ }
+
+ /////
+ ///// Translates the commerce server basekt to the wish list entity
+ /////
+ /////
+ /////
+ /////
+ /////
+ //protected virtual WishList TranslateBasketToWishList(string userId, string shopName, Basket basket)
+ //{
+ // var request = new TranslateOrderGroupToEntityRequest(userId, shopName, basket);
+ // var result = PipelineUtility.RunCommerceConnectPipeline(Constants.TranslateOrderGroupToEntityWishList, request);
+ // return result.WishList;
+ //}
+ }
+}
\ No newline at end of file
diff --git a/Storefront/CS/CSF/Connect/Pipelines/WishLists/TranslateOrderGroupToWishList.cs b/Storefront/CS/CSF/Connect/Pipelines/WishLists/TranslateOrderGroupToWishList.cs
new file mode 100644
index 0000000..57d8fd5
--- /dev/null
+++ b/Storefront/CS/CSF/Connect/Pipelines/WishLists/TranslateOrderGroupToWishList.cs
@@ -0,0 +1,170 @@
+using CommerceServer.Core.Runtime.Orders;
+using Sitecore.Commerce.Connect.CommerceServer.Orders.Models;
+using Sitecore.Commerce.Connect.CommerceServer.Pipelines;
+using Sitecore.Commerce.Entities;
+using Sitecore.Commerce.Entities.Carts;
+using Sitecore.Commerce.Entities.WishLists;
+using Sitecore.Commerce.Pipelines;
+using Sitecore.Commerce.Services;
+using Sitecore.Diagnostics;
+using Sitecore.Globalization;
+using Sitecore.Reference.Storefront.Connect.Pipelines.Utilities;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Web;
+
+namespace Sitecore.Reference.Storefront.Connect.Pipelines.WishLists
+{
+ ///
+ /// Translates the commerce server order group to the wish list entity
+ ///
+ public class TranslateOrderGroupToWishList : CommerceTranslateProcessor
+ {
+ /// Gets the entity factory.
+ /// The entity factory.
+ public IEntityFactory EntityFactory { get; internal set; }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The entity factory.
+ public TranslateOrderGroupToWishList(IEntityFactory entityFactory)
+ {
+ this.EntityFactory = entityFactory;
+ }
+
+ /// Processes the specified arguments.
+ /// The arguments.
+ public override void Process(ServicePipelineArgs args)
+ {
+ Assert.IsNotNull((object)args, "args");
+ Assert.IsNotNull((object)args.Request, "args.Request");
+ Assert.IsNotNull((object)args.Result, "args.Result");
+ Assert.IsTrue(args.Request is TranslateOrderGroupToWishListRequest, "args.Request is TranslateOrderGroupToWishListRequest");
+ Assert.IsTrue(args.Result is TranslateOrderGroupToWishListResult, "args.Result is TranslateOrderGroupToWishListResult");
+
+ TranslateOrderGroupToWishListRequest request = (TranslateOrderGroupToWishListRequest)args.Request;
+ TranslateOrderGroupToWishListResult result = (TranslateOrderGroupToWishListResult)args.Result;
+
+ if (!OrderGroupUtility.ValidOrderGroupForWishList(request, result))
+ {
+ result.Success = false;
+ return;
+ }
+
+ WishList destination = this.EntityFactory.Create("WishList");
+ this.TranslateToWishList(request, request.OrderGroup, destination);
+ ((TranslateOrderGroupToWishListResult)args.Result).WishList = destination;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected virtual void TranslateToWishList(TranslateOrderGroupToWishListRequest request, OrderGroup origin, WishList destination)
+ {
+ this.TranslateCommerceConnectProperties(request, (WishList)destination);
+ destination.Name = origin.Name.Replace(Constants.WishListNameBeginning, "");
+ destination.ExternalId = origin.OrderGroupId.ToString("B");
+ destination.CustomerId = origin.SoldToId.ToString("B");
+ this.MapWeaklyTypedProperties(origin, (Entity)destination);
+ destination.Lines = this.GetTranslatedOrderForms(origin, destination);
+ }
+
+ /// Translates the CommerceConnect properties.
+ /// The request.
+ /// The wish list.
+ protected virtual void TranslateCommerceConnectProperties(TranslateOrderGroupToWishListRequest request, WishList destination)
+ {
+ destination.UserId = request.UserId;
+ destination.ShopName = request.ShopName;
+ }
+
+ ///
+ /// Maps the weakly types properties from a Commerce Server basket to an CommerceConnect entity
+ ///
+ /// the basket to copy from
+ /// the entity to copy to
+ protected virtual void MapWeaklyTypedProperties(OrderGroup origin, Entity destination)
+ {
+ foreach (string key in origin)
+ destination.Properties.Add(key, origin[key]);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected virtual ReadOnlyCollection GetTranslatedOrderForms(OrderGroup orderGroup, WishList destination)
+ {
+ if (orderGroup.OrderForms == null || orderGroup.OrderForms.Count == 0)
+ {
+ return (new List()).AsReadOnly();
+ }
+
+ var origin = orderGroup.OrderForms[0];
+ return this.GetTranslateLineItems(origin);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected virtual ReadOnlyCollection GetTranslateLineItems(OrderForm origin)
+ {
+ List wishListLineList = new List();
+ foreach (LineItem lineItem in origin.LineItems)
+ {
+ WishListLine destination = this.EntityFactory.Create("WishListLine");
+ // destination.ExternalId = lineItem.?;
+ destination.Quantity = (uint)lineItem.Quantity;
+ this.MapWeaklyTypedProperties(lineItem, (Entity)destination);
+ this.AppendCartProduct(lineItem, destination);
+
+ wishListLineList.Add(destination);
+ }
+ return wishListLineList.AsReadOnly();
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected virtual void MapWeaklyTypedProperties(LineItem origin, Entity destination)
+ {
+ foreach (string key in origin)
+ destination.Properties.Add(key, origin[key]);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected virtual void AppendCartProduct(LineItem origin, WishListLine destination)
+ {
+ CommerceCartProduct commerceCartProduct = this.EntityFactory.Create("CartProduct");
+ commerceCartProduct.Description = origin.Description;
+ commerceCartProduct.DisplayName = origin.DisplayName;
+ commerceCartProduct.ProductName = origin.DisplayName;
+ commerceCartProduct.LineNumber = (uint)origin.Index;
+ CommercePrice commercePrice = this.EntityFactory.Create("Price");
+ commercePrice.Amount = origin.PlacedPrice;
+ commercePrice.ListPrice = origin.ListPrice;
+ commerceCartProduct.Price = commercePrice;
+ commerceCartProduct.ProductCatalog = origin.ProductCatalog;
+ commerceCartProduct.ProductCategory = origin.ProductCategory;
+ commerceCartProduct.ProductId = origin.ProductId;
+ commerceCartProduct.ProductVariantId = origin.ProductVariantId;
+ destination.Product = (CartProduct)commerceCartProduct;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Storefront/CS/CSF/Connect/Pipelines/WishLists/TranslateOrderGroupToWishListHeader.cs b/Storefront/CS/CSF/Connect/Pipelines/WishLists/TranslateOrderGroupToWishListHeader.cs
new file mode 100644
index 0000000..fe40f42
--- /dev/null
+++ b/Storefront/CS/CSF/Connect/Pipelines/WishLists/TranslateOrderGroupToWishListHeader.cs
@@ -0,0 +1,86 @@
+using CommerceServer.Core.Runtime.Orders;
+using Sitecore.Commerce.Connect.CommerceServer.Orders.Models;
+using Sitecore.Commerce.Connect.CommerceServer.Pipelines;
+using Sitecore.Commerce.Entities;
+using Sitecore.Commerce.Entities.Carts;
+using Sitecore.Commerce.Entities.WishLists;
+using Sitecore.Commerce.Pipelines;
+using Sitecore.Commerce.Services;
+using Sitecore.Diagnostics;
+using Sitecore.Globalization;
+using Sitecore.Reference.Storefront.Connect.Pipelines.Utilities;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Web;
+
+namespace Sitecore.Reference.Storefront.Connect.Pipelines.WishLists
+{
+ ///
+ /// Translates the commerce server order group to the wish list entity
+ ///
+ public class TranslateOrderGroupToWishListHeader : CommerceTranslateProcessor
+ {
+ /// Gets the entity factory.
+ /// The entity factory.
+ public IEntityFactory EntityFactory { get; internal set; }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The entity factory.
+ public TranslateOrderGroupToWishListHeader(IEntityFactory entityFactory)
+ {
+ this.EntityFactory = entityFactory;
+ }
+
+ /// Processes the specified arguments.
+ /// The arguments.
+ public override void Process(ServicePipelineArgs args)
+ {
+ Assert.IsNotNull((object)args, "args");
+ Assert.IsNotNull((object)args.Request, "args.Request");
+ Assert.IsNotNull((object)args.Result, "args.Result");
+ Assert.IsTrue(args.Request is TranslateOrderGroupToWishListHeaderRequest, "args.Request is TranslateOrderGroupToWishListHeaderRequest");
+ Assert.IsTrue(args.Result is TranslateOrderGroupToWishListHeaderResult, "args.Result is TranslateOrderGroupToWishListHeaderResult");
+
+ TranslateOrderGroupToWishListHeaderRequest request = (TranslateOrderGroupToWishListHeaderRequest)args.Request;
+ TranslateOrderGroupToWishListHeaderResult result = (TranslateOrderGroupToWishListHeaderResult)args.Result;
+
+ if (!OrderGroupUtility.ValidOrderGroupForWishList(request, result))
+ {
+ result.Success = false;
+ return;
+ }
+
+ WishListHeader destination = this.EntityFactory.Create("WishListHeader");
+ this.TranslateToWishListHeader(request, request.OrderGroup, destination);
+ ((TranslateOrderGroupToWishListHeaderResult)args.Result).WishList = destination;
+ }
+
+ /// Translates properties.
+ /// The request.
+ /// The order group
+ /// The wish list header
+ protected virtual void TranslateToWishListHeader(TranslateOrderGroupToWishListHeaderRequest request, OrderGroup origin, WishListHeader destination)
+ {
+ destination.Name = origin.Name.Replace(Constants.WishListNameBeginning, "");
+ destination.ExternalId = origin.OrderGroupId.ToString("B");
+ destination.ShopName = request.ShopName;
+ destination.CustomerId = origin.SoldToId.ToString("B");
+ this.MapWeaklyTypedProperties(origin, (Entity)destination);
+ }
+
+ ///
+ /// Maps the weakly types properties from a Commerce Server basket to an CommerceConnect entity
+ ///
+ /// the basket to copy from
+ /// the entity to copy to
+ protected virtual void MapWeaklyTypedProperties(OrderGroup origin, Entity destination)
+ {
+ foreach (string key in origin)
+ destination.Properties.Add(key, origin[key]);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Storefront/CS/CSF/Connect/Pipelines/WishLists/TranslateOrderGroupToWishListHeaderRequest.cs b/Storefront/CS/CSF/Connect/Pipelines/WishLists/TranslateOrderGroupToWishListHeaderRequest.cs
new file mode 100644
index 0000000..97d26f4
--- /dev/null
+++ b/Storefront/CS/CSF/Connect/Pipelines/WishLists/TranslateOrderGroupToWishListHeaderRequest.cs
@@ -0,0 +1,60 @@
+using CommerceServer.Core.Runtime.Orders;
+using Sitecore.Commerce.Connect.CommerceServer.Pipelines;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace Sitecore.Reference.Storefront.Connect.Pipelines.WishLists
+{
+
+ ///
+ ///
+ ///
+ public class TranslateOrderGroupToWishListHeaderRequest : TranslateOrderGroupRequest
+ {
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public TranslateOrderGroupToWishListHeaderRequest(string userId, string shopName, OrderGroup orderGroup)
+ : base(userId, shopName, orderGroup) { }
+ }
+
+ ///
+ ///
+ ///
+ public class TranslateOrderGroupRequest : CommerceRequest
+ {
+ ///
+ ///
+ ///
+ public string UserId { get; set; }
+
+ ///
+ ///
+ ///
+ public string ShopName { get; set; }
+
+ ///
+ ///
+ ///
+ public OrderGroup OrderGroup { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public TranslateOrderGroupRequest(string userId, string shopName, OrderGroup orderGroup)
+ {
+ this.UserId = userId;
+ this.ShopName = shopName;
+ this.OrderGroup = orderGroup;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Storefront/CS/CSF/Connect/Pipelines/WishLists/TranslateOrderGroupToWishListHeaderResult.cs b/Storefront/CS/CSF/Connect/Pipelines/WishLists/TranslateOrderGroupToWishListHeaderResult.cs
new file mode 100644
index 0000000..a568495
--- /dev/null
+++ b/Storefront/CS/CSF/Connect/Pipelines/WishLists/TranslateOrderGroupToWishListHeaderResult.cs
@@ -0,0 +1,36 @@
+using Sitecore.Commerce.Connect.CommerceServer.Pipelines;
+using Sitecore.Commerce.Entities.WishLists;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace Sitecore.Reference.Storefront.Connect.Pipelines.WishLists
+{
+ ///
+ ///
+ ///
+ public class TranslateOrderGroupToWishListHeaderResult : CommerceResult
+ {
+ ///
+ ///
+ ///
+ public WishListHeader WishList { get; set; }
+
+ ///
+ ///
+ ///
+ public TranslateOrderGroupToWishListHeaderResult()
+ {
+ }
+
+ ///
+ ///
+ ///
+ ///
+ public TranslateOrderGroupToWishListHeaderResult(WishListHeader wishList)
+ {
+ this.WishList = wishList;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Storefront/CS/CSF/Connect/Pipelines/WishLists/TranslateOrderGroupToWishListRequest.cs b/Storefront/CS/CSF/Connect/Pipelines/WishLists/TranslateOrderGroupToWishListRequest.cs
new file mode 100644
index 0000000..1bb910f
--- /dev/null
+++ b/Storefront/CS/CSF/Connect/Pipelines/WishLists/TranslateOrderGroupToWishListRequest.cs
@@ -0,0 +1,24 @@
+using CommerceServer.Core.Runtime.Orders;
+using Sitecore.Commerce.Connect.CommerceServer.Pipelines;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace Sitecore.Reference.Storefront.Connect.Pipelines.WishLists
+{
+ ///
+ ///
+ ///
+ public class TranslateOrderGroupToWishListRequest : TranslateOrderGroupRequest
+ {
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public TranslateOrderGroupToWishListRequest(string userId, string shopName, OrderGroup orderGroup)
+ : base(userId, shopName, orderGroup) { }
+ }
+}
\ No newline at end of file
diff --git a/Storefront/CS/CSF/Connect/Pipelines/WishLists/TranslateOrderGroupToWishListResult.cs b/Storefront/CS/CSF/Connect/Pipelines/WishLists/TranslateOrderGroupToWishListResult.cs
new file mode 100644
index 0000000..4d6c2c2
--- /dev/null
+++ b/Storefront/CS/CSF/Connect/Pipelines/WishLists/TranslateOrderGroupToWishListResult.cs
@@ -0,0 +1,36 @@
+using Sitecore.Commerce.Connect.CommerceServer.Pipelines;
+using Sitecore.Commerce.Entities.WishLists;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace Sitecore.Reference.Storefront.Connect.Pipelines.WishLists
+{
+ ///
+ ///
+ ///
+ public class TranslateOrderGroupToWishListResult : CommerceResult
+ {
+ ///
+ ///
+ ///
+ public WishList WishList { get; set; }
+
+ ///
+ ///
+ ///
+ public TranslateOrderGroupToWishListResult()
+ {
+ }
+
+ ///
+ ///
+ ///
+ ///
+ public TranslateOrderGroupToWishListResult(WishList wishList)
+ {
+ this.WishList = wishList;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Storefront/CS/CSF/Controllers/AccountController.cs b/Storefront/CS/CSF/Controllers/AccountController.cs
index 59a52f5..1190047 100644
--- a/Storefront/CS/CSF/Controllers/AccountController.cs
+++ b/Storefront/CS/CSF/Controllers/AccountController.cs
@@ -400,6 +400,7 @@ public ActionResult MyOrder(string id)
/// Recent Orders PlugIn for Account Management Home Page
///
/// The view to display recent orders
+ [SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
[HttpPost]
[Authorize]
[ValidateJsonAntiForgeryToken]
diff --git a/Storefront/CS/CSF/Controllers/WishListController.cs b/Storefront/CS/CSF/Controllers/WishListController.cs
new file mode 100644
index 0000000..5c4f54b
--- /dev/null
+++ b/Storefront/CS/CSF/Controllers/WishListController.cs
@@ -0,0 +1,485 @@
+//-----------------------------------------------------------------------
+//
+// Copyright (c) Sitecore Corporation 1999-2016
+//
+// Defines the WishListController class.
+//-----------------------------------------------------------------------
+// Copyright 2016 Sitecore Corporation A/S
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+// except in compliance with the License. You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software distributed under the
+// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+// either express or implied. See the License for the specific language governing permissions
+// and limitations under the License.
+// -------------------------------------------------------------------------------------------
+
+namespace Sitecore.Reference.Storefront.Controllers
+{
+ using Sitecore;
+ using Sitecore.Commerce.Connect.CommerceServer;
+ using Sitecore.Commerce.Contacts;
+ using Sitecore.Commerce.Entities.WishLists;
+ using Sitecore.Diagnostics;
+ using Sitecore.Reference.Storefront.Managers;
+ using Sitecore.Reference.Storefront.Models.InputModels;
+ using Sitecore.Reference.Storefront.Models.JsonResults;
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Web.Mvc;
+ using Sitecore.Reference.Storefront.ExtensionMethods;
+ using Sitecore.Reference.Storefront.Infrastructure;
+
+ ///
+ /// Used to handle all Wish List Actions
+ ///
+ public class WishListController : CSBaseController
+ {
+ #region Properties
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The inventory manager.
+ /// The account manager.
+ /// The wish list manager.
+ /// The contact factory.
+ public WishListController(
+ [NotNull] AccountManager accountManager,
+ [NotNull] WishListManager wishListManager,
+ [NotNull] ContactFactory contactFactory)
+ : base(accountManager, contactFactory)
+ {
+ Assert.ArgumentNotNull(contactFactory, "contactFactory");
+ Assert.ArgumentNotNull(wishListManager, "wishListManager");
+
+ this.WishListManager = wishListManager;
+ }
+
+ ///
+ /// Gets or sets the wish list manager.
+ ///
+ ///
+ /// The wish list manager.
+ ///
+ public WishListManager WishListManager { get; protected set; }
+
+ #endregion
+
+ #region Controller actions
+
+ ///
+ /// Main controller action
+ ///
+ /// My wish lists view
+ [HttpGet]
+ public override ActionResult Index()
+ {
+ if (!Context.User.IsAuthenticated)
+ {
+ return Redirect("/login");
+ }
+
+ return View(this.CurrentRenderingView);
+ }
+
+ ///
+ /// View a Wish List based on it's Id
+ ///
+ /// The Id of the Wish List
+ ///
+ /// Returns the view with wish lists details
+ ///
+ [HttpGet]
+ public ActionResult ViewWishList(string id)
+ {
+ if (!Context.User.IsAuthenticated)
+ {
+ return Redirect("/login");
+ }
+
+ return View(this.CurrentRenderingView);
+ }
+
+ ///
+ /// Show Active Wish Lists
+ ///
+ /// if set to true [filter].
+ ///
+ /// Returns active wish lists
+ ///
+ [HttpPost]
+ [Authorize]
+ [ValidateJsonAntiForgeryToken]
+ public JsonResult ActiveWishLists(bool filter = false)
+ {
+ try
+ {
+ var wishLists = new List();
+ var userResponse = this.AccountManager.GetUser(Context.User.Name);
+ var result = new WishListsBaseJsonResult(userResponse.ServiceProviderResult);
+ if (userResponse.ServiceProviderResult.Success && userResponse.Result != null)
+ {
+ wishLists = filter ? this.WishListsHeaders(result).Take(5).ToList() : this.WishListsHeaders(result);
+ }
+
+ result.Initialize(wishLists);
+ return Json(result, JsonRequestBehavior.AllowGet);
+ }
+ catch (Exception e)
+ {
+ CommerceLog.Current.Error("ActiveWishLists", this, e);
+ return Json(new BaseJsonResult("ActiveWishLists", e), JsonRequestBehavior.AllowGet);
+ }
+ }
+
+ ///
+ /// Gets the wish lists.
+ ///
+ /// The model.
+ ///
+ /// A wish list
+ ///
+ [HttpPost]
+ [Authorize]
+ [ValidateJsonAntiForgeryToken]
+ public JsonResult GetWishList(WishListInputModel model)
+ {
+ try
+ {
+ Assert.ArgumentNotNull(model, "model");
+
+ var validationResult = new BaseJsonResult();
+ this.ValidateModel(validationResult);
+ if (validationResult.HasErrors)
+ {
+ return Json(validationResult, JsonRequestBehavior.AllowGet);
+ }
+
+ var userResponse = this.AccountManager.GetUser(Context.User.Name);
+ var result = new WishListBaseJsonResult(userResponse.ServiceProviderResult);
+ if (userResponse.ServiceProviderResult.Success && userResponse.Result != null)
+ {
+ this.WishList(model.ExternalId, result);
+ }
+
+ return Json(result, JsonRequestBehavior.AllowGet);
+ }
+ catch (Exception e)
+ {
+ CommerceLog.Current.Error("GetWishList", this, e);
+ return Json(new BaseJsonResult("GetWishList", e), JsonRequestBehavior.AllowGet);
+ }
+ }
+
+ ///
+ /// Create Wish List
+ ///
+ /// The model.
+ ///
+ /// Creates wish list
+ ///
+ [HttpPost]
+ [Authorize]
+ [ValidateJsonAntiForgeryToken]
+ public JsonResult CreateWishList(CreateWishListInputModel model)
+ {
+ try
+ {
+ Assert.ArgumentNotNull(model, "model");
+
+ var validationResult = new BaseJsonResult();
+ this.ValidateModel(validationResult);
+ if (validationResult.HasErrors)
+ {
+ return Json(validationResult, JsonRequestBehavior.AllowGet);
+ }
+
+ var wishLists = new List();
+ var response = this.WishListManager.CreateWishList(this.CurrentStorefront, this.CurrentVisitorContext, model.Name);
+ var result = new WishListsBaseJsonResult(response.ServiceProviderResult);
+ if (response.ServiceProviderResult.Success && response.Result != null)
+ {
+ wishLists = this.WishListsHeaders(result);
+ }
+
+ result.Initialize(wishLists);
+ return Json(result, JsonRequestBehavior.AllowGet);
+ }
+ catch (Exception e)
+ {
+ CommerceLog.Current.Error("CreateWishList", this, e);
+ return Json(new BaseJsonResult("CreateWishList", e), JsonRequestBehavior.AllowGet);
+ }
+ }
+
+ ///
+ /// Deletes the wish list.
+ ///
+ /// The model.
+ ///
+ /// Deletes wish list
+ ///
+ [HttpPost]
+ [Authorize]
+ [ValidateJsonAntiForgeryToken]
+ public JsonResult DeleteWishList(WishListInputModel model)
+ {
+ try
+ {
+ Assert.ArgumentNotNull(model, "model");
+
+ var validationResult = new BaseJsonResult();
+ this.ValidateModel(validationResult);
+ if (validationResult.HasErrors)
+ {
+ return Json(validationResult, JsonRequestBehavior.AllowGet);
+ }
+
+ var wishLists = new List();
+ var response = this.WishListManager.DeleteWishList(this.CurrentStorefront, this.CurrentVisitorContext, model.ExternalId);
+ var result = new WishListsBaseJsonResult(response.ServiceProviderResult);
+ if (response.ServiceProviderResult.Success)
+ {
+ wishLists = this.WishListsHeaders(result);
+ }
+
+ result.Initialize(wishLists);
+ return Json(result, JsonRequestBehavior.AllowGet);
+ }
+ catch (Exception e)
+ {
+ CommerceLog.Current.Error("DeleteWishList", this, e);
+ return Json(new BaseJsonResult("DeleteWishList", e), JsonRequestBehavior.AllowGet);
+ }
+ }
+
+ ///
+ /// Add the wish lists to the cart.
+ ///
+ /// The models.
+ ///
+ /// The Json result.
+ ///
+ [HttpPost]
+ [Authorize]
+ [ValidateJsonAntiForgeryToken]
+ public JsonResult AddWishListsToCart(List models)
+ {
+ try
+ {
+ Assert.ArgumentNotNull(models, "models");
+
+ var validationResult = new BaseJsonResult();
+ this.ValidateModel(validationResult);
+ if (validationResult.HasErrors)
+ {
+ return Json(validationResult, JsonRequestBehavior.AllowGet);
+ }
+
+ var wishLists = new List();
+
+ //// TODO: ADD ALL THE ITEMS ON EACH WISH LIST TO THE CART
+
+ var result = new WishListsBaseJsonResult();
+ result.Initialize(wishLists);
+ return Json(result, JsonRequestBehavior.AllowGet);
+ }
+ catch (Exception e)
+ {
+ CommerceLog.Current.Error("AddWishListsToCart", this, e);
+ return Json(new BaseJsonResult("AddWishListsToCart", e), JsonRequestBehavior.AllowGet);
+ }
+ }
+
+ ///
+ /// Updates the wish list.
+ ///
+ /// The model.
+ ///
+ /// Updates wish list
+ ///
+ [HttpPost]
+ [Authorize]
+ [ValidateJsonAntiForgeryToken]
+ public JsonResult UpdateWishList(UpdateWishListInputModel model)
+ {
+ try
+ {
+ Assert.ArgumentNotNull(model, "model");
+
+ var validationResult = new BaseJsonResult();
+ this.ValidateModel(validationResult);
+ if (validationResult.HasErrors)
+ {
+ return Json(validationResult, JsonRequestBehavior.AllowGet);
+ }
+
+ var wishLists = new List();
+ var response = this.WishListManager.UpdateWishList(this.CurrentStorefront, this.CurrentVisitorContext, model);
+ var result = new WishListsBaseJsonResult(response.ServiceProviderResult);
+ if (response.ServiceProviderResult.Success && response.Result != null)
+ {
+ wishLists = this.WishListsHeaders(result);
+ }
+
+ result.Initialize(wishLists);
+ return Json(result, JsonRequestBehavior.AllowGet);
+ }
+ catch (Exception e)
+ {
+ CommerceLog.Current.Error("UpdateWishList", this, e);
+ return Json(new BaseJsonResult("UpdateWishList", e), JsonRequestBehavior.AllowGet);
+ }
+ }
+
+ ///
+ /// Adds to wish list.
+ ///
+ /// The view model.
+ ///
+ /// true if the product was added
+ ///
+ [HttpPost]
+ [Authorize]
+ [ValidateJsonAntiForgeryToken]
+ public JsonResult AddToWishList(AddToWishListInputModel model)
+ {
+ try
+ {
+ Assert.ArgumentNotNull(model, "model");
+
+ var validationResult = new BaseJsonResult();
+ this.ValidateModel(validationResult);
+ if (validationResult.HasErrors)
+ {
+ return Json(validationResult, JsonRequestBehavior.AllowGet);
+ }
+
+ var wishLists = new List();
+ var response = this.WishListManager.AddLinesToWishList(this.CurrentStorefront, this.CurrentVisitorContext, model);
+ var result = new WishListsBaseJsonResult(response.ServiceProviderResult);
+ if (response.ServiceProviderResult.Success && response.Result != null)
+ {
+ wishLists = this.WishListsHeaders(result);
+ }
+
+ result.Initialize(wishLists);
+ return Json(result, JsonRequestBehavior.AllowGet);
+ }
+ catch (Exception e)
+ {
+ CommerceLog.Current.Error("AddToWishList", this, e);
+ return Json(new BaseJsonResult("AddToWishList", e), JsonRequestBehavior.AllowGet);
+ }
+ }
+
+ ///
+ /// Deletes the wish list line item.
+ ///
+ /// The model.
+ /// Returns json result with delete line item operation status
+ [HttpPost]
+ [Authorize]
+ [ValidateJsonAntiForgeryToken]
+ public JsonResult DeleteLineItem(WishListLineInputModel model)
+ {
+ try
+ {
+ Assert.ArgumentNotNull(model, "model");
+
+ var validationResult = new BaseJsonResult();
+ this.ValidateModel(validationResult);
+ if (validationResult.HasErrors)
+ {
+ return Json(validationResult, JsonRequestBehavior.AllowGet);
+ }
+
+ var response = this.WishListManager.RemoveWishListLines(this.CurrentStorefront, this.CurrentVisitorContext, model.WishListId, new List { model });
+ var result = new WishListBaseJsonResult(response.ServiceProviderResult);
+ if (response.ServiceProviderResult.Success)
+ {
+ this.WishList(model.WishListId, result);
+ }
+
+ return Json(result, JsonRequestBehavior.AllowGet);
+ }
+ catch (Exception e)
+ {
+ CommerceLog.Current.Error("DeleteLineItem", this, e);
+ return Json(new BaseJsonResult("DeleteLineItem", e), JsonRequestBehavior.AllowGet);
+ }
+ }
+
+ ///
+ /// Updates the wish list line item.
+ ///
+ /// The model.
+ /// Returns the view with update wish list
+ [HttpPost]
+ [Authorize]
+ [ValidateJsonAntiForgeryToken]
+ public ActionResult UpdateLineItem(WishListLineInputModel model)
+ {
+ try
+ {
+ Assert.ArgumentNotNull(model, "model");
+
+ var validationResult = new BaseJsonResult();
+ this.ValidateModel(validationResult);
+ if (validationResult.HasErrors)
+ {
+ return Json(validationResult, JsonRequestBehavior.AllowGet);
+ }
+
+ var response = this.WishListManager.UpdateWishListLine(this.CurrentStorefront, this.CurrentVisitorContext, model);
+ var result = new WishListBaseJsonResult(response.ServiceProviderResult);
+ if (response.ServiceProviderResult.Success && response.Result != null)
+ {
+ this.WishList(model.WishListId, result);
+ }
+
+ return Json(result, JsonRequestBehavior.AllowGet);
+ }
+ catch (Exception e)
+ {
+ CommerceLog.Current.Error("UpdateLineItem", this, e);
+ return Json(new BaseJsonResult("UpdateLineItem", e), JsonRequestBehavior.AllowGet);
+ }
+ }
+
+ #endregion
+
+ #region Helpers
+
+ private void WishList(string wishListId, WishListBaseJsonResult result)
+ {
+ var response = this.WishListManager.GetWishList(this.CurrentStorefront, this.CurrentVisitorContext, wishListId);
+ var wishList = new WishList();
+ if (response.ServiceProviderResult.Success && response.Result != null)
+ {
+ wishList = response.Result;
+ }
+
+ result.Initialize(wishList);
+ result.SetErrors(response.ServiceProviderResult);
+ }
+
+ private List WishListsHeaders(WishListsBaseJsonResult result)
+ {
+ var response = this.WishListManager.GetWishLists(this.CurrentStorefront, this.CurrentVisitorContext);
+ var wishLists = new List();
+ if (response.ServiceProviderResult.Success && response.Result != null)
+ {
+ wishLists = response.Result.ToList();
+ }
+
+ result.SetErrors(response.ServiceProviderResult);
+ return wishLists;
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/Storefront/CS/CSF/Managers/WishListManager.cs b/Storefront/CS/CSF/Managers/WishListManager.cs
index 5da49c1..f1a2d74 100644
--- a/Storefront/CS/CSF/Managers/WishListManager.cs
+++ b/Storefront/CS/CSF/Managers/WishListManager.cs
@@ -28,6 +28,7 @@ namespace Sitecore.Reference.Storefront.Managers
using System.Collections.Generic;
using System.Linq;
using Sitecore.Commerce.Entities.Inventory;
+ using Commerce.Entities.Prices;
///
/// Defines the WishListManager class.
@@ -304,7 +305,11 @@ public WishListManager([NotNull] WishListServiceProvider wishListServiceProvider
{
ProductCatalog = model.ProductCatalog,
ProductId = model.ProductId,
- ProductVariantId = model.VariantId
+ ProductVariantId = model.VariantId,
+ Price = new Price
+ {
+ Amount = 0
+ }
};
var line = new WishListLine
@@ -384,8 +389,8 @@ protected virtual void PopulateStockInformation(CommerceStorefront storefront, W
{
continue;
}
-
- line.Product.StockStatus = new Sitecore.Commerce.Entities.Inventory.StockStatus(Convert.ToInt32((decimal)stockInfo.Properties["OnHandQuantity"]), stockInfo.Status.Name);
+
+ line.Product.StockStatus = stockInfo.Status;
this.InventoryManager.VisitedProductStockStatus(storefront, stockInfo, string.Empty);
}
}
diff --git a/Storefront/CS/CSF/Properties/PublishProfiles/DynamicsRetail.pubxml b/Storefront/CS/CSF/Properties/PublishProfiles/localhost.pubxml
similarity index 55%
rename from Storefront/CS/CSF/Properties/PublishProfiles/DynamicsRetail.pubxml
rename to Storefront/CS/CSF/Properties/PublishProfiles/localhost.pubxml
index b9e5cf6..59e3247 100644
--- a/Storefront/CS/CSF/Properties/PublishProfiles/DynamicsRetail.pubxml
+++ b/Storefront/CS/CSF/Properties/PublishProfiles/localhost.pubxml
@@ -5,19 +5,13 @@ by editing this MSBuild file. In order to learn more about this please visit htt
-->
- MSDeploy
- Release
+ FileSystem
+ Debug
Any CPU
True
False
- localhost
- cssitecore
-
- True
- InProc
- False
-
- <_SavePWD>False
+ http://csDemo/
+ False
\ No newline at end of file
diff --git a/Storefront/CS/CSF/web.Debug.config b/Storefront/CS/CSF/web.Debug.config
deleted file mode 100644
index 9a35eae..0000000
--- a/Storefront/CS/CSF/web.Debug.config
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Storefront/CS/CSF/web.Release.config b/Storefront/CS/CSF/web.Release.config
deleted file mode 100644
index c77c9c7..0000000
--- a/Storefront/CS/CSF/web.Release.config
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Storefront/CS/CSF/web.config b/Storefront/CS/CSF/web.config
deleted file mode 100644
index cec54a0..0000000
--- a/Storefront/CS/CSF/web.config
+++ /dev/null
@@ -1,96 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Storefront/Common/CommonSettings/CommonSettings.csproj b/Storefront/Common/CommonSettings/CommonSettings.csproj
index be40748..3310a4f 100644
--- a/Storefront/Common/CommonSettings/CommonSettings.csproj
+++ b/Storefront/Common/CommonSettings/CommonSettings.csproj
@@ -28,6 +28,7 @@
+
true
@@ -102,6 +103,7 @@
Designer
+
@@ -158,7 +160,6 @@
-
@@ -254,12 +255,6 @@
-
- web.config
-
-
- web.config
-
10.0
diff --git a/Storefront/Common/CommonSettings/Properties/PublishProfiles/localhost.pubxml b/Storefront/Common/CommonSettings/Properties/PublishProfiles/localhost.pubxml
new file mode 100644
index 0000000..59e3247
--- /dev/null
+++ b/Storefront/Common/CommonSettings/Properties/PublishProfiles/localhost.pubxml
@@ -0,0 +1,17 @@
+
+
+
+
+ FileSystem
+ Debug
+ Any CPU
+
+ True
+ False
+ http://csDemo/
+ False
+
+
\ No newline at end of file
diff --git a/Storefront/Common/CommonSettings/web.Debug.config b/Storefront/Common/CommonSettings/web.Debug.config
deleted file mode 100644
index 9a35eae..0000000
--- a/Storefront/Common/CommonSettings/web.Debug.config
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Storefront/Common/CommonSettings/web.Release.config b/Storefront/Common/CommonSettings/web.Release.config
deleted file mode 100644
index c77c9c7..0000000
--- a/Storefront/Common/CommonSettings/web.Release.config
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Storefront/Common/CommonSettings/web.config b/Storefront/Common/CommonSettings/web.config
deleted file mode 100644
index 208a0af..0000000
--- a/Storefront/Common/CommonSettings/web.config
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Storefront/Common/Project/Models/JsonResults/WishListItemBaseJsonResult.cs b/Storefront/Common/Project/Models/JsonResults/WishListItemBaseJsonResult.cs
index 55ae38e..788f34e 100644
--- a/Storefront/Common/Project/Models/JsonResults/WishListItemBaseJsonResult.cs
+++ b/Storefront/Common/Project/Models/JsonResults/WishListItemBaseJsonResult.cs
@@ -48,9 +48,9 @@ public WishListItemBaseJsonResult(WishListLine line, string wishListId)
this.DisplayName = product.DisplayName;
this.Color = product.Properties["Color"] as string;
- this.LineDiscount = ((CommerceTotal)line.Total).LineItemDiscountAmount.ToString(Sitecore.Context.Language.CultureInfo);
+ //this.LineDiscount = ((CommerceTotal)line.Total).LineItemDiscountAmount.ToString(Sitecore.Context.Language.CultureInfo);
this.Quantity = line.Quantity.ToString(Sitecore.Context.Language.CultureInfo);
- this.LineTotal = line.Total.Amount.ToCurrency(currencyCode);
+ //this.LineTotal = line.Total.Amount.ToCurrency(currencyCode);
this.ExternalLineId = line.ExternalId;
this.ProductId = product.ProductId;
this.VariantId = product.ProductVariantId;