public GradeSection GetGradeSection(int gradeSectionCode)
 {
     List<GradeSection> glist = new List<GradeSection>();
     glist = GetAllGradeSections();
     GradeSection g = new GradeSection();
     g = glist.Find(p => p.GradeSectionCode == gradeSectionCode);
     return g;
 }
 public void TranslateGradeSectionBDOToGradeSection(GradeSectionBDO gs, GradeSection gsb)
 {
     RoomService rService = new RoomService();
     Room room = new Room();
     TeacherService tService = new TeacherService();
     Teacher teacher = new Teacher();
     string message = string.Empty;
        room= rService.GetRoom(gs.HomeRoomNumber);
        teacher=  tService.GetTeacher(gs.HomeRoomTeacherId, ref message);
     gsb.Deactivated = gs.Deactivated;
     gsb.GradeLevel = gs.GradeLevel;
     gsb.GradeSectionCode = gs.GradeSectionCode;
     gsb.HomeRoom = room;
     gsb.HomeRoomNumber = gs.HomeRoomNumber;
     gsb.HomeRoomTeacherId = gs.HomeRoomTeacherId;
     gsb.HomeRoomTeacher = teacher;
     if(teacher.MiddleName==String.Empty)
        gsb.TeacherName = teacher.LastName + ", " + teacher.FirstName ;
     else
     gsb.TeacherName = teacher.LastName + ", " + teacher.FirstName + " " + teacher.MiddleName.Substring(0, 1);
     gsb.Class = gs.Class;
     gsb.SY = gs.SY;
     gsb.Section = gs.Section;
 }
 public bool CreateGradeSection(ref GradeSection gs, ref string message)
 {
     GradeSectionBDO gsb = new GradeSectionBDO();
     TranslateGradeSectionToGradeSectionBDO(gs, gsb);
     return gsLogic.CreateGradeSection(ref gsb, ref message);
 }
 private List<GradeSection> ToGradeSectionList(List<GradeSectionBDO> gb)
 {
     List<GradeSection> gsl = new List<GradeSection>();
     foreach (GradeSectionBDO g in gb) {
         GradeSection gs = new GradeSection();
         TranslateGradeSectionBDOToGradeSection(g, gs);
         gsl.Add(gs);
     }
     return gsl;
 }
 public void TranslateGradeSectionToGradeSectionBDO(GradeSection gs, GradeSectionBDO gsb)
 {
     gsb.Deactivated = gs.Deactivated;
     gsb.GradeLevel = gs.GradeLevel;
     gsb.GradeSectionCode = gs.GradeSectionCode;
     gsb.HomeRoomNumber = gs.HomeRoomNumber;
     gsb.HomeRoomTeacherId = gs.HomeRoomTeacherId;
     gsb.SY= gs.SY;
     gsb.Section = gs.Section;
     gsb.Class = gs.Class;
 }
        public void TranslateScheduleBDOToSchedule(SubjectAssignmentBDO sabdo, SubjectAssignment sched)
        {
            GradeSectionService gs = new GradeSectionService();
            GradeSection g = new GradeSection();
            gs.TranslateGradeSectionBDOToGradeSection(sabdo.GradeSection, g);
            sched.GradeSection = g;
            sched.Section = g.Section;
            sched.GradeLevel = g.GradeLevel;
            sched.Class = (int)g.Class;

            RoomService rs = new RoomService();
            Room r = new Room();
            rs.TranslateRoomBDOtoRoomDTO(sabdo.Room, r);
            sched.Room = r;
            sched.RoomCode = r.RoomCode;

            SubjectService ss = new SubjectService();
            Subject s = new Subject();
            ss.TranslateSubjectBDOToSubject(sabdo.Subject, s);
            sched.Subject = s;

            TeacherService ts = new TeacherService();
            Teacher t = new Teacher();
            ts.TranslateTeacherBDOToTeacherDTO(sabdo.Teacher, t);
            sched.Teacher = t;
            if (t.MiddleName == String.Empty)
                sched.TeacherName = t.LastName + ", " + t.FirstName;
            else
                sched.TeacherName = t.LastName + ", " + t.FirstName + " " + t.MiddleName.Substring(0, 1) + ".";

            TimeslotService times = new TimeslotService();
            Timeslot time = new Timeslot();
            times.TranslateTimeslotBDOToTimeslotDTo(sabdo.Timeslot, time);
            sched.Timeslot = time;
            sched.Timestart = time.TimeStart;
            sched.TimeEnd = time.TimeEnd;
            sched.Days = time.Days;

            sched.Deactivated = sabdo.Deactivated;
            sched.GradeSectionCode = sabdo.GradeSectionCode;
            sched.RoomId = sabdo.RoomId;
            sched.SubjectAssignmentsID = sabdo.SubjectAssignmentsID;
            sched.SubjectCode = sabdo.SubjectCode;

            sched.SY = sabdo.SY;
            sched.TeacherId = sabdo.TeacherId;
            sched.TimeSlotCode = sabdo.TimeSlotCode;

            sched.TimeslotInfo = time.Days + " " + time.TimeStart + "-" + time.TimeEnd;
            sched.SubjectInfo = sabdo.SubjectCode + " " + sched.Section + " " + sched.TimeslotInfo;

            sched.SubjectDescription = s.Description;
        }