Ejemplo n.º 1
0
        /// <summary>
        /// Save a new Signature Image from a byte array.
        /// </summary>
        /// <param name="imgData"></param>
        public void SaveNewSignature(byte[] imgData)
        {
            using (WebhostEntities db = new WebhostEntities())
            {
                Faculty faculty = db.Faculties.Where(f => f.ID == FacultyId).Single();
                faculty.SignatureData = imgData;
                db.SaveChanges();
            }
            MemoryStream str = new MemoryStream();

            str.Seek(0, SeekOrigin.Begin);
            try
            {
                str.Read(imgData, 0, imgData.Length);
            }
            catch
            {
                image = null;
                return;
            }
            MemoryStream mStream = new MemoryStream();

            for (int i = 0; i < imgData.Length; i++)
            {
                mStream.WriteByte(imgData[i]);
            }

            image = Image.FromStream(mStream);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets a given WeekendActivity, looks for a WeekendDuty Detention and then
        /// compares to see if their time-frames overlap.
        /// </summary>
        /// <param name="activityId"></param>
        /// <returns></returns>
        public static bool ActivityConflictsWithDetention(int activityId, bool twoHour = true)
        {
            using (WebhostEntities db = new WebhostEntities())
            {
                WeekendActivity activity = db.WeekendActivities.Where(act => act.id == activityId).Single();

                List <WeekendDuty> detentions = activity.Weekend.WeekendDuties.Where(duty => duty.Name.Contains("Detention")).ToList();

                if (detentions.Count <= 0)
                {
                    return(false);                        // No Detention this weekend?
                }
                DateRange activityRange = new DateRange(activity.DateAndTime, activity.DateAndTime.AddMinutes(activity.Duration == 0 ? 120 : activity.Duration));
                foreach (WeekendDuty detention in detentions)
                {
                    DateRange detentionRange = new DateRange(detention.DateAndTime, detention.DateAndTime.AddMinutes(twoHour?120:60));

                    if (activityRange.Intersects(detentionRange))
                    {
                        return(true);
                    }
                }

                return(false);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// courseHeaders = { "Course Name", "Department Name", "Course Code", "Section Name", "Section Code" }
        /// </summary>
        /// <param name="termId"></param>
        /// <returns></returns>
        public static CSV FullYearCourses(int termId)
        {
            CSV csv = new CSV();

            using (WebhostEntities db = new WebhostEntities())
            {
                Term           term            = db.Terms.Where(t => t.id == termId).Single();
                List <Section> currentSections = term.Sections.Where(sec => sec.Course.LengthInTerms == 3 && sec.Course.goesToSchoology).ToList();

                foreach (Section sec in currentSections)
                {
                    String TeachersNames = "";
                    bool   first         = true;
                    foreach (Faculty faculty in sec.Teachers.ToList())
                    {
                        TeachersNames += String.Format("{0}{1} {2}", first ? "" : ", ", faculty.FirstName, faculty.LastName);
                        first          = false;
                    }
                    Dictionary <string, string> secdata = new Dictionary <string, string>();
                    secdata.Add("Course Name", sec.Course.Name);
                    secdata.Add("Department Name", sec.Course.Department.Name);
                    secdata.Add("Course Code", Convert.ToString(sec.CourseIndex));
                    secdata.Add("Section Name", String.Format("[{0}] {1}", sec.Block.LongName, TeachersNames));
                    secdata.Add("Section Code", Convert.ToString(sec.id));

                    csv.Add(secdata);
                }
            }
            return(csv);
        }
Ejemplo n.º 4
0
 public static List <int> GetProctors(int AcademicYear = -1)
 {
     using (WebhostEntities db = new WebhostEntities())
     {
         int        permid            = GetPermissionByName("Proctors", AcademicYear).id;
         Permission proctorPermission = db.Permissions.Where(p => p.id == permid).Single();
         return(proctorPermission.Students.Select(student => student.ID).ToList());
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets the current Academic Year.
        /// Year break is 7 June, since Graduation is in the First Week of June at the latest.
        /// By design, this is also the UniqueID for the Current Academic year Object in the Database.
        /// </summary>
        /// <returns></returns>
        public static int GetCurrentAcademicYear()
        {
            int termId = GetCurrentOrLastTerm();

            using (WebhostEntities db = new WebhostEntities())
            {
                return(db.Terms.Where(t => t.id == termId).Single().AcademicYearID);
            }
            //return DateTime.Today.Year + (DateTime.Today.Month > 6 || (DateTime.Today.Month == 6 && DateTime.Today.Day > 10) ? 1 : 0);
        }
Ejemplo n.º 6
0
        public static String BlockOrderByDayOfWeek(DateTime date)
        {
            String blocks = "ABCDEF";

            if (date.DayOfWeek == DayOfWeek.Wednesday)
            {
                using (WebhostEntities db = new WebhostEntities())
                {
                    if (db.WednesdaySchedules.Where(w => w.Day.Equals(date.Date)).Count() <= 0)
                    {
                        WebhostEventLog.Syslog.LogWarning("I don't know if today is an ABC wednesday or not!");
                        try
                        {
                            MailControler.MailToWebmaster("Wednesday Schedule?", "I don't know if today is ABC or not >_<");
                        }
                        catch
                        {
                            WebhostEventLog.Syslog.LogError("I couldn't send you an email to let you know...");
                        }
                        return(blocks);
                    }

                    WednesdaySchedule wed = db.WednesdaySchedules.Where(w => w.Day.Equals(date.Date)).Single();
                    if (wed.IsABC)
                    {
                        return("ABC");
                    }

                    return("DEF");
                }
            }

            int offset = 0;

            switch (date.DayOfWeek)
            {
            case DayOfWeek.Tuesday: offset = 1; break;

            case DayOfWeek.Thursday: offset = 2; break;

            case DayOfWeek.Friday: offset = 3; break;

            default: offset = 0; break;
            }
            String ordered = "";

            for (int i = 0; i < 6; i++)
            {
                ordered += blocks[(i + offset) % 6];
            }

            return(ordered);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Is a student Active?
        /// Checks the graduation year and the isActive flag.
        /// </summary>
        /// <param name="studentId"></param>
        /// <returns></returns>
        public static bool IsActiveStudent(int studentId)
        {
            using (WebhostEntities db = new WebhostEntities())
            {
                if (db.Students.Where(s => s.ID == studentId).Count() <= 0)
                {
                    return(false);
                }

                Student student = db.Students.Where(s => s.ID == studentId).Single();
                return(student.GraduationYear <= DateRange.GetCurrentAcademicYear() && student.isActive);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Searches for the current (or next) weekend.
        /// If no weekend is saved for that weekend, returns -1.
        /// </summary>
        /// <returns></returns>
        public static int GetCurrentWeekendId()
        {
            using (WebhostEntities db = new WebhostEntities())
            {
                int year = GetCurrentAcademicYear();
                if (db.Weekends.Where(w => w.StartDate.Equals(ThisFriday)).Count() > 0)
                {
                    return(db.Weekends.Where(w => w.StartDate.Equals(ThisFriday)).Single().id);
                }

                return(-1);
            }
        }
Ejemplo n.º 9
0
        public static bool IsActiveFaculty(int facultyId)
        {
            using (WebhostEntities db = new WebhostEntities())
            {
                if (db.Faculties.Where(f => f.ID == facultyId).Count() <= 0)
                {
                    return(false);
                }

                Faculty faculty = db.Faculties.Where(f => f.ID == facultyId).Single();
                return(faculty.isActive);
            }
        }
Ejemplo n.º 10
0
        public static CSV Enrollment(int termId)
        {
            CSV csv = new CSV();

            using (WebhostEntities db = new WebhostEntities())
            {
                Term           term            = db.Terms.Where(t => t.id == termId).Single();
                List <Section> currentSections = term.Sections.Where(sec => sec.Course.goesToSchoology).ToList();

                foreach (Section section in currentSections)
                {
                    //Department Head

                    /*Dictionary<String, String> dept = new Dictionary<string, string>()
                     * {
                     *  {"Course Code", Convert.ToString(section.CourseIndex)},
                     *  {"Section Code", Convert.ToString(section.id)},
                     *  {"User Unique ID", Convert.ToString(section.Course.Department.DeptHeadId)},
                     *  {"Enrollment Type", enrl_teacher}
                     * };
                     *
                     * csv.Add(dept);*/

                    foreach (Faculty teacher in section.Teachers)
                    {
                        Dictionary <String, String> enr = new Dictionary <string, string>();
                        enr.Add("Course Code", Convert.ToString(section.CourseIndex));
                        enr.Add("Section Code", Convert.ToString(section.id));
                        enr.Add("User Unique ID", Convert.ToString(teacher.ID));
                        enr.Add("Enrollment Type", enrl_teacher);
                        enr.Add("Class Name", String.Format("[{0}] {1}", section.Block.LongName, section.Course.Name));
                        enr.Add("Name", String.Format("{0} {1}", teacher.FirstName, teacher.LastName));
                        csv.Add(enr);
                    }
                    foreach (Student student in section.Students)
                    {
                        Dictionary <String, String> enr = new Dictionary <string, string>();
                        enr.Add("Course Code", Convert.ToString(section.CourseIndex));
                        enr.Add("Section Code", Convert.ToString(section.id));
                        enr.Add("User Unique ID", Convert.ToString(student.ID));
                        enr.Add("Enrollment Type", enrl_student);
                        enr.Add("Class Name", String.Format("[{0}] {1}", section.Block.LongName, section.Course.Name));
                        enr.Add("Name", String.Format("{0} {1}", student.FirstName, student.LastName));

                        csv.Add(enr);
                    }
                }
            }
            return(csv);
        }
Ejemplo n.º 11
0
        public static String TechnologyRequirementStatus(int studentId)
        {
            using (WebhostEntities db = new WebhostEntities())
            {
                List <Credit> credits = db.Credits.Where(c => c.StudentId == studentId && c.CreditType.Name.Equals("Technology")).ToList();
                float         value   = 0f;
                foreach (Credit credit in credits)
                {
                    value += credit.CreditValue.Value / 9f;
                }

                return(TechnologyCreditsRequired <= (float)Math.Round(value, 3) ? "Credit Fulfilled" : String.Format("Incomplete {0} of {1}", value, TechnologyCreditsRequired));
            }
        }
Ejemplo n.º 12
0
        public static CSV AdvisorList(int termId)
        {
            /*
             * Brad
             * Erika
             * Holly
             * Sarah
             * Eric
             * Anne
             * Jill
             * emily cornell
             */

            List <String> adv_admins = new List <String>(new string[] { "bbates", "erogers", "hmacy", "sdoenmez", "smcfall", "amackey", "jhutchins", "ecornell", "rbeauzay" });

            CSV csv = new CSV();

            using (WebhostEntities db = new WebhostEntities())
            {
                foreach (Student student in db.Students.Where(st => st.isActive).ToList())
                {
                    Dictionary <String, String> row = new Dictionary <string, string>();
                    row.Add("StudentID", Convert.ToString(student.ID));
                    row.Add("AdvisorID", Convert.ToString(student.AdvisorID));
                    csv.Add(row);

                    foreach (String username in adv_admins)
                    {
                        Faculty teacher = db.Faculties.Where(t => t.UserName.Equals(username)).ToList().Single();
                        Dictionary <String, String> adm = new Dictionary <string, string>();
                        adm.Add("StudentID", Convert.ToString(student.ID));
                        adm.Add("AdvisorID", Convert.ToString(teacher.ID));
                        csv.Add(adm);
                    }

                    foreach (Section sec in student.Sections.Where(sec => sec.Terms.Where(t => t.id == termId).Count() > 0).ToList())
                    {
                        if (sec.Teachers.Count > 0 && (sec.Course.Name.Contains("Tutorial") || sec.Course.Name.Contains("Evening Assisted")))
                        {
                            Dictionary <String, String> tut = new Dictionary <string, string>();
                            tut.Add("StudentID", Convert.ToString(student.ID));
                            tut.Add("AdvisorID", Convert.ToString(sec.Teachers.FirstOrDefault().ID));
                            csv.Add(tut);
                        }
                    }
                }
                return(csv);
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Get a CSV file containing completed credit counts for each student in the given list.
        /// Rows => Students
        /// Columns => Credits
        /// </summary>
        /// <param name="studentIds">Default value is all active students.</param>
        /// <returns></returns>
        public static CSV GetStudentCredits(List <int> studentIds = null)
        {
            CSV output = new CSV();

            using (WebhostEntities db = new WebhostEntities())
            {
                List <Student> students = new List <Student>();
                if (studentIds == null)
                {
                    students = db.Students.Where(s => s.isActive).OrderBy(s => s.GraduationYear).ThenBy(s => s.LastName).ThenBy(s => s.FirstName).ToList();
                }
                else
                {
                    students = db.Students.Where(s => studentIds.Contains(s.ID)).OrderBy(s => s.GraduationYear).ThenBy(s => s.LastName).ThenBy(s => s.FirstName).ToList();
                }

                foreach (Student student in students)
                {
                    Dictionary <String, float> credits = new Dictionary <string, float>();
                    foreach (GradeTableEntry credType in db.GradeTableEntries.Where(t => t.GradeTable.Name.Equals("Credit Types")).ToList())
                    {
                        if (!credits.ContainsKey(credType.Name))
                        {
                            credits.Add(credType.Name, 0f);
                        }
                    }

                    foreach (Credit credit in student.Credits.ToList())
                    {
                        credits[credit.CreditType.Name] += credit.CreditValue.Value / 9f;
                    }

                    Dictionary <String, String> row = new Dictionary <string, string>()
                    {
                        { "First Name", student.FirstName },
                        { "Last Name", student.LastName }
                    };

                    foreach (String credType in credits.Keys)
                    {
                        row.Add(credType, credits[credType].ToString());
                    }

                    output.Add(row);
                }
            }

            return(output);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Gets the currently active term (or the term that just ended, if no term is active.
        /// </summary>
        /// <returns></returns>
        public static int GetCurrentOrLastTerm()
        {
            using (WebhostEntities db = new WebhostEntities())
            {
                foreach (Term term in db.Terms)
                {
                    if ((new DateRange(term.StartDate, term.EndDate)).Contains(DateTime.Today))
                    {
                        return(term.id);
                    }
                }

                // Find the Last Term that Ended.
                return(db.Terms.Where(t => t.EndDate < DateTime.Today).OrderBy(t => t.EndDate).ToList().Last().id);
            }
        }
Ejemplo n.º 15
0
        public static Permission GetPermissionByName(String name, int AcademicYear = -1)
        {
            if (AcademicYear == -1)
            {
                AcademicYear = DateRange.GetCurrentAcademicYear();
            }
            using (WebhostEntities db = new WebhostEntities())
            {
                if (db.Permissions.Where(p => p.Name.Equals(name) && p.AcademicYear == AcademicYear).Count() <= 0)
                {
                    throw new InvalidCastException(String.Format("No Permission named {0}", name));
                }

                return(db.Permissions.Where(p => p.Name.Equals(name) && p.AcademicYear == AcademicYear).Single());
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Save a new Signature straight from file content.
        /// </summary>
        /// <param name="inStream"></param>
        public void SaveNewSignature(Stream inStream)
        {
            image = System.Drawing.Image.FromStream(inStream);
            MemoryStream tmpStream = new MemoryStream();

            image.Save(tmpStream, System.Drawing.Imaging.ImageFormat.Png);
            tmpStream.Seek(0, SeekOrigin.Begin);
            byte[] imgBytes = new byte[tmpStream.Length];
            tmpStream.Read(imgBytes, 0, (int)tmpStream.Length);

            using (WebhostEntities db = new WebhostEntities())
            {
                Faculty faculty = db.Faculties.Where(f => f.ID == FacultyId).Single();
                faculty.SignatureData = imgBytes;
                db.SaveChanges();
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Get the id of the Next term.  If none exists returns -1.
        /// </summary>
        /// <returns></returns>
        public static int GetNextTerm()
        {
            int thisTermId = GetCurrentOrLastTerm();

            using (WebhostEntities db = new WebhostEntities())
            {
                List <int> terms = db.Terms.OrderBy(t => t.StartDate).Select(t => t.id).ToList();
                try
                {
                    return(terms[terms.IndexOf(thisTermId) + 1]);
                }
                catch (IndexOutOfRangeException)
                {
                    return(-1);
                }
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Create a credit waiver for a given student.
        /// </summary>
        /// <param name="studentId"></param>
        /// <param name="creditTypeId"></param>
        /// <param name="creditValueId"></param>
        /// <param name="notes"></param>
        public static void CreateWaiverCredit(int studentId, int creditTypeId, int creditValueId, String notes = "Waived Credit.")
        {
            using (WebhostEntities db = new WebhostEntities())
            {
                int newCreditId = db.Credits.Count() > 0 ? db.Credits.OrderBy(c => c.id).ToList().Last().id + 1 : 0;

                Credit waiver = new Credit()
                {
                    StudentId     = studentId,
                    CreditTypeId  = creditTypeId,
                    CreditValueId = creditValueId,
                    Notes         = notes
                };

                db.Credits.Add(waiver);
                db.SaveChanges();
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// userColumns = { "First Name", "Last Name", "Username", "User Unique ID", "Grad Year", "Role" };
        /// </summary>
        /// <param name="academicYear"></param>
        /// <returns></returns>
        public static CSV Users(int academicYear)
        {
            CSV csv = new CSV();

            using (WebhostEntities db = new WebhostEntities())
            {
                List <Student> activeStudents = db.Students.Where(st => st.Sections.Where(sec => sec.Course.AcademicYearID == academicYear).Count() > 0).ToList();
                List <Faculty> activeFaculty  = db.Faculties.Where(fac => fac.Sections.Where(sec => sec.Course.AcademicYearID == academicYear).Count() > 0).ToList();

                foreach (Faculty faculty in activeFaculty)
                {
                    Dictionary <String, String> tdata = new Dictionary <string, string>();
                    tdata.Add("First Name", faculty.FirstName);
                    tdata.Add("Last Name", faculty.LastName);
                    tdata.Add("User name", faculty.UserName);
                    tdata.Add("E-Mail", string.Format("{0}@dublinschool.org", faculty.UserName));
                    tdata.Add("User Unique ID", Convert.ToString(faculty.ID));
                    tdata.Add("Role", Convert.ToString(faculty.SchoologyRoleId));

                    /*if (faculty.ID != 67)
                     *  tdata.Add("Role", usr_teacher);
                     * else
                     *  tdata.Add("Role", usr_admin);
                     */
                    csv.Add(tdata);
                }

                foreach (Student student in activeStudents)
                {
                    Dictionary <String, String> tdata = new Dictionary <string, string>();
                    tdata.Add("First Name", student.FirstName);
                    tdata.Add("Last Name", student.LastName);
                    tdata.Add("User name", student.UserName);
                    tdata.Add("E-Mail", string.Format("{0}@dublinschool.org", student.UserName));
                    tdata.Add("User Unique ID", Convert.ToString(student.ID));
                    tdata.Add("Grad Year", Convert.ToString(student.GraduationYear));
                    tdata.Add("Role", usr_student);

                    csv.Add(tdata);
                }
            }

            return(csv);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Synchronize all student signups to the Google Calendar.
        /// </summary>
        /// <param name="WeekendId"></param>
        /// <param name="log"></param>
        public static void SyncronizeStudentSignups(int WeekendId, StreamWriter log = null)
        {
            if (log == null)
            {
                log           = new StreamWriter(Console.OpenStandardOutput());
                log.AutoFlush = true;
                log.WriteLine("Hello Console!");
            }

            using (WebhostEntities db = new WebhostEntities())
            {
                using (GoogleCalendarCall gcal = new GoogleCalendarCall())
                {
                    Weekend weekend = db.Weekends.Where(w => w.id == WeekendId).Single();
                    log.WriteLine("Syncing Student Signups for {0} Weekend {1}", weekend.DutyTeam.Name, weekend.StartDate.ToShortDateString());
                    String activitiesCalendarId = db.GoogleCalendars.Where(c => c.CalendarName.Equals("Weekend Activities")).Single().CalendarId;
                    foreach (WeekendActivity activity in weekend.WeekendActivities.ToList())
                    {
                        log.WriteLine("Updating Student Signups for {0}, {1} {2}", activity.Name, activity.DateAndTime.ToLongDateString(), activity.DateAndTime.ToShortTimeString());
                        List <String> students = gcal.GetEventParticipants(activitiesCalendarId, activity.GoogleCalendarEventId).Where(un => un.Contains("_")).ToList();

                        foreach (StudentSignup signup in activity.StudentSignups.ToList())
                        {
                            if (students.Contains(signup.Student.UserName))
                            {
                                log.WriteLine("{0} {1} is already on the calendar.", signup.Student.FirstName, signup.Student.LastName);
                                students.Remove(signup.Student.UserName);
                            }
                            String status = signup.IsBanned?"declined":"accepted";
                            log.WriteLine("Status:  {0}", status);
                            gcal.AddEventParticipant(activitiesCalendarId, activity.GoogleCalendarEventId, signup.Student.UserName, status, false, signup.IsBanned ? "Not Allowed" : "");
                        }

                        foreach (String toRemove in students)
                        {
                            gcal.RemoveParticipant(activitiesCalendarId, activity.GoogleCalendarEventId, toRemove);
                            log.WriteLine("Removed {0} from Event.", toRemove);
                        }
                    }
                }
            }
        }
Ejemplo n.º 21
0
        public static Dictionary <DateRange, int> BlockIdsByTime(DateTime date)
        {
            Dictionary <DateRange, int> dict = new Dictionary <DateRange, int>();

            if (date.DayOfWeek == DayOfWeek.Saturday || date.DayOfWeek == DayOfWeek.Sunday)
            {
                return(dict);
            }
            int year = GetCurrentAcademicYear();

            String BlockOrderByDay = BlockOrderByDayOfWeek(date);

            using (WebhostEntities db = new WebhostEntities())
            {
                List <Block> blocks = db.Blocks.Where(b => b.AcademicYear == year).ToList();
                dict.Add(new DateRange(DateTime.Today.AddHours(8), DateTime.Today.AddHours(8).AddMinutes(30)), blocks.Where(b => b.Name.Equals("Morning Meeting")).Single().id);
                dict.Add(FirstBlock(date), blocks.Where(b => b.Name.Equals("" + BlockOrderByDay[0])).Single().id);
                dict.Add(SecondBlock(date), blocks.Where(b => b.Name.Equals("" + BlockOrderByDay[1])).Single().id);
                dict.Add(ThirdBlock(date), blocks.Where(b => b.Name.Equals("" + BlockOrderByDay[2])).Single().id);
                if (date.DayOfWeek != DayOfWeek.Wednesday)
                {
                    dict.Add(FourthBlock(date), blocks.Where(b => b.Name.Equals("" + BlockOrderByDay[3])).Single().id);
                    dict.Add(FifthBlock(date), blocks.Where(b => b.Name.Equals("" + BlockOrderByDay[4])).Single().id);
                    dict.Add(SixthBlock(date), blocks.Where(b => b.Name.Equals("" + BlockOrderByDay[5])).Single().id);
                }
                dict.Add(new DateRange(date.AddHours(15), date.AddHours(17).AddMinutes(30)), blocks.Where(b => b.Name.Equals("Sports")).Single().id);
                if (DateTime.Today.DayOfWeek != DayOfWeek.Friday)
                {
                    if (DateTime.Today.DayOfWeek == DayOfWeek.Monday || DateTime.Today.DayOfWeek == DayOfWeek.Wednesday)
                    {
                        dict.Add(new DateRange(date.AddHours(19), date.AddHours(21)), blocks.Where(b => b.Name.Equals("MEAS")).Single().id);
                    }
                    else
                    {
                        dict.Add(new DateRange(date.AddHours(19), date.AddHours(21)), blocks.Where(b => b.Name.Equals("TEAS")).Single().id);
                    }
                    dict.Add(new DateRange(date.AddHours(19).AddMinutes(30), date.AddHours(21).AddMinutes(30)), blocks.Where(b => b.Name.Equals("Study Hall")).Single().id);
                }
            }
            return(dict);
        }
Ejemplo n.º 22
0
        public Signature(int facultyId)
        {
            using (WebhostEntities db = new WebhostEntities())
            {
                Faculty faculty = db.Faculties.Where(f => f.ID == facultyId).Single();
                FacultyId = facultyId;

                if (faculty.SignatureData.Length <= 0)
                {
                    image = null;
                    return;
                }

                MemoryStream str = new MemoryStream();
                str.Seek(0, SeekOrigin.Begin);
                try
                {
                    str.Read(faculty.SignatureData, 0, faculty.SignatureData.Length);
                }
                catch
                {
                    image = null;
                    return;
                }
                MemoryStream mStream = new MemoryStream();
                for (int i = 0; i < faculty.SignatureData.Length; i++)
                {
                    mStream.WriteByte(faculty.SignatureData[i]);
                }

                try
                {
                    image = Image.FromStream(mStream);
                }
                catch (Exception e)
                {
                    MailControler.MailToWebmaster("Signature Image Failed To Load.", String.Format("Comment Letter Signature Image for {0} {1} failed to load properly.\n\nError: {2}", faculty.FirstName, faculty.LastName, e.Message));
                    image = null;
                }
            }
        }
Ejemplo n.º 23
0
        public static String ScienceMathRequirementStatus(int studentId)
        {
            using (WebhostEntities db = new WebhostEntities())
            {
                List <Credit> credits = db.Credits.Where(c => c.StudentId == studentId && (c.CreditType.Name.Equals("Mathematics") || c.CreditType.Name.Equals("Science"))).ToList();
                float         value   = 0f;
                foreach (Credit credit in credits)
                {
                    value += credit.CreditValue.Value / 9f;
                }

                List <String> Required = new List <string>(RequiredScienceCourses);

                foreach (String course in RequiredScienceCourses)
                {
                    if (credits.Where(c => c.Sections.Where(s => s.Course.Name.Contains(course)).Count() > 0).Count() > 0 || credits.Where(c => c.Notes.Contains(course)).Count() > 0)
                    {
                        Required.Remove(course);
                    }
                }

                if (Required.Count > 0)
                {
                    String missing = "Missing: ";
                    foreach (String course in Required)
                    {
                        missing += String.Format("{0} ", course);
                    }

                    return(missing);
                }

                String response = MathSciCreditsHonors <= (float)Math.Round(value, 3) ? "Honors Fulfilled" : (MathSciCreditsRequired <= (float)Math.Round(value, 3) ? "Credit Fulfilled" : String.Format("Incomplete {0} of {1}", value, MathSciCreditsRequired));


                return(response);
            }
        }
Ejemplo n.º 24
0
        public static List <TableRow> GetCreditReportWebTable(int studentId)
        {
            List <TableRow>             table      = new List <TableRow>();
            Dictionary <String, String> gradstatus = GetGraduationRequirementStatuses(studentId);
            TableHeaderRow gradreqheader           = new TableHeaderRow();
            TableRow       gradreqrow = new TableRow();

            foreach (String req in gradstatus.Keys)
            {
                gradreqheader.Cells.Add(new TableHeaderCell()
                {
                    Text = req
                });
                gradreqrow.Cells.Add(new TableCell()
                {
                    Text = gradstatus[req]
                });
            }

            table.Add(gradreqheader);
            table.Add(gradreqrow);

            using (WebhostEntities db = new WebhostEntities())
            {
                Student student = db.Students.Where(s => s.ID == studentId).Single();

                Dictionary <String, float> credits = new Dictionary <string, float>();
                foreach (GradeTableEntry credType in db.GradeTableEntries.Where(t => t.GradeTable.Name.Equals("Credit Types")).ToList())
                {
                    if (!credits.ContainsKey(credType.Name))
                    {
                        credits.Add(credType.Name, 0f);
                    }
                }

                // Build Header Rows
                TableHeaderRow totalCreditsHeaderRow = new TableHeaderRow();
                totalCreditsHeaderRow.Cells.Add(new TableHeaderCell()
                {
                    Text = "Total Credits", ColumnSpan = credits.Keys.Count
                });
                table.Add(totalCreditsHeaderRow);

                TableHeaderRow subheader = new TableHeaderRow();
                foreach (String type in credits.Keys)
                {
                    subheader.Cells.Add(new TableCell()
                    {
                        Text = type
                    });
                }
                table.Add(subheader);

                Dictionary <String, List <TableRow> > creditRows = new Dictionary <string, List <TableRow> >();

                foreach (Credit credit in student.Credits.ToList())
                {
                    credits[credit.CreditType.Name] += credit.CreditValue.Value / 9f;
                    TableRow credRow = new TableRow();
                    credRow.Cells.AddRange(new TableCell[] {
                        new TableCell()
                        {
                            Text = credit.Sections.Count > 0? String.Format("{0} {1} {2}", credit.Sections.ToList().Single().Course.Name, credit.Sections.ToList().Single().Terms.ToList().First().Name, credit.Sections.ToList().Single().Terms.ToList().First().StartDate.Year): ""
                        },
                        new TableCell()
                        {
                            Text = credit.Notes, ColumnSpan = (credits.Keys.Count > 3 ? credits.Keys.Count - 2 : 1)
                        },
                        new TableCell()
                        {
                            Text = String.Format("{0:F3}", credit.CreditValue.Value / 9f)
                        }
                    });

                    if (creditRows.ContainsKey(credit.CreditType.Name))
                    {
                        creditRows[credit.CreditType.Name].Add(credRow);
                    }
                    else
                    {
                        creditRows.Add(credit.CreditType.Name, new List <TableRow>()
                        {
                            credRow
                        });
                    }
                }

                TableRow row = new TableRow();

                foreach (String credType in credits.Keys)
                {
                    row.Cells.Add(new TableCell()
                    {
                        Text = String.Format("{0:F3}", credits[credType])
                    });
                }

                table.Add(row);
                table.Add(new TableFooterRow());

                foreach (String type in creditRows.Keys)
                {
                    TableHeaderRow typeHeaderRow = new TableHeaderRow();
                    typeHeaderRow.Cells.Add(new TableHeaderCell()
                    {
                        Text = type, ColumnSpan = credits.Keys.Count
                    });
                    table.Add(typeHeaderRow);
                    foreach (TableRow tr in creditRows[type])
                    {
                        table.Add(tr);
                    }
                }
            }

            return(table);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Publish all the Weekend Items to the Weekend Duty and Weekend Activities calendars.
        /// </summary>
        /// <param name="WeekendId"></param>
        /// <param name="log">Pass your favorite Log object here in the Web context, or leave it blank to use the Console Standard output.</param>
        public static void PublishWeekendScheduleToGoogleCalendars(int WeekendId, StreamWriter log = null)
        {
            if (log == null)
            {
                log           = new StreamWriter(Console.OpenStandardOutput());
                log.AutoFlush = true;
                log.WriteLine("Hello Console!");
            }
            using (WebhostEntities db = new WebhostEntities())
            {
                using (GoogleCalendarCall gcal = new GoogleCalendarCall())
                {
                    Weekend weekend = db.Weekends.Where(w => w.id == WeekendId).Single();
                    log.WriteLine("Publishing {0} Weekend {1}", weekend.DutyTeam.Name, weekend.StartDate.ToShortDateString());
                    String dutyCalendarId       = db.GoogleCalendars.Where(c => c.CalendarName.Equals("Weekend Duty")).Single().CalendarId;
                    String activitiesCalendarId = db.GoogleCalendars.Where(c => c.CalendarName.Equals("Weekend Activities")).Single().CalendarId;

                    foreach (WeekendDuty duty in weekend.WeekendDuties.ToList())
                    {
                        if (duty.GoogleCalendarEventId.Equals(""))
                        {
                            log.WriteLine("Creating New Event for {0}, {1} {2}", duty.Name, duty.DateAndTime.ToLongDateString(), duty.DateAndTime.ToShortTimeString());
                            duty.GoogleCalendarEventId = gcal.PostEventToCalendar(dutyCalendarId, duty.Name, duty.DateAndTime, TimeSpan.FromMinutes(duty.Duration), duty.Description);
                            log.WriteLine("Got EventId:  {0}", duty.GoogleCalendarEventId);
                        }
                        else
                        {
                            log.WriteLine("Updating EventId: {0}", duty.GoogleCalendarEventId);
                            try
                            {
                                gcal.UpdateEvent(dutyCalendarId, duty.GoogleCalendarEventId, duty.Name, duty.DateAndTime, TimeSpan.FromMinutes(duty.Duration), duty.Description);
                            }
                            catch (GoogleAPICall.GoogleAPIException gae)
                            {
                                log.WriteLine(gae.Message);
                                log.WriteLine(gae.InnerException.Message);
                                log.WriteLine("Creating New Event for {0}, {1} {2}", duty.Name, duty.DateAndTime.ToLongDateString(), duty.DateAndTime.ToShortTimeString());
                                duty.GoogleCalendarEventId = gcal.PostEventToCalendar(dutyCalendarId, duty.Name, duty.DateAndTime, TimeSpan.FromMinutes(duty.Duration), duty.Description);
                                log.WriteLine("Got EventId:  {0}", duty.GoogleCalendarEventId);
                            }
                        }

                        List <String> participants = gcal.GetEventParticipants(dutyCalendarId, duty.GoogleCalendarEventId);
                        foreach (Faculty adult in duty.DutyTeamMembers.ToList())
                        {
                            if (participants.Contains(adult.UserName))
                            {
                                log.WriteLine("{0} {1} is already assigned to this Event.", adult.FirstName, adult.LastName);
                                participants.Remove(adult.UserName);
                            }
                            else
                            {
                                gcal.AddEventParticipant(dutyCalendarId, duty.GoogleCalendarEventId, adult.UserName);
                                log.WriteLine("Added {0} {1} to this event.", adult.FirstName, adult.LastName);
                            }
                        }

                        foreach (String toRemove in participants)
                        {
                            gcal.RemoveParticipant(dutyCalendarId, duty.GoogleCalendarEventId, toRemove);
                            log.WriteLine("Removed no longer assigned adult {0}", toRemove);
                        }
                    }

                    foreach (WeekendActivity activity in weekend.WeekendActivities.ToList())
                    {
                        if (activity.GoogleCalendarEventId.Equals(""))
                        {
                            log.WriteLine("Creating New Event for {0}, {1} {2}", activity.Name, activity.DateAndTime.ToLongDateString(), activity.DateAndTime.ToShortTimeString());
                            activity.GoogleCalendarEventId = gcal.PostEventToCalendar(activitiesCalendarId, activity.Name, activity.DateAndTime, TimeSpan.FromMinutes(activity.Duration), activity.Description);
                            log.WriteLine("Got EventId:  {0}", activity.GoogleCalendarEventId);
                        }
                        else
                        {
                            log.WriteLine("Updating EventId: {0}", activity.GoogleCalendarEventId);
                            try
                            {
                                gcal.UpdateEvent(activitiesCalendarId, activity.GoogleCalendarEventId, activity.Name, activity.DateAndTime, TimeSpan.FromMinutes(activity.Duration), activity.Description);
                            }
                            catch (GoogleAPICall.GoogleAPIException gae)
                            {
                                log.WriteLine(gae.Message);
                                log.WriteLine(gae.InnerException.Message);
                                log.WriteLine("Creating New Event for {0}, {1} {2}", activity.Name, activity.DateAndTime.ToLongDateString(), activity.DateAndTime.ToShortTimeString());
                                activity.GoogleCalendarEventId = gcal.PostEventToCalendar(activitiesCalendarId, activity.Name, activity.DateAndTime, TimeSpan.FromMinutes(activity.Duration), activity.Description);
                                log.WriteLine("Got EventId:  {0}", activity.GoogleCalendarEventId);
                            }
                        }

                        List <String> participants = gcal.GetEventParticipants(activitiesCalendarId, activity.GoogleCalendarEventId).Where(un => !un.Contains("_")).ToList();
                        foreach (Faculty adult in activity.Adults.ToList())
                        {
                            if (participants.Contains(adult.UserName))
                            {
                                log.WriteLine("{0} {1} is already assigned to this Event.", adult.FirstName, adult.LastName);
                                participants.Remove(adult.UserName);
                            }
                            else
                            {
                                gcal.AddEventParticipant(activitiesCalendarId, activity.GoogleCalendarEventId, adult.UserName);
                                log.WriteLine("Added {0} {1} to this event.", adult.FirstName, adult.LastName);
                            }
                        }

                        foreach (String toRemove in participants)
                        {
                            gcal.RemoveParticipant(activitiesCalendarId, activity.GoogleCalendarEventId, toRemove);
                            log.WriteLine("Removed no longer assigned adult {0}", toRemove);
                        }
                    }
                }

                db.SaveChanges();
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Import Credits from Blackbaud.
        /// Use the Query named for this in Blackbaud.
        /// Returns a CSV contaning everything that was ignored or errored.
        /// </summary>
        /// <param name="creditCSV"></param>
        /// <returns></returns>
        public static CSV ImportCredits(CSV creditCSV)
        {
            CSV output = new CSV();

            using (WebhostEntities db = new WebhostEntities())
            {
                int newCreditId = db.Credits.Count() > 0 ? db.Credits.OrderBy(c => c.id).Select(c => c.id).ToList().Last() + 1 : 0;
                int year        = DateRange.GetCurrentAcademicYear();
                foreach (Dictionary <String, String> row in creditCSV.Data)
                {
                    String note      = String.Format("Imported {5} Credit for {0} taken {1} {2} - {3} {4}", row[Credit_CourseName], row[Credit_Term], row[Credit_AcademicYear], row[Credit_FirstName], row[Credit_LastName], row[Credit_Department]);
                    int    studentId = Convert.ToInt32(row[Credit_StudentId]);
                    if (db.Students.Where(s => s.ID == studentId).Count() <= 0)
                    {
                        output.Add(new Dictionary <string, string>()
                        {
                            { "Student", String.Format("{0} {1}", row[Credit_FirstName], row[Credit_LastName]) }, { "Error", "Not in Webhost" }
                        });
                        continue;
                    }
                    Student student = db.Students.Where(s => s.ID == studentId).Single();
                    if (student.Credits.Where(c => c.Notes.Equals(note)).Count() > 0)
                    {
                        output.Add(new Dictionary <string, string>()
                        {
                            { "Student", String.Format("{0} {1}", row[Credit_FirstName], row[Credit_LastName]) }, { "Error", String.Format("{3} Credit already exists for {0} taken {1} {2}", row[Credit_CourseName], row[Credit_Term], row[Credit_AcademicYear], row[Credit_Department]) }
                        });
                        continue; // Don't re-import the same credit more than once!
                    }


                    GradeTable CreditTypes;
                    GradeTable CreditValues;
                    try
                    {
                        CreditTypes  = db.GradeTables.Where(t => t.Name.Equals("Credit Types") && t.AcademicYearID == year).Single();
                        CreditValues = db.GradeTables.Where(t => t.Name.Equals("Credit Values") && t.AcademicYearID == year).Single();
                    }
                    catch
                    {
                        continue;
                    }

                    String dept = row[Credit_Department];
                    if (CreditTypes.GradeTableEntries.Where(t => dept.Contains(t.Name)).Count() <= 0)
                    {
                        output.Add(new Dictionary <string, string>()
                        {
                            { "Student", String.Format("{0} {1}", row[Credit_FirstName], row[Credit_LastName]) }, { "Error", String.Format("{3} No credit given for {0} taken {1} {2}", row[Credit_CourseName], row[Credit_Term], row[Credit_AcademicYear], row[Credit_Department]) }
                        });
                        continue;
                    }
                    Credit credit = new Credit()
                    {
                        StudentId     = studentId,
                        Notes         = note,
                        CreditTypeId  = CreditTypes.GradeTableEntries.Where(t => dept.Contains(t.Name)).Single().id,
                        CreditValueId = CreditValues.GradeTableEntries.Where(v => v.Value == 3).Single().id,
                        id            = newCreditId++
                    };

                    db.Credits.Add(credit);
                }

                db.SaveChanges();
            }

            return(output);
        }
Ejemplo n.º 27
0
            public GradeReport(int studentId)
            {
                using (WebhostEntities db = new WebhostEntities())
                {
                    Student student = db.Students.Find(studentId);
                    if (student == null)
                    {
                        throw new InvalidOperationException("No Student with ID:  " + studentId);
                    }

                    StudentId = studentId;
                    Grades    = new Dictionary <int, Grade>();

                    foreach (StudentComment comment in
                             student.StudentComments.Where(com =>
                                                           !com.FinalGrade.Name.Equals("Not Applicable") &&
                                                           !com.FinalGrade.Name.Equals("Pass") &&
                                                           !com.FinalGrade.Name.Equals("Fail")))
                    {
                        Grades.Add(comment.CommentHeader.Section.id, new Grade()
                        {
                            CreditWeight = comment.CommentHeader.Section.Course.LengthInTerms / 3f,
                            DisplayName  = comment.FinalGrade.Name,
                            Value        = comment.FinalGrade.Value / 100f
                        });
                    }

                    Dictionary <int, Grade> temp = new Dictionary <int, Grade>();

                    foreach (StudentComment comment in student.StudentComments.Where(com =>
                                                                                     com.FinalGrade.Name.Equals("Not Applicable") &&
                                                                                     !com.TermGrade.Name.Equals("Pass") &&
                                                                                     !com.TermGrade.Name.Equals("Fail") &&
                                                                                     !com.TermGrade.Name.Equals("Not Applicable")))
                    {
                        if (Grades.ContainsKey(comment.CommentHeader.SectionIndex))
                        {
                            continue; // already got the final grade from this section.
                        }
                        if (temp.ContainsKey(comment.CommentHeader.SectionIndex))
                        {
                            temp[comment.CommentHeader.SectionIndex].CombineGradePoints(new Grade()
                            {
                                CreditWeight = 1f / 3f, Value = comment.TermGrade.Value / 100f, DisplayName = comment.TermGrade.Name
                            });
                        }

                        else
                        {
                            temp.Add(comment.CommentHeader.SectionIndex, new Grade()
                            {
                                CreditWeight = 1f / 3f, Value = comment.TermGrade.Value / 100f, DisplayName = comment.TermGrade.Name
                            });
                        }
                    }

                    foreach (int key in temp.Keys)
                    {
                        Grades.Add(key, temp[key]);
                    }

                    // Calculate GPA
                    TotalCredits = 0f;
                    float totalGradePoints = 0f;

                    foreach (int sectionId in Grades.Keys)
                    {
                        TotalCredits     += Grades[sectionId].CreditWeight;
                        totalGradePoints += Grades[sectionId].Value * Grades[sectionId].CreditWeight;
                    }

                    GPA = totalGradePoints / TotalCredits;
                }
            }
Ejemplo n.º 28
0
        public static String HistoryWorldLanguageRequirementStatus(int studentId)
        {
            using (WebhostEntities db = new WebhostEntities())
            {
                List <Credit> historyCredits       = db.Credits.Where(c => c.StudentId == studentId && (c.CreditType.Name.Equals("History"))).ToList();
                List <Credit> worldLanguageCredits = db.Credits.Where(c => c.StudentId == studentId && (c.CreditType.Name.Equals("World Languages"))).ToList();
                float         histvalue            = 0f;
                foreach (Credit credit in historyCredits)
                {
                    histvalue += credit.CreditValue.Value / 9f;
                }

                bool hasLanguageWaiver = worldLanguageCredits.Where(c => c.Notes.Contains("Waiver")).Count() > 0;

                float wlvalue   = 0f;
                Regex languages = new Regex("French|Spanish|Latin|Mandarin");
                Dictionary <String, float> languageCounts = new Dictionary <string, float>();

                foreach (Credit credit in worldLanguageCredits)
                {
                    wlvalue += credit.CreditValue.Value / 9f;

                    String sectionName = credit.Notes;
                    if (credit.Sections.Count > 0)
                    {
                        sectionName += credit.Sections.Single().Course.Name;
                    }

                    if (languages.IsMatch(sectionName))
                    {
                        if (languageCounts.ContainsKey(languages.Match(sectionName).Value))
                        {
                            languageCounts[languages.Match(sectionName).Value] += credit.CreditValue.Value / 9f;
                        }
                        else
                        {
                            languageCounts.Add(languages.Match(sectionName).Value, credit.CreditValue.Value / 9f);
                        }
                    }
                }

                float value = histvalue + wlvalue;

                List <String> Required = new List <string>(RequiredHistoryCources);

                foreach (String course in RequiredHistoryCources)
                {
                    if (historyCredits.Where(c => c.Sections.Where(s => s.Course.Name.Contains(course)).Count() > 0).Count() > 0 || historyCredits.Where(c => c.Notes.Contains(course)).Count() > 0)
                    {
                        Required.Remove(course);
                    }
                }

                if (Required.Count > 0)
                {
                    String missing = "Missing: ";
                    foreach (String course in Required)
                    {
                        missing += String.Format("{0} ", course);
                    }

                    return(missing);
                }

                String response = "";

                if (histvalue >= (hasLanguageWaiver?4f:HistoryOnlyCreditsHonors))
                {
                    response = "History Honors Fulfilled, ";
                }
                else if (histvalue >= (hasLanguageWaiver?4f:HistoryOnlyCreditsRequired))
                {
                    response = "History Requirement Fulfilled, ";
                }
                else
                {
                    response = "History Requirement Incomplete, ";
                }

                if (hasLanguageWaiver)
                {
                    response += "Language Waiver";
                }
                else if (worldLanguageCredits.Count < 2)
                {
                    response += "World Languages Requirement Incomplete";
                }
                else
                {
                    if (languageCounts.Keys.Count == 1 &&
                        (float)Math.Round(languageCounts[languageCounts.Keys.Single()], 3) >= 3f)
                    {
                        response += "World Languages Honors Fulfilled.";
                    }
                    else
                    {
                        int atLeastTwo = 0;
                        foreach (String key in languageCounts.Keys)
                        {
                            if (languageCounts[key] >= 2f)
                            {
                                atLeastTwo++;
                            }
                        }

                        if (atLeastTwo >= 2f)
                        {
                            response += "World Languages Honors Fulfilled.";
                        }
                        else if (atLeastTwo >= 1f)
                        {
                            response += "World Language Requirement Fulfilled.";
                        }
                        else
                        {
                            response += "World Language Requirement Incomplete.";
                        }
                    }
                }

                if ((float)Math.Round(value, 3) >= HistoryWLCreditsHonors)
                {
                    response += String.Format("{0}Overall Honors Fulfilled.", Environment.NewLine);
                }
                else if ((float)Math.Round(value, 3) >= HistoryWLCreditsRequired)
                {
                    response += String.Format("{0}Overall Requirement Fulfilled.", Environment.NewLine);
                }
                else
                {
                    response += String.Format("{0}Overall Requirement Incomplete.", Environment.NewLine);
                }

                return(response);
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Assigns Default Credit Values for all classes for all students.  These credits may be modified later and will be passed over by this method if it is run again.
        /// </summary>
        /// <returns>CSV object containing all new credits which have been created.</returns>
        public static CSV AssignDefaultCredits()
        {
            CSV output = new CSV();

            using (WebhostEntities db = new WebhostEntities())
            {
                int newCreditId = db.Credits.Count() > 0? db.Credits.OrderBy(c => c.id).ToList().Last().id + 1 : 0;

                foreach (AcademicYear acadYear in db.AcademicYears.ToList())
                {
                    GradeTable CreditTypes;
                    GradeTable CreditValues;
                    try
                    {
                        CreditTypes  = acadYear.GradeTables.Where(t => t.Name.Equals("Credit Types")).Single();
                        CreditValues = acadYear.GradeTables.Where(t => t.Name.Equals("Credit Values")).Single();
                    }
                    catch
                    {
                        continue;
                    }
                    foreach (Course course in acadYear.Courses.Where(c => c.Sections.Count > 0).ToList())
                    {
                        if (CreditTypes.GradeTableEntries.Where(t => course.Department.Name.Contains(t.Name)).Count() <= 0)
                        {
                            WebhostEventLog.Syslog.LogInformation("Skipping nonsense credit for {0}", course.Name);
                            continue;
                        }
                        foreach (Section section in course.Sections.Where(s => s.Students.Count > 0).ToList())
                        {
                            GradeTableEntry creditType  = CreditTypes.GradeTableEntries.Where(t => course.Department.Name.Contains(t.Name)).Single();
                            GradeTableEntry creditValue = CreditValues.GradeTableEntries.Where(v => v.Value == course.LengthInTerms * 3).Single();

                            foreach (Student student in section.Students.ToList())
                            {
                                // if this student already has credit for this section, then don't do anything!  it may be that the credit has been altered.
                                if (student.Credits.Where(c => c.Sections.Contains(section)).Count() <= 0)
                                {
                                    WebhostEventLog.Syslog.LogInformation("Giving {0} {1} credit for [{2}] {3}", student.FirstName, student.LastName, section.Block.LongName, section.Course.Name);
                                    Credit credit = new Credit()
                                    {
                                        id            = newCreditId++,
                                        StudentId     = student.ID,
                                        CreditTypeId  = creditType.id,
                                        CreditValueId = creditValue.id,
                                        Student       = student,
                                        CreditType    = creditType,
                                        CreditValue   = creditValue,
                                        Notes         = "This is a default credit."
                                    };

                                    credit.Sections.Add(section);

                                    db.Credits.Add(credit);

                                    Dictionary <String, String> row = new Dictionary <string, string>()
                                    {
                                        { "Student", String.Format("{0} {1}", student.FirstName, student.LastName) },
                                        { "Credit Type", creditType.Name },
                                        { "Credit Value", creditValue.Name },
                                        { "Class", section.Course.Name },
                                        { "Year", acadYear.id.ToString() }
                                    };

                                    output.Add(row);
                                }
                                else
                                {
                                    WebhostEventLog.Syslog.LogInformation("{0} {1} already has credit for {2}. Nothing to do.", student.FirstName, student.LastName, section.Course.Name);
                                }
                            }
                        }
                    }
                }

                db.SaveChanges();
            }

            return(output);
        }