public ActionResult Create([Bind(Include = "BillID,CustomerID,Street,City,State,Zip")] Billing billing) { if (ModelState.IsValid) { Customer customer = db.Customers.Where(x => x.Username == User.Identity.Name).First(); db.usp_AddBilling(customer.CustomerID, billing.Street, billing.City, billing.State, billing.Zip); 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", "Invoice", null)); } ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "FirstName", billing.CustomerID); return(View(billing)); }
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)); }