예제 #1
0
        public ActionResult Create(Shipping shipping)
        {
            if (ModelState.IsValid)
            {
                Customer customer = db.Customers.Where(x => x.Username == User.Identity.Name).First();
                db.usp_AddShipping(customer.CustomerID, shipping.Street, shipping.City, shipping.State, shipping.Zip);
                if (shipping.BillingIsSame)
                {
                    db.usp_AddBilling(customer.CustomerID, shipping.Street, shipping.City, shipping.State, shipping.Zip);
                }
                else
                {
                    //see if user has billing address
                    try
                    {
                        Billing billing = db.Billings.Where(x => x.CustomerID == customer.CustomerID).First();
                    }
                    catch (Exception e)
                    {
                        return(RedirectToAction("Create", "Billing", null));
                    }
                }

                //see if user has credit card
                try
                {
                    Credit_Card card = db.Credit_Card.Where(x => x.CustomerID == customer.CustomerID).First();
                }
                catch (Exception e)
                {
                    return(RedirectToAction("CreateForCheckout", "CreditCard", null));
                }

                return(RedirectToAction("Index"));
            }

            return(View(shipping));
        }