private void Save(Schedule schedule)
{
int numberOfRooms = Configuration.GetInstance.GetNumberOfRooms();
int daySize = schedule.day_Hours * numberOfRooms;
var db = new LINQDataContext();
db.Classroom_TimeDeleteAll();
foreach (KeyValuePair<CourseClass, int> it in schedule.GetClasses().ToList())
{
// coordinate of time-space slot
int pos = it.Value; // int pos of _slot array
int day = pos / daySize;
int time = pos % daySize; // this is not time now!
int room = time / schedule.day_Hours;
time = time % schedule.day_Hours; // this is a time now!
int dur = it.Key.GetDuration;
CourseClass cc = it.Key;
Algorithm.Room r = Configuration.GetInstance.GetRoomById(room);
//
// Save Classroom_Time
//
db.Classroom_TimeSave(r.Origin_ID_inDB, cc.Class_ID, cc.GetProfessor.GetId, time, dur, day);
//
// Save New_GroupsPerClassroom
//
foreach (var gs in cc.GetGroups)
{
db.New_GroupsPerClassSave(r.Origin_ID_inDB, cc.Class_ID, time, day, gs.GetId);
}
}
}