// GET: /Details/UpdateConsumer
 public ActionResult UpdateConsumer()
 {
     if (Session["loggedIn"] != null)
     {
         String username = Session["loginName"].ToString();
         Customer cust = new Customer(username);
         return View(cust);
     }
     else
     {
         return RedirectToAction("Index", "Login");
     }
 }
        public ActionResult ConsumerDetails(Customer cust)
        {
            if (ModelState.IsValid)
            {
                String username = Session["loginName"].ToString();
                cust.completeConsumer(cust, username);
            }
            else
            {

                return View(cust);
            }
            return RedirectToAction("Index", "Checkout");
        }
Beispiel #3
0
        public Order(string username, String accountType, ShoppingCart cart)
        {
            this.cart = (ShoppingCart) cart;

            if (accountType.Equals("Personal"))
            {
                customerDetails = new Customer(username);
                country = customerDetails.country;
            }
            else
            {
                retailerDetails = new Retailer();
                retailerDetails.getRetailer(username);
                country = retailerDetails.country;
            }

            paymentDetails = new Payment(username, accountType);
            getShippersDetails();

            getTotals();
        }
Beispiel #4
0
        public void updateConsumer(Customer cust, String username)
        {
            using (MySqlConnection con = new MySqlConnection(con_str))
            {

                con.Open();
                using (MySqlCommand cmd = new MySqlCommand("updateConsumer", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    //Get username

                    cmd.Parameters.AddWithValue("@username", username);

                    //params for insert into contact
                    cmd.Parameters.AddWithValue("@title", cust.title.ToString());
                    cmd.Parameters.AddWithValue("@forename", cust.forename);
                    cmd.Parameters.AddWithValue("@surname", cust.surname);
                    cmd.Parameters.AddWithValue("@firstNumber", cust.firstNumber);
                    if (cust.secondaryNumber != null)
                    {
                        cmd.Parameters.AddWithValue("@secondaryNumber", cust.secondaryNumber);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@secondaryNumber", null);
                    }
                    cmd.Parameters.AddWithValue("@email", cust.email);
                    if (cust.fax != null)
                    {
                        cmd.Parameters.AddWithValue("@fax", cust.fax);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@fax", null);
                    }
                    if (cust.dob != null)
                    {
                        cmd.Parameters.AddWithValue("@dob", cust.dob.ToString("yyyy-MM-dd"));
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@dob", null);
                    }

                    //params for insert into address
                    cmd.Parameters.AddWithValue("@firstLine", cust.firstLine);
                    if (cust.secondLine != null)
                    {
                        cmd.Parameters.AddWithValue("@secondLine", cust.secondLine);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@secondLine", null);
                    }
                    cmd.Parameters.AddWithValue("@town", cust.town);
                    cmd.Parameters.AddWithValue("@postcode", cust.postcode);
                    cmd.Parameters.AddWithValue("@region", cust.region);
                    cmd.Parameters.AddWithValue("@country", cust.country);

                    cmd.ExecuteNonQuery();

                    con.Close();
                }
            }
        }