//Handle the login according to type of user
        //Returns users ID if successful
        //Error is 0
        //Admin is 1

        public int login(String email, String password)
        {
            //check if the user's information is in the database
            var user = (from u in db.Users
                        where u.User_Email.Equals(email) && u.User_Password.Equals(Secrecy.HashPassword(password))
                        select u).FirstOrDefault();


            //If the user exists and is a customer
            if (user != null && user.USer_Type.Equals("Customer"))
            {
                //Return the users ID
                return(user.User_ID);
            }
            else if (user == null)
            {
                //Display an error
                return(0);
            }
            else if (user.USer_Type.Equals("Admin"))
            {
                //Assign the ID to an admin ID who can add, edit and delete products
                return(1);
            }
            else
            {
                //Display an error
                return(-1);
            }
        }
        //Add a new user to the database and hash their password
        public int Register(string firstname, string surname, string email, string password, string usertype, string username, string cellphone, string address)
        {
            //Check if the user exists
            var checkuser = (from u in db.Users
                             where u.User_Email.Equals(email)
                             select u).FirstOrDefault();

            if (checkuser == null)
            {
                var newUser = new User
                {
                    //Assign the new users data to the database
                    User_FirstName = firstname,
                    User_Surname   = surname,
                    User_Email     = email,
                    //Hash their password
                    User_Password  = Secrecy.HashPassword(password),
                    User_Name      = username,
                    User_Address   = address,
                    User_Cellphone = cellphone,
                    USer_Type      = usertype
                };
                //Submit to the database
                db.Users.InsertOnSubmit(newUser);

                try
                {
                    //Submit the changes
                    db.SubmitChanges();
                    return(1);
                }
                catch (Exception ex)
                {
                    //Show an error if something goes wrong
                    ex.GetBaseException();
                    return(-1);
                }
            }
            else
            {
                //Return 0 if it is successful
                return(0);
            }
        }