public SubjectBDO GetSubject(string subjectCode) { SubjectBDO sbdo = new SubjectBDO(); Subject subj = new Subject(); try { using (var DCEnt = new DCFIEntities()) { var sub = (from s in DCEnt.Subjects where s.SubjectCode == subjectCode select s).FirstOrDefault(); subj = sub; ConvertSubjectToSubjectBDO(subj, sbdo); } } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } } return sbdo; }
public Boolean UpdateSubject(ref SubjectBDO subjectBDO, ref string message) { message = "Subject updated successfully."; Boolean ret = true; using (var DCEnt = new DCFIEntities()) { var subjectCode = subjectBDO.SubjectCode; Subject subjectInDB = (from s in DCEnt.Subjects where s.SubjectCode == subjectCode select s).FirstOrDefault(); if (subjectInDB == null) { throw new Exception("No Subject with SubjectCode " + subjectBDO.SubjectCode); } DCEnt.Subjects.Remove(subjectInDB); subjectInDB.SubjectID = subjectBDO.SubjectID; subjectInDB.Description = subjectBDO.Description; subjectInDB.GradeLevel = subjectBDO.GradeLevel; subjectInDB.LearningAreaCode = subjectBDO.LearningAreaCode; subjectInDB.SubjectCode = subjectBDO.SubjectCode; DCEnt.Subjects.Attach(subjectInDB); DCEnt.Entry(subjectInDB).State = System.Data.Entity.EntityState.Modified; int num = DCEnt.SaveChanges(); if (num != 1) { ret = false; message = "No subject is updated."; } } return ret; }
public List<SubjectBDO> GetAllSbjects() { List<SubjectBDO> subjectBDOList = new List<SubjectBDO>(); List<Subject> subjectList = new List<Subject>(); try { using (var DCEnt = new DCFIEntities()) { var allSubjects = (DCEnt.Subjects); subjectList = allSubjects.ToList<Subject>(); foreach (Subject s in subjectList) { SubjectBDO subjectBDO = new SubjectBDO(); ConvertSubjectToSubjectBDO(s, subjectBDO); subjectBDOList.Add(subjectBDO); } } } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } } return subjectBDOList; }
public void ConvertSubjectAssignmentToSubjectAssignmentBDO(SubjectAssignment sa, SubjectAssignmentBDO sabdo) { sabdo.Deactivated = (bool)sa.Deactivated; GradeSectionDAO gd = new GradeSectionDAO(); GradeSectionBDO g = new GradeSectionBDO(); g = gd.GetGradeSectionBDO((int)sa.GradeSectionCode); sabdo.GradeSection = g; sabdo.GradeSectionCode = g.GradeSectionCode; RoomBDO r = new RoomBDO(); RoomDAO rd = new RoomDAO(); rd.ConvertRoomToRoomBDO(sa.Room, r); sabdo.Room = r; sabdo.RoomId = r.RoomId; SubjectDAO sd = new SubjectDAO(); SubjectBDO sb = new SubjectBDO(); sd.ConvertSubjectToSubjectBDO(sa.Subject, sb); sabdo.Subject = sb; sabdo.SubjectAssignmentsID = sa.SubjectAssignmentsID; sabdo.SubjectCode = sa.SubjectCode; sabdo.SY = sa.SY; TeacherDAO td = new TeacherDAO(); TeacherBDO tb = new TeacherBDO(); td.ConvertTeacherToTeacherBDO(sa.Teacher, tb); sabdo.Teacher = tb; sabdo.TeacherId = tb.TeacherId; TimeslotDAO tid = new TimeslotDAO(); TimeslotBDO tib = new TimeslotBDO(); tid.ConvertTimeslotToTimeslotBDO(sa.Timeslot, tib); sabdo.Timeslot = tib; sabdo.TimeSlotCode = tib.TimeSlotCode; sabdo.GradeLevel = g.GradeLevel; }
public void ConvertSubjectBDOToSubject(SubjectBDO sbdo, Subject s) { s.SubjectID = sbdo.SubjectID; s.Description = sbdo.Description; s.GradeLevel = sbdo.GradeLevel; s.LearningAreaCode = sbdo.LearningAreaCode; s.SubjectCode = sbdo.SubjectCode; }
public void ConvertSubjectToSubjectBDO(Subject s, SubjectBDO sbdo) { sbdo.Description = s.Description; sbdo.GradeLevel = s.GradeLevel; sbdo.LearningAreaCode = s.LearningAreaCode; sbdo.SubjectCode = s.SubjectCode; sbdo.SubjectID = s.SubjectID; sbdo.MPW = s.MPW; }
public void TranslateSubjectToSubjectBDO(Subject sub, SubjectBDO sbdo) { LearningAreaService las = new LearningAreaService(); LearningAreaBDO lb = new LearningAreaBDO(); sbdo.SubjectID = sub.SubjectID; sbdo.Description = sub.Description; sbdo.GradeLevel = sub.GradeLevel; sbdo.LearningAreaCode = sub.LearningAreaCode; sbdo.SubjectCode = sub.SubjectCode; las.TranslateLearningAreaToLearningAreaBDO(sub.LArea, lb); sbdo.LearningArea = lb; }
public void ConvertSubjectToSubjectBDO(Subject s, SubjectBDO sbdo) { LearningAreaDAO ldao = new LearningAreaDAO(); LearningAreaBDO la = new LearningAreaBDO(); sbdo.Description = s.Description; sbdo.GradeLevel = s.GradeLevel; sbdo.LearningAreaCode = s.LearningAreaCode; sbdo.SubjectCode = s.SubjectCode; sbdo.SubjectID = s.SubjectID; // ldao.ConvertLearningAreaToLearningAreaBDO(s.LearningArea, la); sbdo.LearningArea = la; }
public void TranslateSubjectBDOToSubject(SubjectBDO sub, Subject sbdo) { //LearningAreaService las = new LearningAreaService(); //LearningArea lb = new LearningArea(); sbdo.SubjectID = sub.SubjectID; sbdo.Description = sub.Description; sbdo.GradeLevel = sub.GradeLevel; sbdo.LearningAreaCode = sub.LearningAreaCode; sbdo.SubjectCode = sub.SubjectCode; sbdo.Academic = sub.Academic; sbdo.MPW = sub.MPW; // las.TranslateLearningAreaBDOToLearningArea(sub.LearningArea, lb); // sbdo.LArea = lb; }
public void ConvertSubjectBDOToSubject(SubjectBDO sbdo, Subject s) { //LearningAreaDAO ldao = new LearningAreaDAO(); //LearningArea l = new LearningArea();//s.LearningArea = sbdo.LearningArea; s.SubjectID = sbdo.SubjectID; s.Description = sbdo.Description; s.GradeLevel = sbdo.GradeLevel; s.LearningAreaCode = sbdo.LearningAreaCode; s.SubjectCode = sbdo.SubjectCode; s.MPW = sbdo.MPW; // ldao.ConvertLearningAreaBDOToLearningArea(sbdo.LearningArea, l); // s.LearningArea = l; }
public List<SubjectBDO> ToSubjectBDOList(List<Subject> sList) { List<SubjectBDO> slist = new List<SubjectBDO>(); foreach (Subject s in sList) { SubjectBDO sbdo = new SubjectBDO(); sbdo.LearningAreaCode = s.LearningAreaCode; sbdo.Description = s.Description; sbdo.GradeLevel = s.GradeLevel; sbdo.SubjectCode = s.SubjectCode; slist.Add(sbdo); } return slist; }
public SubjectBDO GetSubject(string subjectCode) { SubjectBDO sbdo = new SubjectBDO(); Subject subj = new Subject(); using (var DCEnt = new DCFIEntities()) { var sub = (from s in DCEnt.Subjects where s.SubjectCode == subjectCode select s).FirstOrDefault(); subj = sub; } ConvertSubjectToSubjectBDO(subj, sbdo); return sbdo; }
public void ConvertStuSubjectsToStuSubjectsBDO(StudentSubject s, StudentSubjectBDO sbdo) { StudentEnrolmentDAO sed = new StudentEnrolmentDAO(); StudentEnrollmentBDO sedb = new StudentEnrollmentBDO(); sed.ConvertEnrolToEnrolBDO(s.StudentEnrollment, sedb); sbdo.StudentEnrollment = sedb; StudentDAO sd = new StudentDAO(); StudentBDO sb = new StudentBDO(); sd.ConvertStudentToStudentBDO(s.StudentEnrollment.Student, sb); sbdo.StudentEnrollment.Student = sb; SubjectDAO subd = new SubjectDAO(); SubjectBDO sbo = new SubjectBDO(); subd.ConvertSubjectToSubjectBDO(s.Subject, sbo); sbdo.Subject = sbo; sbdo.StudentSY = s.StudentSY; sbdo.SubjectCode = s.SubjectCode; sbdo.StudentSubjectsID = s.StudentSubjectsID; sbdo.StudentEnrSubCode = s.StudentEnrSubCode; sbdo.Remarks = s.Remarks; sbdo.FirstPeriodicRating = s.FirstPeriodicRating; sbdo.SecondPeriodicRating = s.SecondPeriodicRating; sbdo.ThirdPeriodicRating = s.ThirdPeriodicRating; sbdo.FourthPeriodicRating = s.FourthPeriodicRating; sbdo.StudentEnrSubCode = s.StudentEnrSubCode; sbdo.SubjectAssignments = s.SubjectAssignments; sbdo.FirstEntered = s.FirstEntered; sbdo.SecondEntered = s.SecondEntered; sbdo.FourthEntered = s.FourthEntered; sbdo.ThirdEntered = s.ThirdEntered; sbdo.LockFirst = s.LockFirst; sbdo.LockSecond = s.LockSecond; sbdo.LockThird = s.LockThird; sbdo.LockFourth = s.LockFourth; sbdo.FirstLocked = s.FirstLocked; sbdo.SecondLocked = s.SecondLocked; sbdo.ThirdLocked = s.ThirdLocked; sbdo.FourthLocked = s.FourthLocked; }
public void ConvertLearningAreaToLearningAreaBDO(LearningArea la, LearningAreaBDO labdo) { // labdo.Subjects = GetSubjectsforLearningArea(la.LearningAreaCode); labdo.Academic = la.Academic; labdo.Description = la.Description; labdo.LearningAreaCode = la.LearningAreaCode; labdo.Units = la.Units; labdo.RatePerUnit = la.RatePerUnit; labdo.RatePerSubject = la.RatePerSubject; foreach (Subject s in la.Subjects) { SubjectBDO sb = new SubjectBDO(); ConvertSubjectToSubjectBDO(s, sb); sb.Academic =(bool) la.Academic; labdo.Subjects.Add(sb); } }
public List<SubjectBDO> GetAllSbjects() { List<Subject> subjectList = new List<Subject>(); using (var DCEnt = new DCFIEntities()) { var allSubjects = (DCEnt.Subjects); subjectList = allSubjects.ToList<Subject>(); } List<SubjectBDO> subjectBDOList = new List<SubjectBDO>(); foreach (Subject s in subjectList) { SubjectBDO subjectBDO = new SubjectBDO(); ConvertSubjectToSubjectBDO(s, subjectBDO); subjectBDOList.Add(subjectBDO); } return subjectBDOList; }
private List<CurriculumSubjectBDO> ToCurriculumSubjectBDOList(List<CurriculumSubject> csList) { List<CurriculumSubjectBDO> csbdoList = new List<CurriculumSubjectBDO>(); foreach (CurriculumSubject cs in csList) { SubjectDAO sDAO = new SubjectDAO(); SubjectBDO sbdo = new SubjectBDO(); CurriculumSubjectBDO csbdo = new CurriculumSubjectBDO(); csbdo.CurriculumCode = cs.CurriculumCode; csbdo.CurrSubCode = cs.CurrSubCode; csbdo.Deactivated = cs.Deactivated; csbdo.SubjectCode = cs.SubjectCode; sbdo = sDAO.GetSubject(cs.SubjectCode); csbdo.Sub = sbdo; csbdoList.Add(csbdo); } return csbdoList; }
public Boolean CreateSubject(ref SubjectBDO subjectBDO, ref string message) { message = "Subject Added Successfully"; bool ret = true; Subject s = new Subject(); ConvertSubjectBDOToSubject(subjectBDO, s); using (var DCEnt = new DCFIEntities()) { DCEnt.Subjects.Attach(s); DCEnt.Entry(s).State = System.Data.Entity.EntityState.Added; int num = DCEnt.SaveChanges(); if (num != 1) { ret = false; message = "Adding of Subject failed"; } } return ret; }
public Boolean CreateSubject(ref SubjectBDO subjectBDO, ref string message) { message = "Subject Added Successfully"; bool ret = true; Subject s = new Subject(); try { ConvertSubjectBDOToSubject(subjectBDO, s); using (var DCEnt = new DCFIEntities()) { DCEnt.Subjects.Attach(s); DCEnt.Entry(s).State = System.Data.Entity.EntityState.Added; int num = DCEnt.SaveChanges(); if (num != 1) { ret = false; message = "Adding of Subject failed"; } } } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } } return ret; }
public List<SubjectBDO> GetSubjectsforGradeLevel(string gradeLevel) { List<Subject> subjects = null; List<SubjectBDO> sbdoList = new List<SubjectBDO>(); using (var DCEnt = new DCFIEntities()) { subjects = (from s in DCEnt.Subjects where s.GradeLevel == gradeLevel select s).ToList<Subject>(); } foreach (Subject s in subjects) { SubjectBDO subjBDO = new SubjectBDO(); ConvertSubjectToSubjectBDO(s, subjBDO); sbdoList.Add(subjBDO); } return sbdoList; }
public Boolean UpdateSubject(ref SubjectBDO subjectBDO, ref string message) { message = "Subject updated successfully."; Boolean ret = true; try { using (var DCEnt = new DCFIEntities()) { var subjectCode = subjectBDO.SubjectCode; Subject subjectInDB = (from s in DCEnt.Subjects where s.SubjectCode == subjectCode select s).FirstOrDefault(); if (subjectInDB == null) { throw new Exception("No Subject with SubjectCode " + subjectBDO.SubjectCode); } DCEnt.Subjects.Remove(subjectInDB); subjectInDB.SubjectID = subjectBDO.SubjectID; subjectInDB.Description = subjectBDO.Description; subjectInDB.GradeLevel = subjectBDO.GradeLevel; subjectInDB.LearningAreaCode = subjectBDO.LearningAreaCode; subjectInDB.SubjectCode = subjectBDO.SubjectCode; subjectInDB.MPW = subjectBDO.MPW; DCEnt.Subjects.Attach(subjectInDB); DCEnt.Entry(subjectInDB).State = System.Data.Entity.EntityState.Modified; int num = DCEnt.SaveChanges(); if (num != 1) { ret = false; message = "No subject is updated."; } } } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } } return ret; }
public List<SubjectBDO> GetSubjectsforLearningArea(string learningAreaCode) { List<Subject> subjects = null; List<SubjectBDO> sbdoList = new List<SubjectBDO>(); using (var DCEnt = new DCFIEntities()) { subjects = (from s in DCEnt.Subjects where s.LearningAreaCode == learningAreaCode select s).ToList<Subject>(); } foreach (Subject s in subjects) { SubjectBDO subjBDO = new SubjectBDO(); ConvertSubjectToSubjectBDO(s, subjBDO); sbdoList.Add(subjBDO); } return sbdoList; }
public List<SubjectBDO> GetSubjectsforGradeLevel(string gradeLevel) { List<Subject> subjects = null; List<SubjectBDO> sbdoList = new List<SubjectBDO>(); try { using (var DCEnt = new DCFIEntities()) { subjects = (from s in DCEnt.Subjects where s.GradeLevel == gradeLevel select s).ToList<Subject>(); foreach (Subject s in subjects) { SubjectBDO subjBDO = new SubjectBDO(); ConvertSubjectToSubjectBDO(s, subjBDO); sbdoList.Add(subjBDO); } } } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } } return sbdoList; }
public List<SubjectBDO> ToSubjectBDOList(ICollection<Subject> slist) { List<SubjectBDO> sbdoList = new List<SubjectBDO>(); foreach (Subject s in slist) { SubjectBDO sbdo = new SubjectBDO(); ConvertSubjectToSubjectBDO(s, sbdo); sbdoList.Add(sbdo); } return sbdoList; }