コード例 #1
0
        /// <summary>
        /// The add address.
        /// </summary>
        /// <param name="address">
        /// The address.
        /// </param>
        public void AddAddress(Address address)
        {
            var dalAddress = new DataAccessLayer.Address();
            var dalCustomerAddress = new CustomerAddress();

            BusinessObjectLayer.Customer customer = this.User;
            var customerAddress = new BusinessObjectLayer.CustomerAddress();

            dalAddress.Insert(address);

            customerAddress.CustomerId = customer.Id;
            customerAddress.AddressId = address.Id;

            dalCustomerAddress.Insert(customerAddress);
        }
コード例 #2
0
        /// <summary>
        /// The submit_ click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void Submit_Click(object sender, EventArgs e)
        {
            var address = new Address();
            address.FirstName = this.FirstName.Text;
            address.LastName = this.LastName.Text;
            address.CompanyName = this.CompanyName.Text;
            address.PostalCode = this.PostalCode.Text;
            address.AddressNumber = this.AddressNumber.Text;

            new Customer().AddAddress(address);

            this.SetFlash("Adres succesvol toegevoegd.");

            this.Response.Redirect("?page=Customer");
        }
コード例 #3
0
        /// <summary>
        /// The place order.
        /// </summary>
        /// <param name="products">
        /// The products.
        /// </param>
        /// <param name="addressInvoice">
        /// The address invoice.
        /// </param>
        /// <param name="addressShipping">
        /// The address shipping.
        /// </param>
        /// <param name="shipping">
        /// The shipping.
        /// </param>
        public void PlaceOrder(
            Address addressInvoice, 
            Address addressShipping, 
            bool shipping)
        {
            var dalAddress = new DataAccessLayer.Address();
            dalAddress.Insert(addressInvoice);
            dalAddress.Insert(addressShipping);

            var order = new BusinessObjectLayer.Order();
            order.InvoiceAddressId = addressInvoice.Id;
            order.ShippingAddressId = addressShipping.Id;
            order.CustomerId = User.Id;
            order.Delivery = shipping;
            if (shipping)
            {
                order.DeliveryPrice = 5;
            }

            order.Created = DateTime.Now;

            this.dalOrder.Insert(order);
            System.Diagnostics.Debug.WriteLine("Order placed with Id: " + order.Id);

            foreach (CartProduct cartProduct in _bllCart.GetCart())
            {
                var product = new BusinessObjectLayer.OrderProduct();
                product.OrderId = order.Id;
                product.Price = cartProduct.Price;
                product.ProductId = cartProduct.Id;
                product.Amount = cartProduct.Amount;

                this.dalOrderProduct.Insert(product);
                System.Diagnostics.Debug.WriteLine("Product added to order: " + order.Id + "(" + product.Id + ")");
            }

            this._bllCart.Remove();
        }
コード例 #4
0
        /// <summary>
        /// The submit_ on click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Submit_OnClick(object sender, EventArgs e)
        {
            var addressShipping = new Address();
            var addressInvoice = new Address();

            addressInvoice.FirstName = this.FirstNameInvoice.Text;
            addressShipping.FirstName = this.FirstNameDelivery.Text;

            addressInvoice.LastName = this.LastNameInvoice.Text;
            addressShipping.LastName = this.LastNameDelivery.Text;

            addressInvoice.CompanyName = this.CompanyNameInvoice.Text;
            addressShipping.CompanyName = this.CompanyNameDelivery.Text;

            addressInvoice.PostalCode = this.PostalCodeInvoice.Text;
            addressShipping.PostalCode = this.PostalCodeDelivery.Text;

            addressInvoice.AddressNumber = this.PostalCodeInvoice.Text;
            addressShipping.AddressNumber = this.PostalCodeDelivery.Text;

            bool shipping = this.DeliveryTrue.Checked;

            this._bllOrder.PlaceOrder(addressInvoice, addressShipping, shipping);

            this.Response.Redirect("?page=Order&method=Success");
        }
コード例 #5
0
        /// <summary>
        /// The register.
        /// </summary>
        /// <param name="email">
        /// The email.
        /// </param>
        /// <param name="password">
        /// The password.
        /// </param>
        /// <param name="phone">
        /// The phone.
        /// </param>
        /// <param name="cellPhone">
        /// The cell phone.
        /// </param>
        /// <param name="firstName">
        /// The first name.
        /// </param>
        /// <param name="lastName">
        /// The last name.
        /// </param>
        /// <param name="companyName">
        /// The company name.
        /// </param>
        /// <param name="postalCode">
        /// The postal code.
        /// </param>
        /// <param name="addressNumber">
        /// The address number.
        /// </param>
        /// <returns>
        /// The <see cref="Customer"/>.
        /// </returns>
        /// <exception cref="Exception">
        /// </exception>
        public BusinessObjectLayer.Customer Register(
            string email, 
            string password, 
            string phone, 
            string cellPhone, 
            string firstName, 
            string lastName, 
            string companyName, 
            string postalCode, 
            string addressNumber)
        {
            // TODO Input validation.
            var dalAddress = new DataAccessLayer.Address();
            var dalCustomerAddress = new CustomerAddress();

            if (this.dalCustomer.GetBy("Email", email) != null)
            {
                throw new Exception("Gebruikersnaam is al in gebruik.");
            }

            var customer = new BusinessObjectLayer.Customer();
            customer.Email = email.Trim();
            if (!this.IsValidEmail(customer.Email))
            {
                throw new Exception("Ongeldig e-mailadres.");
            }
            customer.Password = password.Trim();
            if (string.IsNullOrWhiteSpace(customer.Password))
            {
                throw new Exception("Ongeldig wachtwoord.");
            }

            customer.Phone = phone.Trim();
            customer.CellPhone = cellPhone.Trim();
            customer.Created = DateTime.Now;

            var address = new Address();
            address.AddressNumber = addressNumber.Trim();
            address.CompanyName = companyName.Trim();
            address.FirstName = firstName.Trim();
            if (string.IsNullOrWhiteSpace(address.FirstName))
            {
                throw new Exception("Ongeldige voornaam.");
            }
            address.LastName = lastName.Trim();
            if (string.IsNullOrWhiteSpace(address.LastName))
            {
                throw new Exception("Ongeldige achternaam.");
            }

            address.PostalCode = postalCode.Trim();
            address.CountryId = 0;

            customer = this.dalCustomer.Insert(customer);
            address = dalAddress.Insert(address);

            var customerAddress = new BusinessObjectLayer.CustomerAddress();
            customerAddress.DefaultInvoice = true;
            customerAddress.DefaultShipping = true;
            customerAddress.AddressId = address.Id;
            customerAddress.CustomerId = customer.Id;
            dalCustomerAddress.Insert(customerAddress);

            return customer;
        }