// // GET: /Wishlist/ public ActionResult Index() { var context = new IPTV2Entities(); Product product = context.Products.FirstOrDefault(p => p.ProductId == 1 && p.OfferingId == GlobalConfig.offeringId && p.StatusId == GlobalConfig.Visible); Wishlist wishlist = new Wishlist() { UID_s = User.Identity.Name, registDt_d = DateTime.Now.ToString("s"), ProductId_i = product.ProductId, ProductName_s = product.Description }; WishlistModel model = new WishlistModel() { type = "Wishlist", data = wishlist }; string wishlist_json = JsonConvert.SerializeObject(model); return Content(wishlist_json, "application/json"); }
public ActionResult Add(int? id) { Dictionary<string, object> collection = new Dictionary<string, object>(); ErrorCodes errorCode = ErrorCodes.UnknownError; string errorMessage = "ERROR"; collection = MyUtility.setError(errorCode, errorMessage); if (id != null) { if (!IsWishlisted((int)id)) { if (!User.Identity.IsAuthenticated) { collection = MyUtility.setError(ErrorCodes.NotAuthenticated, "NOT AUTHENTICATED"); return Content(MyUtility.buildJson(collection), "application/json"); } var context = new IPTV2Entities(); Product product = context.Products.FirstOrDefault(p => p.ProductId == id && p.OfferingId == GlobalConfig.offeringId && p.StatusId == GlobalConfig.Visible); if (product != null) { Wishlist wishlist = new Wishlist() { UID_s = User.Identity.Name, registDt_d = DateTime.Now.ToString("s"), ProductId_i = product.ProductId, ProductName_s = product.Description }; WishlistModel model = new WishlistModel() { type = "Wishlist", data = wishlist }; string wishlist_json = JsonConvert.SerializeObject(model); GSResponse res = GigyaHelpers.createAndSendRequest("gcs.setObjectData", new GSObject(wishlist_json)); if (res.GetErrorCode() == 0) { //Publish user action List<ActionLink> actionlinks = new List<ActionLink>(); actionlinks.Add(new ActionLink() { text = SNSTemplates.actionlink_text, href = String.Format("{0}{1}", GlobalConfig.baseUrl, String.Format(SNSTemplates.wishlist_actionlink_href, User.Identity.Name)) }); List<MediaItem> mediaItems = new List<MediaItem>(); mediaItems.Add(new MediaItem() { type = SNSTemplates.wishlist_mediaitem_type, src = String.Format("{0}{1}", GlobalConfig.AssetsBaseUrl, SNSTemplates.wishlist_mediaitem_src), href = String.Format("{0}{1}", GlobalConfig.baseUrl, String.Format(SNSTemplates.wishlist_mediaitem_href, User.Identity.Name)) }); string gender = GigyaMethods.GetUserInfoByKey(new System.Guid(User.Identity.Name), "gender"); UserAction action = new UserAction() { actorUID = User.Identity.Name, userMessage = String.Format(SNSTemplates.wishlist_usermessage, product.Description, gender == "f" ? "her" : "his"), title = SNSTemplates.wishlist_title, subtitle = String.Format("{0}{1}", GlobalConfig.baseUrl, String.Format(SNSTemplates.wishlist_subtitle, User.Identity.Name)), linkBack = String.Format("{0}{1}", GlobalConfig.baseUrl, String.Format(SNSTemplates.wishlist_linkback, User.Identity.Name)), description = SNSTemplates.wishlist_description, actionLinks = actionlinks, mediaItems = mediaItems }; var userId = new Guid(User.Identity.Name); var userData = MyUtility.GetUserPrivacySetting(userId); if (userData.IsExternalSharingEnabled.Contains("true")) GigyaMethods.PublishUserAction(action, userId, "external"); //Modify action to suit Internal feed needs mediaItems.Clear(); mediaItems.Add(new MediaItem() { type = SNSTemplates.wishlist_mediaitem_type, src = String.Format("{0}{1}", GlobalConfig.AssetsBaseUrl, SNSTemplates.wishlist_mediaitem_src_internal), href = String.Format("{0}{1}", GlobalConfig.baseUrl, String.Format(SNSTemplates.wishlist_mediaitem_href, User.Identity.Name)) }); action.description = SNSTemplates.wishlist_description_internal; action.mediaItems = mediaItems; if (userData.IsInternalSharingEnabled.Contains("true")) GigyaMethods.PublishUserAction(action, userId, "internal"); } return Content(res.GetData().ToJsonString(), "application/json"); } } else { errorCode = ErrorCodes.WishlistItemExists; errorMessage = "ALREADY EXISTS"; collection = MyUtility.setError(errorCode, errorMessage); } } return Content(MyUtility.buildJson(collection), "application/json"); }