public ActionResult Details()
 {
     if (Session["loggedIn"] != null)
     {
         Retailer r = new Retailer();
         return View(r);
     }
     else
     {
         return RedirectToAction("Index", "Login");
     }
 }
 public ActionResult Details(Retailer r)
 {
     if (ModelState.IsValid)
     {
         String username = Session["loginName"].ToString();
         r.completeRetailer(r, username);
     }
     else
     {
         return View(r);
     }
     return RedirectToAction("Index", "Checkout");
 }
        public ActionResult UpdateRetailer(Retailer r)
        {
            /*  if (ModelState.IsValid)
              { */
            String username = Session["loginName"].ToString();

            r.updateRetailer(r, username);
            /*   }
              else
              {
                  return View(r);
              }  */
            return RedirectToAction("Index", "Checkout");
        }
        public ActionResult UpdateRetailer()
        {
            if (Session["loggedIn"] != null)
            {
                String username = Session["loginName"].ToString();
                System.Diagnostics.Debug.WriteLine("UpdateRetailer Controller");
                Retailer r = new Retailer();
                r.getRetailer(username);

                return View(r);
            }
            else
            {
                return RedirectToAction("Index", "Login");
            }
        }
Exemplo n.º 5
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();
        }
Exemplo n.º 6
0
        public void updateRetailer(Retailer r, String username)
        {
            try
            {

                using (MySqlConnection con = new MySqlConnection(con_str))
                {

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

                        //Get username

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

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

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

                        cmd.ExecuteNonQuery();

                        con.Close();
                    }
                }
            }

            catch
            {
                System.Diagnostics.Debug.WriteLine("updateRetailer() Fail!");
            }
        }
Exemplo n.º 7
0
        public void completeRetailer(Retailer r, String username)
        {
            using (MySqlConnection con = new MySqlConnection(con_str))
            {
                con.Open();
                using (MySqlCommand cmd = new MySqlCommand("completeRetailer", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@username", username);

                    cmd.Parameters.AddWithValue("@branch", r.branch);
                    cmd.Parameters.AddWithValue("@companyName", r.Companyname);

                    if (r.Companywebsite != null)
                    {
                        cmd.Parameters.AddWithValue("@companyWebsite", r.Companywebsite);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@secondaryNumber", null);
                    }

                    //params for insert into contact
                    cmd.Parameters.AddWithValue("@title", r.title.ToString());
                    cmd.Parameters.AddWithValue("@forename", r.forename);
                    cmd.Parameters.AddWithValue("@surname", r.surname);

                    cmd.Parameters.AddWithValue("@firstNumber", r.firstNumber);
                    if (r.secondaryNumber != null)
                    {
                        cmd.Parameters.AddWithValue("@secondaryNumber", r.secondaryNumber);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@secondaryNumber", null);
                    }
                    cmd.Parameters.AddWithValue("@email", r.email);
                    if (r.fax != null)
                    {
                        cmd.Parameters.AddWithValue("@fax", r.fax);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@fax", null);
                    }

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

                    cmd.ExecuteNonQuery();
                    con.Close();
                }
            }
        }