public ActionResult Create(Customer customer)
        {
            try
            {
                var custInfo = CustomerDB.GetCustomerInfo(customer.UserName);

                // check to see if the username already exists
                if (custInfo != null)
                {
                    ViewBag.usertaken = "User ID Already Exist";
                    return(View());
                }

                else
                {
                    if (customer.CustEmail == null)
                    {
                        customer.CustEmail = "";
                    }
                    if (customer.CustBusPhone == null)
                    {
                        customer.CustBusPhone = "";
                    }
                    customer.Password = Crypto.Hash(customer.Password);
                    CustomerDB.CustomerRegister(customer);

                    return(RedirectToAction("Login"));
                }
            }
            catch
            {
                return(View());
            }
        }
        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());
            }
        }