Example #1
0
        /// <summary>
        /// When a row gets created, a bunch of controls in it are maniuplated depending on context
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvUserCarts_RowCreated(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType != DataControlRowType.DataRow)
            {
                return;
            }
            Mediachase.Commerce.Orders.Cart cart = e.Row.DataItem as Mediachase.Commerce.Orders.Cart;

            HyperLink  hlDeleteCart = e.Row.FindControl("hlDeleteCart") as HyperLink;
            HyperLink  hlEditCart   = e.Row.FindControl("hlEditCart") as HyperLink;
            HyperLink  hlCopyCArt   = e.Row.FindControl("hlCopyCart") as HyperLink;
            LinkButton lbGoToCart   = e.Row.FindControl("lbGoToCart") as LinkButton;

            if (((Mediachase.Commerce.Orders.Cart)e.Row.DataItem).Name == NWTD.Profile.ActiveCart)
            {
                e.Row.CssClass = e.Row.CssClass + " active-cart";
                RadioButton rbActiveCart = e.Row.FindControl("rbActiveCart") as RadioButton;
                hlDeleteCart.Visible = false;
                rbActiveCart.Checked = true;
            }
            else
            {
                hlDeleteCart.Visible = true;
            }

            if (!NWTD.Orders.Cart.CartCanBeEdited(cart))
            {
                hlDeleteCart.Visible = false;
                hlEditCart.Visible   = false;
                hlCopyCArt.Visible   = false;
                //lbGoToCart.Visible = false;
                //lbGoToCart.Parent.Controls.Add(new Literal() { Text = lbGoToCart.Text });
            }
        }
Example #2
0
        /// <summary>
        /// Makes sure that the supplied customer has an active cart.
        /// </summary>
        /// <param name="Account"></param>
        public static void EnsureCustomerCart(Account Account)
        {
            Mediachase.Commerce.Orders.Cart activeCart = null;

            //first, check to see if the "activecart" session key matches up with a real cart, and if it is, we're golden
            if (Account["ActiveCart"] != null)
            {
                activeCart = Mediachase.Commerce.Orders.Cart.LoadByCustomerAndName(Account.PrincipalId, Account["ActiveCart"].ToString());
                if (activeCart != null && !NWTD.Orders.Cart.CartCanBeEdited(activeCart))
                {
                    activeCart = null;                                                                                     //nope, this cart is not editible, so we need to move along
                }
            }
            //next, we need to see if the customer has any carts at all, create one
            MetaStorageCollectionBase <Mediachase.Commerce.Orders.Cart> carts = Mediachase.Commerce.Orders.Cart.LoadByCustomer(Account.PrincipalId);

            //if we still don't have an active cart, we'll loop throught the customer's carts and assign the first valid one we find
            if (activeCart == null)
            {
                foreach (Mediachase.Commerce.Orders.Cart cart in carts)
                {
                    if (activeCart == null && cart.Status.ToString().Equals(NWTD.Orders.Cart.CART_STATUS.OPEN.ToString()))
                    {
                        activeCart = cart;
                    }
                }
            }

            //finally, if there is still no active cart, create the damn thing
            if (activeCart == null)
            {
                //first, we have to make sure we come up with a unique name.
                string baseName   = Mediachase.Commerce.Orders.Cart.DefaultName;
                string cartName   = baseName;
                int    iterations = 1;
                while (Mediachase.Commerce.Orders.Cart.LoadByCustomerAndName(Account.PrincipalId, cartName) != null)
                {
                    cartName = string.Format("{0}-{1}", baseName, iterations.ToString());
                    iterations++;
                }
                activeCart = NWTD.Orders.Cart.CreateCart(Account, cartName);
            }



            AssignActiveCart(Account, activeCart);
        }
Example #3
0
 /// <summary>
 /// Sets the acctive cart for a supplied customer
 /// </summary>
 /// <param name="Account"></param>
 /// <param name="Cart"></param>
 public static void AssignActiveCart(Account Account, Mediachase.Commerce.Orders.Cart Cart)
 {
     Account["ActiveCart"] = Cart.Name;
     Account.AcceptChanges();
 }
 public void UpdateAddress(Mediachase.Commerce.Orders.Cart cart, ExtendedPayExPayment payment)
 {
 }