Ejemplo n.º 1
0
 public CourseSemesterViewModel(CourseSemester m)
 {
     ID = m.ID;
     TypeValue = m.Semester.Type;
     Type = m.Semester.Type.ToString();
     Year = m.Semester.Year.ToString();
     Number = m.Course.Number;
     Name = m.Course.Name;
     StudentLimit = m.StudentLimit;
 }
Ejemplo n.º 2
0
        public CourseSemesterViewModel CourseSemester(CourseSemester courseSemester)
        {
            using (var ctx = new ApplicationDbContext())
            {
                if (courseSemester == null || courseSemester.Course == null || courseSemester.Semester == null ||
                    ctx.CourseSemesters.Where(m => m.Course.ID == courseSemester.Course.ID && m.Semester.Type == courseSemester.Semester.Type && m.Semester.Year == courseSemester.Semester.Year && m.IsActive).Any())
                {
                    //record already exists or data incomplete
                    return null;
                }

                courseSemester.Course = ctx.Courses.Find(courseSemester.Course.ID);
                courseSemester.Semester = ctx.Semesters.Find(courseSemester.Semester.Type, courseSemester.Semester.Year);

                ctx.CourseSemesters.Add(courseSemester);
                ctx.SaveChanges();

                return new CourseSemesterViewModel(courseSemester);
            }
        }
Ejemplo n.º 3
0
 public CourseSemesterViewModel(CourseSemester m, IEnumerable<RecommendationRecord> records)
     : this(m)
 {
     AssignedStudents = records.Count();
 }
        /// <summary>
        /// The writeResults class writes the Course Optimization run to the database.  The class takes in the optimization model, all students, all courses, 
        /// all semesters, all course/semster offerings, the dB context, the optimization variable (total slack for overbooked students across all course/
        /// semester offerings, and the RunName provided to the Optimization engine.  
        /// </summary>
        /// <param name="GRBModelData"></param>
        /// <param name="students"></param>
        /// <param name="courses"></param>
        /// <param name="sems"></param>
        /// <param name="crssems"></param>
        /// <param name="ctx"></param>
        /// <param name="ObjectiveValue"></param>
        /// <param name="RunName"></param>
        private static void writeResults(GRBVar[,,] GRBModelData, StudentPreference[] students, Course[] courses, Semester[] sems, CourseSemester[] crssems, ApplicationDbContext ctx, int ObjectiveValue, string RunName)
        {
            Recommendation rec = new Recommendation() { Name = RunName };
            rec.Records = new List<RecommendationRecord>();
            rec.StudentPreferences = students;
            rec.CourseSemesters = crssems;

            rec.MissingSeats = ObjectiveValue;
            for (int i = 0; i < students.Length; i++)
            {
                for (int j = 0; j < courses.Length; j++)
                {
                    for (int k = 0; k < sems.Length; k++)
                    {
                        try
                        {
                            if (GRBModelData[i, j, k].Get(GRB.DoubleAttr.X) == 1)
                                rec.Records.Add(new RecommendationRecord() { StudentPreference = students[i], CourseSemester = crssems.Single(m => m.Course == courses[j] && m.Semester == sems[k]) });
                        }
                        catch (GRBException e)
                        {
                        }
                    }
                }
            }
            ctx.Recommendations.Add(rec);
            ctx.SaveChanges();
        }