public void HasUserFilledOutQuestionsReturnsTrueIfTheUserFilledOutEvenASingleQuestion()
        {
            AgileMindEntities agileDb = new AgileMindEntities();

            LoginResult.ValidateLogin(LOGINNAME, PASSWORD, "ip");

            AgileMind.DAL.Data.Login login = (from data in agileDb.Logins where data.LoginName == LOGINNAME select data).First();
            if (login != null)
            {
                t_LoginSession session = (from data in agileDb.t_LoginSession where data.LoginId == login.LoginId && data.ValidTill > DateTime.Now select data).First();
                if (session != null)
                {
                    t_UserProfileAnswer newAnswer = new t_UserProfileAnswer();
                    newAnswer.LoginId = login.LoginId;
                    newAnswer.NoAnswer = false;
                    newAnswer.UserProfileQuestionId = 1;
                    newAnswer.Answer = "one answer";
                    newAnswer.Created = DateTime.Now;
                    agileDb.t_UserProfileAnswer.AddObject(newAnswer);
                    agileDb.SaveChanges();

                    bool userFilledOutQuestion = UserProfileQuestionsResults.HasUserFilledOutAnyQuestions(session.LoginSessionId);
                    Assert.IsTrue(userFilledOutQuestion);
                }
                else
                {
                    Assert.Fail("Could not find the session to begin testing.");
                }
            }
            else
            {
                Assert.Fail("Could not find the login to start testing");
            }
        }
 /// <summary>
 /// Create a new t_UserProfileAnswer object.
 /// </summary>
 /// <param name="userProfileAnswerId">Initial value of the UserProfileAnswerId property.</param>
 /// <param name="loginId">Initial value of the LoginId property.</param>
 /// <param name="userProfileQuestionId">Initial value of the UserProfileQuestionId property.</param>
 /// <param name="answer">Initial value of the Answer property.</param>
 /// <param name="created">Initial value of the Created property.</param>
 /// <param name="noAnswer">Initial value of the NoAnswer property.</param>
 public static t_UserProfileAnswer Createt_UserProfileAnswer(global::System.Int32 userProfileAnswerId, global::System.Int32 loginId, global::System.Int32 userProfileQuestionId, global::System.String answer, global::System.DateTime created, global::System.Boolean noAnswer)
 {
     t_UserProfileAnswer t_UserProfileAnswer = new t_UserProfileAnswer();
     t_UserProfileAnswer.UserProfileAnswerId = userProfileAnswerId;
     t_UserProfileAnswer.LoginId = loginId;
     t_UserProfileAnswer.UserProfileQuestionId = userProfileQuestionId;
     t_UserProfileAnswer.Answer = answer;
     t_UserProfileAnswer.Created = created;
     t_UserProfileAnswer.NoAnswer = noAnswer;
     return t_UserProfileAnswer;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the t_UserProfileAnswer EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTot_UserProfileAnswer(t_UserProfileAnswer t_UserProfileAnswer)
 {
     base.AddObject("t_UserProfileAnswer", t_UserProfileAnswer);
 }
        public static Result SaveUserQuestions(List<vwQuestionAnswer> QuestionAnswerList, Guid SessionId)
        {
            Result saveResults = new Result();

            AgileMindEntities agileDB = new AgileMindEntities();

            t_LoginSession session = (from loginSession in agileDB.t_LoginSession where loginSession.LoginSessionId == SessionId && loginSession.ValidTill > DateTime.Now select loginSession).First();
            if (session != null)
            {
                List<t_UserProfileAnswer> answerList = (from data in agileDB.t_UserProfileAnswer where data.LoginId == session.LoginId select data).ToList();

                foreach (vwQuestionAnswer questionAnswer in QuestionAnswerList)
                {
                    if (questionAnswer.UserProfileAnswerId == null || questionAnswer.UserProfileAnswerId == 0)
                    {
                        t_UserProfileAnswer newAnswer = new t_UserProfileAnswer();
                        newAnswer.Answer = questionAnswer.Answer;
                        newAnswer.Created = DateTime.Now;
                        newAnswer.LoginId = session.LoginId;
                        newAnswer.UserProfileQuestionId = questionAnswer.UserProfileQuestionId;
                        if (questionAnswer.NoAnswer.HasValue)
                        {
                            newAnswer.NoAnswer = questionAnswer.NoAnswer.Value;
                        }
                        else
                        {
                            newAnswer.NoAnswer = false;
                        }
                        agileDB.t_UserProfileAnswer.AddObject(newAnswer);
                    }
                    else
                    {
                        t_UserProfileAnswer foundAnswer = (from data in agileDB.t_UserProfileAnswer where data.UserProfileAnswerId == questionAnswer.UserProfileAnswerId select data).First();

                        if (foundAnswer != null)
                        {
                            foundAnswer.Answer = questionAnswer.Answer;

                            if (questionAnswer.NoAnswer.HasValue)
                            {
                                foundAnswer.NoAnswer = questionAnswer.NoAnswer.Value;
                            }
                            else
                            {
                                foundAnswer.NoAnswer = false;
                            }

                        }
                    }
                }

                agileDB.SaveChanges();

                saveResults.Success = true;
            }
            else
            {
                saveResults.Error = "Could not find session";
            }

            return saveResults;
        }