Example #1
0
        public static IList <UserResultForPageForDate> GetUserLatestAnswers(int userId)
        {
            var answers = StudentRecordFinder.GetAnswersForUser(userId);

            var includedAnswers = StudentRecordFinder.ExtractIncludedAnswers(answers);

            var sortAnswers = new List <UserResultForPageForDate>();

            foreach (var answer in includedAnswers)
            {
                var currAnswer = new UserResultForPageForDate(answer, userId);

                if (!sortAnswers.Contains(currAnswer))
                {
                    sortAnswers.Add(currAnswer);
                }
            }

            sortAnswers.Sort();

            return(sortAnswers);
        }
Example #2
0
        public static TblUserAnswers FindLatestUserAnswer(IList <TblUserAnswers> userAnswers)
        {
            if (userAnswers != null)
            {
                var includedAnswers = StudentRecordFinder.ExtractIncludedAnswers(userAnswers);

                if (includedAnswers.Count > 0)
                {
                    var latestUserAnswer = includedAnswers[0];
                    foreach (var o in includedAnswers)
                    {
                        if (o.Date > latestUserAnswer.Date)
                        {
                            latestUserAnswer = o;
                        }
                    }

                    return(latestUserAnswer);
                }
            }
            return(null);
        }