Esempio n. 1
0
 internal void ClearAddress(int id)
 {
     if (this.billingID == id || this.shippingID == id) {
         Customer tmp = new Customer();
         EcommercePlatformDataContext db = new EcommercePlatformDataContext();
         tmp = db.Customers.Where(x => x.ID.Equals(this.ID)).FirstOrDefault<Customer>();
         if (tmp.billingID == id) {
             tmp.billingID = 0;
         }
         if (tmp.shippingID == id) {
             tmp.shippingID = 0;
         }
         db.SubmitChanges();
     }
 }
		private void detach_Customers1(Customer entity)
		{
			this.SendPropertyChanging();
			entity.Address1 = null;
		}
		private void attach_Customers(Customer entity)
		{
			this.SendPropertyChanging();
			entity.Address = this;
		}
 partial void DeleteCustomer(Customer instance);
 partial void UpdateCustomer(Customer instance);
 partial void InsertCustomer(Customer instance);
Esempio n. 7
0
        internal void Save() {
            EcommercePlatformDataContext db = new EcommercePlatformDataContext();
            Settings settings = new Settings();
            bool RequireCustomerActivation = true;
            if (settings.Get("RequireCustomerActivation") == "false") {
                RequireCustomerActivation = false;
            }

            // Make sure we don't have an account with this e-mail address
            Customer cust = this.GetCustomerByEmail();
            if (cust != null && cust.ID > 0) {
                throw new Exception("An account using the E-Mail address you provided already exists.");
            }

            // We are going to make an attempt at saving the Customer record

            Customer new_customer = new Customer {
                email = this.email,
                fname = this.fname,
                lname = this.lname,
                phone = this.phone,
                dateAdded = this.dateAdded,
                isSuspended = this.isSuspended,
                isValidated = this.isValidated,
                validator = this.validator,
                password = this.password,
                receiveNewsletter = this.receiveNewsletter,
                receiveOffers = this.receiveOffers,
            };

            if (!RequireCustomerActivation) {
                new_customer.isValidated = 1;
            }
            db.Customers.InsertOnSubmit(new_customer);
            db.SubmitChanges();
            this.ID = new_customer.ID;

            if (RequireCustomerActivation) {
                SendValidation();
            }
        }
Esempio n. 8
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;
        }
Esempio n. 9
0
 internal void SetShippingDefaultAddress(int id) {
     EcommercePlatformDataContext db = new EcommercePlatformDataContext();
     Customer cust = new Customer();
     cust = db.Customers.Where(x => x.ID.Equals(this.ID)).FirstOrDefault<Customer>();
     cust.shippingID = id;
     db.SubmitChanges();
     this.shippingID = id;
 }
Esempio n. 10
0
 internal Customer Get(int id = 0) {
     try {
         Customer cust = new Customer();
         EcommercePlatformDataContext db = new EcommercePlatformDataContext();
         cust = db.Customers.Where(x => x.ID.Equals(id)).FirstOrDefault<Customer>();
         return cust;
     } catch (Exception) {
         throw new Exception("Unable to retrieve Customer record.");
     }
 }
Esempio n. 11
0
        internal void SaveAddresses(Address billing, Address shipping) {
            
            this.billingID = billing.ID;
            this.shippingID = shipping.ID;

            Customer tmp = new Customer();
            EcommercePlatformDataContext db = new EcommercePlatformDataContext();
            tmp = db.Customers.Where(x => x.ID.Equals(this.ID)).FirstOrDefault<Customer>();
            tmp.billingID = this.billingID;
            tmp.shippingID = this.shippingID;
            db.SubmitChanges();
        }
Esempio n. 12
0
 internal void UpdatePassword() {
     Customer tmp = new Customer();
     EcommercePlatformDataContext db = new EcommercePlatformDataContext();
     tmp = db.Customers.Where(x => x.ID.Equals(this.ID)).FirstOrDefault<Customer>();
     tmp.password = this.password;
     db.SubmitChanges();
 }
Esempio n. 13
0
 internal void Update(string email, string fname, string lname, string phone, int receiveOffers, int receiveNewsletter) {
     Customer tmp = new Customer();
     EcommercePlatformDataContext db = new EcommercePlatformDataContext();
     tmp = db.Customers.Where(x => x.ID.Equals(this.ID)).FirstOrDefault<Customer>();
     tmp.email = email;
     tmp.fname = fname;
     tmp.lname = lname;
     tmp.phone = phone;
     tmp.receiveNewsletter = receiveNewsletter;
     tmp.receiveOffers = receiveOffers;
     db.SubmitChanges();
 }