// GET: Customer/Edit/5
 public ActionResult Edit()
 {
     //check to see if user is logged in else redirect to login
     if (Session["UserID"] == null)
     {
         return(RedirectToAction("Login"));
     }
     else
     {
         int      id          = Convert.ToInt32(Session["UserID"]);
         Customer currentCust = CustomerDB.GetCustomerDetails(id);
         return(View(currentCust));
     }
 }
        Customer customer; //customer reference
        // GET: Customer

        public ActionResult Index()
        {
            //check for nulls and redirect if necessary
            if (Session["UserID"] == null)
            {
                return(RedirectToAction("Login"));
            }
            //return customer details
            else
            {
                int id = Convert.ToInt32(Session["UserID"]);

                customer = CustomerDB.GetCustomerDetails(id);
                return(View(customer));
            }
        }
        public ActionResult Edit(Customer newCustomer)
        {
            try
            {
                var      custInfo    = CustomerDB.GetCustomerInfo(newCustomer.UserName);
                int      id          = Convert.ToInt32(Session["UserID"]);
                Customer currentCust = CustomerDB.GetCustomerDetails(id);
                newCustomer.Password = Crypto.Hash(newCustomer.Password);
                // check to see if username has been taken
                if (custInfo != null && currentCust.UserName != custInfo.UserName)
                {
                    ViewBag.usertaken = "User ID Already Exist";
                    return(View());
                }
                if (newCustomer.CustEmail == null)
                {
                    newCustomer.CustEmail = "";
                }
                if (newCustomer.CustBusPhone == null)
                {
                    newCustomer.CustBusPhone = "";
                }

                int count = CustomerDB.UpdateCustomer(currentCust, newCustomer);
                if (count == 0)// no update due to concurrency issue
                {
                    TempData["errorMessage"] = "Update aborted. " +
                                               "Another user changed or deleted this row";
                }

                else
                {
                    TempData["errorMessage"] = "";
                }
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }