public ActionResult Login(LoginViewModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }
                //Authenticate user
                UserModel userModel = new UserModel(model.UserName, model.Password);

                if (userModel.Authenticated == false)
                {
                    model.ErrorMessage = "Unknown UserName or Incorrect Password";
                    return(View(model));
                }

                //set session details to include user details, used for Authorisation
                //in other controllers
                SessionHandler.AddAuthorisedUser(userModel);
                return(RedirectToAction("About", "Home"));
            }
            catch (Exception e)
            {
                return(RedirectToAction("HandledCodeError", "ErrorHandler", new { exception = e.ToString() }));
            }
        }
        public ActionResult Register(RegisterViewModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }

                //Add User and check not already exist
                RegisterUserModel registration = new RegisterUserModel(model.UserName, model.Password, model.Email, model.TelNo);

                if (registration.Success)
                {
                    SessionHandler.AddAuthorisedUser(new UserModel(model.UserName, model.Password));
                    return(RedirectToAction("About", "Home"));
                }

                model.ErrorMessage = "Unable to add user, try different credentials";
                return(View(model));
            }
            catch (Exception e)
            {
                return(RedirectToAction("HandledCodeError", "ErrorHandler", new { exception = e.ToString() }));
            }
        }