private void detach_Carts1(Cart entity)
		{
			this.SendPropertyChanging();
			entity.Shipping = null;
		}
示例#2
0
 public Cart Save() {
     EcommercePlatformDataContext db = new EcommercePlatformDataContext();
     try {
         Cart c = new Cart {
             cust_id = 0,
             date_created = DateTime.UtcNow,
             shipping_price = 0
         };
         db.Carts.InsertOnSubmit(c);
         db.SubmitChanges();
         return c;
     } catch { };
     return this;
 }
		private void detach_Carts(Cart entity)
		{
			this.SendPropertyChanging();
			entity.Billing = null;
		}
		private void attach_Carts1(Cart entity)
		{
			this.SendPropertyChanging();
			entity.Shipping = this;
		}
		private void attach_Carts(Cart entity)
		{
			this.SendPropertyChanging();
			entity.Billing = this;
		}
 partial void DeleteCart(Cart instance);
 partial void UpdateCart(Cart instance);
 partial void InsertCart(Cart instance);
示例#9
0
        internal void GetFromStorage(HttpContext ctx) {

            HttpCookie cart_cookie = null;
            int cartID = 0;
            int custID = 0;
            Cart cart = new Cart();
            cart_cookie = ctx.Request.Cookies.Get("hdcart");
            if (cart_cookie != null && cart_cookie.Value != null && cart_cookie.Value.Length > 0) {
                cartID = Convert.ToInt32(cart_cookie.Value);
            }
            if (cartID == 0) {
                // cart doesn't exist yet / no cookie
                cart = cart.Save();
                cartID = cart.ID;
                HttpCookie cook = new HttpCookie("hdcart", cartID.ToString());
                if (this.remember) {
                    cook.Expires = DateTime.Now.AddDays(30);
                }
                ctx.Response.Cookies.Add(cook);
            } else {
                // cookie exists
                try {
                    // attempt to get cart
                    cart = new Cart().Get(cartID);
                    custID = cart.cust_id;
                } catch {
                    // no cart
                    cart = cart.Save();
                    cartID = cart.ID;
                    HttpCookie cook = new HttpCookie("hdcart", cartID.ToString());
                    if (this.remember) {
                        cook.Expires = DateTime.Now.AddDays(30);
                    }
                    ctx.Response.Cookies.Add(cook);
                }
            }

            Customer customer = new Customer();
            if (custID > 0) {
                // customer ID exists on cart. Get customer
                try {
                    customer = customer.Get(custID);
                } catch { }
            }
            customer.Cart = cart;

            this.ID = customer.ID;
            this.email = customer.email;
            this.fname = customer.fname;
            this.lname = customer.lname;
            this.phone = customer.phone;
            this.dateAdded = customer.dateAdded;
            this.isSuspended = customer.isSuspended;
            this.receiveNewsletter = customer.receiveNewsletter;
            this.receiveOffers = customer.receiveOffers;
            this.billingID = customer.billingID;
            this.shippingID = customer.shippingID;
            this.validator = customer.validator;
            this.Cart = customer.Cart;
            this.remember = customer.remember;
        }