Beispiel #1
0
        public ActionResult Login(UserLogin userLogin, int selectedButton)
        {
            try
            {
                UserProfile userProfile     = userSqlDAL.GetUser(userLogin.UserEmail);
                bool        passwordMatches = hashProvider.VerifyPasswordMatch(userProfile.UserPassword, userLogin.UserPassword, userProfile.Salt);
                //
                //    // TODO : Add a variable to the parameters to represent whether the user
                //    // is logging in from the TakeSurvey page or from the general login in button.
                //    // RedirectToAction will change depending on the starting point.

                // Jarrod: Right now I've set it so that  once you've loggin in the program checksto see if you have a survey result in th DB
                // If you do, the you are taken to your custom franchise list
                // If you haven't take a survey yet, you are taken to the survey page

                if (passwordMatches)
                {
                    SaveUserSession(userLogin.UserEmail);
                    SurveyAnswers existingSurvey = surveyAnswerDAL.GetSurveyResult(userProfile.UserEmail);

                    if (existingSurvey.business != null)
                    {
                        return(RedirectToAction("ViewProfile"));
                    }
                    else
                    {
                        return(RedirectToAction("Survey", "Home"));
                    }
                }
            }
            catch
            {
                return(RedirectToAction("IncorrectLogin"));
            }
            return(RedirectToAction("IncorrectLogin"));
        }
        public ActionResult Survey(Survey survey)
        {
            //    // TODO Should we move RetrieveUserSession and SaveUserSession to a helper class?
            //    // Otherwise, code is redundant
            UserProfile   userProfile   = userProfileSqlDAL.GetUser(RetrieveUserSession());
            SurveyAnswers surveyAnswers = new SurveyAnswers(userProfile.UserEmail, survey.Business1, survey.State2, survey.Experience3, survey.NetWorth4, survey.Staff5, survey.HaveOwnedBusiness6, survey.WorkStyle7, survey.Industry8, survey.Challenges9, survey.Timeframe10);

            var testIfInDb = surveyAnswerDAL.GetSurveyResult(surveyAnswers.userEmail);

            if (testIfInDb.experience == null)
            {
                surveyAnswerDAL.SaveNewSurveyResult(surveyAnswers);
            }
            else
            {
                surveyAnswerDAL.UpdateSurveyResult(surveyAnswers);
            }

            return(RedirectToAction("ViewProfile", "Profile", userProfile));
        }