public LearningAreaBDO GetLearningArea(string learningAreaCode) { LearningAreaBDO laBDO = null; LearningArea l = new LearningArea(); try { using (var DCEnt = new DCFIEntities()) { var lA = (from learn in DCEnt.LearningAreas where learn.LearningAreaCode == learningAreaCode select learn).FirstOrDefault(); l = lA; if (l != null) { laBDO = new LearningAreaBDO(); ConvertLearningAreaToLearningAreaBDO(l, laBDO); } } } 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 laBDO; }
public Boolean CreateSY(ref SchoolYearBDO syBDO, ref string message) { message = "School Year Added Successfully"; bool ret = true; SchoolYear u = new SchoolYear() { SY = syBDO.SY, CurrentSY = syBDO.CurrentSY }; using (var DCEnt = new DCFIEntities()) { DCEnt.SchoolYears.Attach(u); DCEnt.Entry(u).State = System.Data.Entity.EntityState.Added; int num = DCEnt.SaveChanges(); syBDO.SY = u.SY; if (num != 1) { ret = false; message = "Adding of School Year failed"; } } return ret; }
public Boolean CreateBuilding(ref BuildingBDO buildBDO, ref string message) { message = "Building Added Successfully"; bool ret = true; try { Building b = new Building(); ConvertBuildingBDOToBuilding(buildBDO,b); using (var DCEnt = new DCFIEntities()) { DCEnt.Buildings.Add(b); DCEnt.Entry(b).State = System.Data.Entity.EntityState.Added; int num = DCEnt.SaveChanges(); buildBDO.BuildingCode = b.BuildingCode; if (num < 1) { ret = false; message = "Adding of Building 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<RoomBDO> GetAllRooms() { List<Room> roomList = new List<Room>(); List<RoomBDO> roomBDOList = new List<RoomBDO>(); try { using (var DCEnt = new DCFIEntities()) { var allRooms = (DCEnt.Rooms); roomList = allRooms.ToList<Room>(); } foreach (Room r in roomList) { RoomBDO roomBDO = new RoomBDO(); ConvertRoomToRoomBDO(r, roomBDO); roomBDOList.Add(roomBDO); } } 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 roomBDOList; }
public Boolean DeleteUser(int userId, ref string message) { message = "User Deleted successfully."; Boolean ret = true; using (var DCEnt = new DCFIEntities()) { User userInDB = (from u in DCEnt.Users where u.UserId == userId select u).FirstOrDefault(); if (userInDB == null) { throw new Exception("No user with ID " + userId); } DCEnt.Users.Remove(userInDB); DCEnt.Entry(userInDB).State = System.Data.Entity.EntityState.Deleted; int num = DCEnt.SaveChanges(); if (num != 1) { ret = false; message = "Deletion of User Failed."; } } return(ret); }
public List <PaymentDetailsBDO> GetAllPaymentDetails() { List <PaymentDetail> paymentDetailsList = new List <PaymentDetail>(); List <PaymentDetailsBDO> paymentDetailsBDOList = new List <PaymentDetailsBDO>(); try { using (var DCEnt = new DCFIEntities()) { var allPaymentDetails = (DCEnt.PaymentDetails); paymentDetailsList = allPaymentDetails.ToList <PaymentDetail>(); } foreach (PaymentDetail pd in paymentDetailsList) { PaymentDetailsBDO paymentDetailsBDO = new PaymentDetailsBDO(); ConvertPaymentDetailsToPaymentDetailsBDO(pd, paymentDetailsBDO); paymentDetailsBDOList.Add(paymentDetailsBDO); } } 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(paymentDetailsBDOList); }
public SubjectAssignmentBDO GetScheduleInfo(int sAi) { SchoolYearDAO syd = new SchoolYearDAO(); currentSY = syd.CurrentSY(); SubjectAssignment schedInfo = new SubjectAssignment(); SubjectAssignmentBDO saBDO = new SubjectAssignmentBDO(); try { using (var DCEnt = new DCFIEntities()) { schedInfo = (from sched in DCEnt.SubjectAssignments where sched.Deactivated == false && sched.SY.Equals(currentSY) && sched.SubjectAssignmentsID == sAi select sched).FirstOrDefault <SubjectAssignment>(); ConvertSubjectAssignmentToSubjectAssignmentBDO(schedInfo, saBDO); } } 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(saBDO); }
public List <StudentAssessmentBDO> GetAllAssessments() { List <StudentAssessmentBDO> assessBDOList = new List <StudentAssessmentBDO>(); List <StudentAssessment> assesList = new List <StudentAssessment>(); try { using (var DCEnt = new DCFIEntities()) { var allAssessments = (DCEnt.StudentAssessments); assesList = allAssessments.ToList <StudentAssessment>(); } foreach (StudentAssessment a in assesList) { StudentAssessmentBDO assessBDO = new StudentAssessmentBDO(); ConvertAssessToAssessBDO(a, assessBDO); assessBDOList.Add(assessBDO); } } 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(assessBDOList); }
// DCEnt.Scholarships.Remove(sInDB); // sInDB.Condition = sBDO.Condition; // sInDB.Deactivated = sBDO.Deactivated; // sInDB.Description = sBDO.Description; // sInDB.Privilege = sBDO.Privilege; // sInDB.ScholarshipCode = sBDO.ScholarshipCode; // DCEnt.Scholarships.Attach(sInDB); // DCEnt.Entry(sInDB).State = System.Data.Entity.EntityState.Modified; // int num = DCEnt.SaveChanges(); // if (num != 1) // { // ret = false; // message = "No scholarship is updated."; // } //} //return ret; public Boolean UpdateScholarshipDiscount(ref ScholarshipDiscountBDO sBDO, ref string message) { message = "Scholarship discount updated successfully."; Boolean ret = true; using (var DCEnt = new DCFIEntities()) { var scholarshipCode = sBDO.ScholarshipCode; ScholarshipDiscount sInDB = (from s in DCEnt.ScholarshipDiscounts where s.ScholarshipCode == scholarshipCode select s).FirstOrDefault(); if (sInDB == null) { throw new Exception("No Scholarship discount with ScholarshipCode " + sBDO.ScholarshipCode); } DCEnt.ScholarshipDiscounts.Remove(sInDB); sInDB.FeeCode = sBDO.FeeCode; sInDB.Deactivated = sBDO.Deactivated; sInDB.Discount = sBDO.Discount; sInDB.ScholarshipCode = sBDO.ScholarshipCode; DCEnt.ScholarshipDiscounts.Attach(sInDB); DCEnt.Entry(sInDB).State = System.Data.Entity.EntityState.Modified; int num = DCEnt.SaveChanges(); if (num != 1) { ret = false; message = "No scholarship discount is updated."; } } return(ret); }
//Changed public FeeBDO GetFeeForAll(string currSY) { Fee fe = new Fee(); FeeBDO fb = new FeeBDO(); try { using (var DCEnt = new DCFIEntities()) { fe = (from f in DCEnt.Fees where f.GradeLevel.Equals("0") && f.SYImplemented.Equals(currSY) select f).FirstOrDefault(); } ConvertFeeToFeeBDO(fe, fb); } 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(fb); }
public FeeBDO GetFee(int FeeId) { Fee fe = new Fee(); FeeBDO fb = new FeeBDO(); try { using (var DCEnt = new DCFIEntities()) { fe = (from f in DCEnt.Fees where f.FeeID == FeeId select f).FirstOrDefault(); } ConvertFeeToFeeBDO(fe, fb); } 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(fb); }
public List <FeeBDO> GetAllFees() { List <FeeBDO> fBDOList = new List <FeeBDO>(); List <Fee> fList = new List <Fee>(); try { using (var DCEnt = new DCFIEntities()) { var allFees = (DCEnt.Fees); fList = allFees.ToList <Fee>(); } fBDOList = ToFeeBDOList(fList); } 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(fBDOList); }
//Changed public List <FeeBDO> GetAllFees(string gradeLevel, string currSY) { List <Fee> fList = new List <Fee>(); List <FeeBDO> fBDOList = new List <FeeBDO>(); try { using (var DCEnt = new DCFIEntities()) { var allFees = (from f in DCEnt.Fees where f.GradeLevel.Equals(gradeLevel) && f.SYImplemented.Equals(currSY) select f); fList = allFees.ToList <Fee>(); } fBDOList = ToFeeBDOList(fList); } 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(fBDOList); }
public Timeslot GetTimeSlot(string timeslotCode) { Timeslot timeslot = new Timeslot(); timeslot = null; try { using (var DCEnt = new DCFIEntities()) { timeslot = (from t in DCEnt.Timeslots where t.TimeSlotCode == timeslotCode select t).FirstOrDefault(); } } 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 timeslot; }
public Boolean DeleteScholarshipDiscount(string sdCode, string scholarshipCode) { //message = "User Deleted successfully."; Boolean ret = true; using (var DCEnt = new DCFIEntities()) { ScholarshipDiscount sdInDB = (from sd in DCEnt.ScholarshipDiscounts where sd.ScholarshipCode == scholarshipCode && sd.ScholarshipFeeCode == sdCode select sd).FirstOrDefault(); if (sdInDB == null) { throw new Exception("No Scholarship Discount with ID " + sdCode); } DCEnt.ScholarshipDiscounts.Remove(sdInDB); DCEnt.Entry(sdInDB).State = System.Data.Entity.EntityState.Deleted; int num = DCEnt.SaveChanges(); if (num != 1) { ret = false; //message = "Deletion of User Failed."; } } return ret; }
public Boolean DeleteScholarshipDiscount(string sdCode, string scholarshipCode) { //message = "User Deleted successfully."; Boolean ret = true; using (var DCEnt = new DCFIEntities()) { ScholarshipDiscount sdInDB = (from sd in DCEnt.ScholarshipDiscounts where sd.ScholarshipCode == scholarshipCode && sd.ScholarshipFeeCode == sdCode select sd).FirstOrDefault(); if (sdInDB == null) { throw new Exception("No Scholarship Discount with ID " + sdCode); } DCEnt.ScholarshipDiscounts.Remove(sdInDB); DCEnt.Entry(sdInDB).State = System.Data.Entity.EntityState.Deleted; int num = DCEnt.SaveChanges(); if (num != 1) { ret = false; //message = "Deletion of User Failed."; } } return(ret); }
public Boolean CreateFee(ref FeeBDO fBDO, ref string message) { message = "Fee Added Successfully"; bool ret = true; Fee f = new Fee(); try { ConvertFeeBDOToFee(fBDO, f); using (var DCEnt = new DCFIEntities()) { DCEnt.Fees.Attach(f); DCEnt.Entry(f).State = System.Data.Entity.EntityState.Added; int num = DCEnt.SaveChanges(); if (num != 1) { ret = false; message = "Adding of Fee 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> 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 Boolean CreateCurriculum(ref CurriculumBDO cbdo, ref string message) { message = "Curriculum Added Successfully"; bool ret = true; Curriculum cur = new Curriculum(); try { ConvertCurriculumBDOToCurriculum(cbdo, cur); using (var DCEnt = new DCFIEntities()) { DCEnt.Curriculums.Add(cur); DCEnt.Entry(cur).State = System.Data.Entity.EntityState.Added; int num = DCEnt.SaveChanges(); if (num == 0) { ret = false; message = "Adding of Curriculum 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>(); 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<CurriculumSubjectBDO> GetCurriculumSubjects(string curriculumCode) { List<CurriculumSubject> csList = new List<CurriculumSubject>(); List<CurriculumSubjectBDO> csbList = new List<CurriculumSubjectBDO>(); try { using (var DCEnt = new DCFIEntities()) { var allCurrSub = (from cSub in DCEnt.CurriculumSubjects where cSub.CurriculumCode == curriculumCode select cSub).ToList<CurriculumSubject>(); csList = allCurrSub; csbList = ToCurriculumSubjectBDOList(csList); } } 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 csbList; }
public LearningAreaBDO GetLearningArea(string learningAreaCode) { LearningAreaBDO laBDO = null; LearningArea l = new LearningArea(); try { using (var DCEnt = new DCFIEntities()) { var lA = (from learn in DCEnt.LearningAreas where learn.LearningAreaCode == learningAreaCode select learn).FirstOrDefault(); l = lA; } if (l != null) { laBDO = new LearningAreaBDO(); laBDO.Academic = l.Academic; } } 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(laBDO); }
public Boolean CreateGradeSection(ref GradeSectionBDO gsBDO, ref string message) { message = "Grade Section Added Successfully"; bool ret = true; GradeSection gs = new GradeSection(); try{ ConvertGradeSectionBDOToGradeSection(gsBDO, gs); using (var DCEnt = new DCFIEntities()) { DCEnt.GradeSections.Attach(gs); DCEnt.Entry(gs).State = System.Data.Entity.EntityState.Added; int num = DCEnt.SaveChanges(); if (num != 1) { ret = false; message = "Adding of Grade Section 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 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 List <FeeBDO> GetAllFeesForGradeLevel(string gradeLevel) { FeeDAO fdao = new FeeDAO(); List <Fee> studentFees = null; List <FeeBDO> sfbdoList = new List <FeeBDO>(); try { using (var DCEnt = new DCFIEntities()) { studentFees = (from sf in DCEnt.Fees where sf.GradeLevel == gradeLevel select sf).ToList <Fee>(); } foreach (Fee s in studentFees) { FeeBDO sBDO = new FeeBDO(); fdao.ConvertFeeToFeeBDO(s, sBDO); sfbdoList.Add(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(sfbdoList); }
public List<StudentEnrollmentBDO> GetAllEnrollmentsForSy(string sy) { List<StudentEnrollment> enrolList = new List<StudentEnrollment>(); List<StudentEnrollmentBDO> enrolBDOList = new List<StudentEnrollmentBDO>(); try { using (var DCEnt = new DCFIEntities()) { var allEnrols = (from enrol in DCEnt.StudentEnrollments where enrol.SY == sy select enrol); enrolList = allEnrols.ToList<StudentEnrollment>(); } foreach (StudentEnrollment a in enrolList) { StudentEnrollmentBDO enrolBDO = new StudentEnrollmentBDO(); ConvertEnrolToEnrolBDO(a, enrolBDO); enrolBDOList.Add(enrolBDO); } } 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 enrolBDOList; }
public BuildingBDO GetBuildingBDO(string buildingCode) { BuildingBDO buildingBDO = null; try { using (var DCEnt = new DCFIEntities()) { Building bldg = (from b in DCEnt.Buildings where b.BuildingCode == buildingCode select b).FirstOrDefault(); if (bldg != null) { buildingBDO = new BuildingBDO(); ConvertBuildingToBuildingBDO(bldg, buildingBDO); } } }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 buildingBDO; }
public List <StudentEnrollmentBDO> GetAllEnrollments() { List <StudentEnrollmentBDO> enrolBDOList = new List <StudentEnrollmentBDO>(); List <StudentEnrollment> enrolList = new List <StudentEnrollment>(); try { using (var DCEnt = new DCFIEntities()) { var allEnrols = (DCEnt.StudentEnrollments); enrolList = allEnrols.ToList <StudentEnrollment>(); } foreach (StudentEnrollment a in enrolList) { StudentEnrollmentBDO enrolBDO = new StudentEnrollmentBDO(); ConvertEnrolToEnrolBDO(a, enrolBDO); enrolBDOList.Add(enrolBDO); } } 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(enrolBDOList); }
public UserBDO GetUserBDO(int userId) { UserBDO userBDO = null; UserTypeBDO utype = null; using (var DCEnt = new DCFIEntities()) { User user = (from u in DCEnt.Users where u.UserId == userId select u).FirstOrDefault(); if (user != null) { utype = new UserTypeBDO() { UserTypeCode = user.UserTypeCode }; userBDO = new UserBDO() { UserId = user.UserId, UserName = user.UserName, Password = user.Password, LastName = user.LastName, FirstName = user.UserName, MiddleName = user.MiddleName, UserType = utype }; } } return userBDO; }
public List <string> GetEnrolledIdsforNewTraits(string gradelevel, string sy) { List <StudentEnrollment> result = new List <StudentEnrollment>(); List <string> ids = new List <string>(); try { using (var DCEnt = new DCFIEntities()) { var res = (from e in DCEnt.StudentEnrollments where e.SY.Equals(sy) && e.GradeLevel.Equals(gradelevel) select e); result = res.ToList <StudentEnrollment>(); } foreach (StudentEnrollment s in result) { ids.Add(s.StudentId); } } 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(ids); }
public Boolean DeleteSY(string schoolyear, ref string message) { message = "SY " + schoolyear + " Deleted successfully."; Boolean ret = true; using (var DCEnt = new DCFIEntities()) { SchoolYear SYInDB = (from u in DCEnt.SchoolYears where u.SY == schoolyear select u).FirstOrDefault(); if (SYInDB == null) { throw new Exception("No SY " + schoolyear + " existed"); } DCEnt.SchoolYears.Remove(SYInDB); DCEnt.Entry(SYInDB).State = System.Data.Entity.EntityState.Deleted; int num = DCEnt.SaveChanges(); if (num != 1) { ret = false; message = "Deletion of SY Failed."; } } return ret; }
public StudentEnrollmentBDO GetStudentEnrolment(string studID, string sy) { string id = String.Empty; id = studID + sy; StudentEnrollment sa = null; StudentEnrollmentBDO enrolBDO = new StudentEnrollmentBDO(); try { using (var DCEnt = new DCFIEntities()) { sa = (from enrol in DCEnt.StudentEnrollments where enrol.StudentSY == id select enrol).FirstOrDefault(); } ConvertEnrolToEnrolBDO(sa, enrolBDO); } 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(enrolBDO); }
public Boolean UpdateGradeLevel(ref GradeLevelBDO gBDO, ref string message) { message = "Grade Level updated successfully."; Boolean ret = true; using (var DCEnt = new DCFIEntities()) { var gCode = gBDO.GradeLev; GradeLevel gInDB = (from g in DCEnt.GradeLevels where g.GradeLevel1 == gCode select g).FirstOrDefault(); if (gInDB == null) { throw new Exception("No Grade Level " + gBDO.GradeLev); } DCEnt.GradeLevels.Remove(gInDB); gInDB.GradeLevel1 = gBDO.GradeLev; gInDB.Description = gBDO.Description; DCEnt.GradeLevels.Attach(gInDB); DCEnt.Entry(gInDB).State = System.Data.Entity.EntityState.Modified; int num = DCEnt.SaveChanges(); if (num != 1) { ret = false; message = "No grade level is updated."; } } return(ret); }
public Boolean UpdateTrait(ref TraitBDO tBDO, ref string message) { message = "Trait updated successfully."; Boolean ret = true; using (var DCEnt = new DCFIEntities()) { var traitCode = tBDO.TraitCode; Trait tInDB = (from t in DCEnt.Traits where t.TraitCode == traitCode select t).FirstOrDefault(); if (tInDB == null) { throw new Exception("No Trait with TraitCode " + tBDO.TraitCode); } DCEnt.Traits.Remove(tInDB); tInDB.Description = tBDO.Description; tInDB.GradeLevel = tBDO.GradeLevel; tInDB.TraitCode = tBDO.TraitCode; DCEnt.Traits.Attach(tInDB); DCEnt.Entry(tInDB).State = System.Data.Entity.EntityState.Modified; int num = DCEnt.SaveChanges(); if (num != 1) { ret = false; message = "No trait is updated."; } } return(ret); }
public List<FeeBDO> GetAllFees() { List<FeeBDO> fBDOList = new List<FeeBDO>(); List<Fee> fList = new List<Fee>(); try { using (var DCEnt = new DCFIEntities()) { var allFees = (DCEnt.Fees); fList = allFees.ToList<Fee>(); } fBDOList = ToFeeBDOList(fList); } 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 fBDOList; }
public RoomBDO GetRoom(string roomCode) { Room room = null; RoomBDO roomBDO = new RoomBDO(); try { using (var DCEnt = new DCFIEntities()) { room = (from r in DCEnt.Rooms where r.RoomCode == roomCode select r).FirstOrDefault(); } ConvertRoomToRoomBDO(room,roomBDO); } 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 roomBDO; }
public PaymentDetailsBDO GetPaymentDetails(int ORNo) { PaymentDetail paymentDetail = null; PaymentDetailsBDO paymentDetailsBDO = new PaymentDetailsBDO(); try { using (var DCEnt = new DCFIEntities()) { paymentDetail = (from pd in DCEnt.PaymentDetails where pd.ORNo == ORNo select pd).FirstOrDefault(); } ConvertPaymentDetailsToPaymentDetailsBDO(paymentDetail, paymentDetailsBDO); } 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(paymentDetailsBDO); }
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 List<StudentSubjectBDO> GetAllStudentSubjects() { List<StudentSubjectBDO> subjectBDOList = new List<StudentSubjectBDO>(); List<StudentSubject> subjectList = new List<StudentSubject>(); try { using (var DCEnt = new DCFIEntities()) { var allStudentSubjects = (DCEnt.StudentSubjects); subjectList = allStudentSubjects.ToList<StudentSubject>(); foreach (StudentSubject s in subjectList) { StudentSubjectBDO subjectBDO = new StudentSubjectBDO(); ConvertStuSubjectsToStuSubjectsBDO(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 Boolean CreateTrait(ref TraitBDO tBDO, ref string message) { message = "Trait Added Successfully"; bool ret = true; Trait t = new Trait(); try { ConvertTraitBDOToTrait(tBDO, t); using (var DCEnt = new DCFIEntities()) { DCEnt.Traits.Attach(t); DCEnt.Entry(t).State = System.Data.Entity.EntityState.Added; int num = DCEnt.SaveChanges(); if (num != 1) { ret = false; message = "Adding of Trait 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<CurriculumBDO> GetAllCurriculums() { List<Curriculum> currList = new List<Curriculum>(); List<CurriculumBDO> currBDOList = new List<CurriculumBDO>(); try { using (var DCEnt = new DCFIEntities()) { var allCurr = (DCEnt.Curriculums); currList = allCurr.ToList<Curriculum>(); foreach (Curriculum c in currList) { CurriculumBDO currBDO = new CurriculumBDO(); ConvertCurriculumToCurriculumBDO(c, currBDO); currBDOList.Add(currBDO); } } } 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 currBDOList; }
public List<TraitBDO> GetAllTraits() { List<Trait> tList = new List<Trait>(); List<TraitBDO> tBDOList = new List<TraitBDO>(); try { using (var DCEnt = new DCFIEntities()) { var allTraits = (DCEnt.Traits); tList = allTraits.ToList<Trait>(); } foreach (Trait t in tList) { TraitBDO tBDO = new TraitBDO(); ConvertTraitToTraitBDO(t, tBDO); tBDOList.Add(tBDO); } } 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 tBDOList; }
public List<LogBDO> GetAllLogs() { List<LogBDO> logblist = new List<LogBDO>(); List<Log> logslist = new List<Log>(); try { using (var DCEnt = new DCFIEntities()) { var allLogs = (DCEnt.Logs); logslist = allLogs.ToList<Log>(); foreach (Log b in logslist) { LogBDO lBDO = new LogBDO(); ConvertLogToLogBDO(b, lBDO); logblist.Add(lBDO); } } } 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 logblist; }
public List <RoomBDO> GetAllRooms() { List <Room> roomList = new List <Room>(); List <RoomBDO> roomBDOList = new List <RoomBDO>(); try { using (var DCEnt = new DCFIEntities()) { var allRooms = (DCEnt.Rooms); roomList = allRooms.ToList <Room>(); } foreach (Room r in roomList) { RoomBDO roomBDO = new RoomBDO(); ConvertRoomToRoomBDO(r, roomBDO); roomBDOList.Add(roomBDO); } } 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(roomBDOList); }
public Boolean UpdateGradeLevel(ref GradeLevelBDO gBDO, ref string message) { message = "Grade Level updated successfully."; Boolean ret = true; using (var DCEnt = new DCFIEntities()) { var gCode = gBDO.GradeLev; GradeLevel gInDB = (from g in DCEnt.GradeLevels where g.GradeLevel1 == gCode select g).FirstOrDefault(); if (gInDB == null) { throw new Exception("No Grade Level " + gBDO.GradeLev); } DCEnt.GradeLevels.Remove(gInDB); gInDB.GradeLevel1 = gBDO.GradeLev; gInDB.Description = gBDO.Description; DCEnt.GradeLevels.Attach(gInDB); DCEnt.Entry(gInDB).State = System.Data.Entity.EntityState.Modified; int num = DCEnt.SaveChanges(); if (num != 1) { ret = false; message = "No grade level is updated."; } } return ret; }
public RoomBDO GetRoom(string roomCode) { Room room = null; RoomBDO roomBDO = new RoomBDO(); try { using (var DCEnt = new DCFIEntities()) { room = (from r in DCEnt.Rooms where r.RoomCode == roomCode select r).FirstOrDefault(); } ConvertRoomToRoomBDO(room, roomBDO); } 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(roomBDO); }
public Boolean CreateUser(ref UserBDO userBDO, ref string message) { message = "User Added Successfully"; bool ret = true; UserType ut = new UserType() { UserType1 = userBDO.UserType.UsersType, UserTypeCode = userBDO.UserType.UserTypeCode }; User u = new User() { UserName = userBDO.UserName, Password = userBDO.Password, LastName = userBDO.LastName, FirstName = userBDO.FirstName, MiddleName = userBDO.MiddleName, UserTypeCode = userBDO.UserType.UserTypeCode, UserType = ut }; using (var DCEnt = new DCFIEntities()) { DCEnt.Users.Attach(u); DCEnt.Entry(u).State = System.Data.Entity.EntityState.Added; int num = DCEnt.SaveChanges(); userBDO.UserId = u.UserId; if (num != 1) { ret = false; message = "Adding of User failed"; } } return(ret); }
public Boolean ActivateUser(int userId, ref string message) { message = "User Activated successfully."; Boolean ret = true; using (var DCEnt = new DCFIEntities()) { User userInDB = (from u in DCEnt.Users where u.UserId == userId select u).FirstOrDefault(); if (userInDB == null) { throw new Exception("No user with ID " + userId); } DCEnt.Users.Remove(userInDB); userInDB.Deactivated = false; DCEnt.Users.Attach(userInDB); DCEnt.Entry(userInDB).State = System.Data.Entity.EntityState.Modified; int num = DCEnt.SaveChanges(); if (num != 1) { ret = false; message = "Activation Failed."; } } return ret; }
public UserBDO GetUserBDO(int userId) { UserBDO userBDO = null; UserTypeBDO utype = null; using (var DCEnt = new DCFIEntities()) { User user = (from u in DCEnt.Users where u.UserId == userId select u).FirstOrDefault(); if (user != null) { utype = new UserTypeBDO() { UserTypeCode = user.UserTypeCode }; userBDO = new UserBDO() { UserId = user.UserId, UserName = user.UserName, Password = user.Password, LastName = user.LastName, FirstName = user.UserName, MiddleName = user.MiddleName, UserType = utype }; } } return(userBDO); }
public Boolean CreateUser(ref UserBDO userBDO, ref string message) { message = "User Added Successfully"; bool ret = true; UserType ut = new UserType() { UserType1 = userBDO.UserType.UsersType, UserTypeCode = userBDO.UserType.UserTypeCode }; User u = new User() { UserName = userBDO.UserName, Password = userBDO.Password, LastName = userBDO.LastName, FirstName = userBDO.FirstName, MiddleName = userBDO.MiddleName, UserTypeCode = userBDO.UserType.UserTypeCode, UserType = ut }; using (var DCEnt = new DCFIEntities()) { DCEnt.Users.Attach(u); DCEnt.Entry(u).State = System.Data.Entity.EntityState.Added; int num = DCEnt.SaveChanges(); userBDO.UserId = u.UserId; if (num != 1) { ret = false; message = "Adding of User failed"; } } return ret; }
public List <TraitBDO> GetAllTraitsForGradeLevel(int cat) { TraitDAO td = new TraitDAO(); List <Trait> studentTraits = null; List <TraitBDO> tbdoList = new List <TraitBDO>(); try { using (var DCEnt = new DCFIEntities()) { studentTraits = (from t in DCEnt.Traits where t.Category == cat select t).ToList <Trait>(); } foreach (Trait t in studentTraits) { TraitBDO tBDO = new TraitBDO(); td.ConvertTraitToTraitBDO(t, tBDO); tbdoList.Add(tBDO); } } 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(tbdoList); }
public List<GradeSectionBDO> GetAllGradeSections(string currentSY) { List<GradeSection> gsList = new List<GradeSection>(); List<GradeSectionBDO> gsBDOList = new List<GradeSectionBDO>(); try { using (var DCEnt = new DCFIEntities()) { var allGradeSections = (from gs in DCEnt.GradeSections where gs.SY == currentSY orderby gs.GradeLevel, gs.Class select gs); gsList = allGradeSections.ToList<GradeSection>(); foreach (GradeSection gs in gsList) { GradeSectionBDO gsBDO = new GradeSectionBDO(); ConvertGradeSectionToGradeSectionBDO(gs, gsBDO); gsBDOList.Add(gsBDO); } } } 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 gsBDOList; }
public Boolean UpdateTrait(ref TraitBDO tBDO, ref string message) { message = "Trait updated successfully."; Boolean ret = true; using (var DCEnt = new DCFIEntities()) { var traitCode = tBDO.TraitCode; Trait tInDB = (from t in DCEnt.Traits where t.TraitCode == traitCode select t).FirstOrDefault(); if (tInDB == null) { throw new Exception("No Trait with TraitCode " + tBDO.TraitCode); } DCEnt.Traits.Remove(tInDB); tInDB.Description = tBDO.Description; tInDB.GradeLevel = tBDO.GradeLevel; tInDB.TraitCode = tBDO.TraitCode; DCEnt.Traits.Attach(tInDB); DCEnt.Entry(tInDB).State = System.Data.Entity.EntityState.Modified; int num = DCEnt.SaveChanges(); if (num != 1) { ret = false; message = "No trait is updated."; } } return ret; }
public GradeSectionBDO GetGradeSectionBDO(int gradesectioncode) { GradeSection gsec = new GradeSection(); GradeSectionBDO gsBDO = new GradeSectionBDO(); try { using (var DCEnt = new DCFIEntities()) { gsec = (from gs in DCEnt.GradeSections where gs.GradeSectionCode == gradesectioncode select gs).FirstOrDefault<GradeSection>(); ConvertGradeSectionToGradeSectionBDO(gsec, gsBDO); } } 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 gsBDO; }
public List<BuildingBDO> GetAllBuildings() { List<BuildingBDO> bBDOList = new List<BuildingBDO>(); List<Building> bList = new List<Building>(); try { using (var DCEnt = new DCFIEntities()) { var allBuildings = (DCEnt.Buildings); bList = allBuildings.ToList<Building>(); foreach (Building b in bList) { BuildingBDO bBDO = new BuildingBDO(); ConvertBuildingToBuildingBDO(b, bBDO); bBDOList.Add(bBDO); } } } 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 bBDOList; }
public List <CurriculumBDO> GetAllCurriculums() { List <Curriculum> currList = new List <Curriculum>(); List <CurriculumBDO> currBDOList = new List <CurriculumBDO>(); try { using (var DCEnt = new DCFIEntities()) { var allCurr = (DCEnt.Curriculums); currList = allCurr.ToList <Curriculum>(); foreach (Curriculum c in currList) { CurriculumBDO currBDO = new CurriculumBDO(); ConvertCurriculumToCurriculumBDO(c, currBDO); currBDOList.Add(currBDO); } } } 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(currBDOList); }
public TimeslotBDO GetTimeslotBDO(string timeslotCode) { TimeslotBDO timeslotBDO = null; using (var DCEnt = new DCFIEntities()) { Timeslot timeslot = new Timeslot(); timeslot = (from t in DCEnt.Timeslots where t.TimeSlotCode == timeslotCode select t).FirstOrDefault(); if (timeslot != null) { timeslotBDO = new TimeslotBDO() { TimeSlotCode = timeslot.TimeSlotCode, TimeStart = timeslot.TimeStart, TimeEnd = timeslot.TimeEnd, Days = timeslot.Days, Deactivated = timeslot.Deactivated }; } } return(timeslotBDO); }
public List <CurriculumSubjectBDO> GetCurriculumSubjects(string curriculumCode) { List <CurriculumSubject> csList = new List <CurriculumSubject>(); List <CurriculumSubjectBDO> csbList = new List <CurriculumSubjectBDO>(); try { using (var DCEnt = new DCFIEntities()) { var allCurrSub = (from cSub in DCEnt.CurriculumSubjects where cSub.CurriculumCode == curriculumCode select cSub).ToList <CurriculumSubject>(); csList = allCurrSub; csbList = ToCurriculumSubjectBDOList(csList); } } 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(csbList); }
public Boolean AddLog(LogBDO log) { //string message = "Log Added Successfully"; bool ret = true; try { Log l = new Log(); ConvertLogBDOToLog(log, l); using (var DCEnt = new DCFIEntities()) { DCEnt.Logs.Add(l); DCEnt.Entry(l).State = System.Data.Entity.EntityState.Added; int num = DCEnt.SaveChanges(); if (num < 1) { ret = false; } } } 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 <SubjectBDO> subjectlist = new List <SubjectBDO>(); ICollection <Subject> subject; try { using (var DCEnt = new DCFIEntities()) { subject = (from s in DCEnt.Subjects where s.LearningAreaCode.Equals(learningAreaCode) select s).ToList <Subject>(); } subjectlist = ToSubjectBDOList(subject); } 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(subjectlist); }