Beispiel #1
0
        internal static CartList GetCart(int uniqueId, bool isShoppingCart)
        {
            CartList list = null;

            try
            {
                list = DataPortal.FetchChild <CartList>(new CartCriteria {
                    UniqueID = uniqueId, IsShoppingCart = isShoppingCart
                });
            }
            catch (Exception)
            {
                list = CartList.NewListAsync().Result;
            }

            return(list);
        }
Beispiel #2
0
        /// <summary>
        /// Returns the collection of settings property values for the specified application instance and settings property group.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.Configuration.SettingsPropertyValueCollection"/> containing the values for the specified settings property group.
        /// </returns>
        /// <param name="context">A <see cref="T:System.Configuration.SettingsContext"/> describing the current application use.
        ///                 </param><param name="collection">A <see cref="T:System.Configuration.SettingsPropertyCollection"/> containing the settings property group whose values are to be retrieved.
        ///                 </param><filterpriority>2</filterpriority>
        public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection collection)
        {
            var     username        = (string)context["UserName"];
            var     isAuthenticated = (bool)context["IsAuthenticated"];
            Profile profile         = ProfileManager.Instance.GetCurrentUser(username);

            var svc = new SettingsPropertyValueCollection();

            foreach (SettingsProperty prop in collection)
            {
                var pv = new SettingsPropertyValue(prop);

                switch (pv.Property.Name)
                {
                case _PROFILE_SHOPPINGCART:
                    pv.PropertyValue = CartList.GetCart(profile.UniqueID, true);
                    break;

                case _PROFILE_WISHLIST:
                    pv.PropertyValue = CartList.GetCart(profile.UniqueID, false);
                    break;

                case _PROFILE_ACCOUNT:
                    if (isAuthenticated)
                    {
                        pv.PropertyValue = new Address(profile);
                    }
                    break;

                default:
                    throw new ApplicationException(string.Format("{0} name.", _ERR_INVALID_PARAMETER));
                }

                svc.Add(pv);
            }
            return(svc);
        }