예제 #1
0
        /// <summary>
        /// Initialize Info object.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="includeStudentCommentData"></param>
        public CommentHeaderInfo(int id, bool includeStudentCommentData = false)
        {
            using (WebhostEntities db = new WebhostEntities())
            {
                CommentHeader header = db.CommentHeaders.Find(id);
                if (header == null)
                {
                    throw new ArgumentException("Invalid Comment Header Id.");
                }

                Id           = id;
                SectionId    = header.SectionIndex;
                TermId       = header.TermIndex;
                Term         = string.Format("{0} {1}", header.Term.Name, header.Term.StartDate.Year);
                SectionTitle = String.Format("[{0}] {1}", header.Section.Block.LongName, header.Section.Course.Name);

                // Convert HTML to Base64String.
                if (header.RTF.Length <= 0)
                {
                    HtmlContent = CommentLetter.ConvertToBase64String(header.HTML);
                }
                else
                {
                    RtfContnet = header.RTF;
                }

                StudentCommentIds = header.StudentComments.Select(com => com.id).ToList();

                if (includeStudentCommentData)
                {
                    StudentComments = new List <StudentCommentInfo>();
                    foreach (int comId in StudentCommentIds)
                    {
                        StudentComments.Add(new StudentCommentInfo(comId));
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Initialize a student comment.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="includeHeader"></param>
        public StudentCommentInfo(int id, bool includeHeader = false)
        {
            using (WebhostEntities db = new WebhostEntities())
            {
                StudentComment comment = db.StudentComments.Find(id);
                if (comment == null)
                {
                    throw new ArgumentException("Invalid Student Comment.");
                }

                Grades = new GradeInfo()
                {
                    EngagementGrade = comment.EngagementGrade.Name,
                    ExamGrade       = comment.ExamGrade.Name,
                    FinalGrade      = comment.FinalGrade.Name,
                    TrimesterGrade  = comment.TermGrade.Name
                };

                Id       = id;
                Student  = new StudentInfo(comment.StudentID);
                HeaderId = comment.HeaderIndex;
                if (comment.RTF.Length <= 0)
                {
                    HtmlContent = CommentLetter.ConvertToBase64String(comment.HTML);
                }
                else
                {
                    RtfContent = comment.RTF;
                }

                if (includeHeader)
                {
                    Header = new CommentHeaderInfo(HeaderId);
                }
            }
        }