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 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 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 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 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 Boolean DismissStudent(string studentID, ref string message) { message = "Student dismissed successfully."; Boolean ret = true; using (var DCEnt = new DCFIEntities()) { Student studentInDB = (from s in DCEnt.Students where s.StudentId == studentID select s).FirstOrDefault(); if (studentInDB == null) { throw new Exception("No student with ID " + studentID); } DCEnt.Students.Remove(studentInDB); studentInDB.Dismissed = true; DCEnt.Students.Attach(studentInDB); DCEnt.Entry(studentInDB).State = System.Data.Entity.EntityState.Modified; int num = DCEnt.SaveChanges(); if (num != 1) { ret = false; message = "Fail to Dismiss Student."; } } return ret; }
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 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 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 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 Boolean AddScholarshipDiscount(ScholarshipDiscountBDO discount,int scholarshipCode, ref string message) { message = "Scholarship Discount Added Successfully"; Boolean ret = true; ScholarshipDiscount sd = new ScholarshipDiscount(); try { ConvertScholarshipDiscountBDOToScholarshipDiscount(discount, sd); using (var DCEnt = new DCFIEntities()) { DCEnt.ScholarshipDiscounts.Add(sd); DCEnt.Entry(sd).State = System.Data.Entity.EntityState.Added; int num = DCEnt.SaveChanges(); if (num != 1) { ret = false; message = "Adding of Scholarship Discount 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 Boolean AddScholarshipDiscounts(List<ScholarshipDiscountBDO> discounts, int scholarshipCode, ref string message) { message = "Scholarship Discounts Added Successfully"; Boolean ret = true; try { foreach (ScholarshipDiscountBDO d in discounts) { ScholarshipDiscount sd = new ScholarshipDiscount(); ConvertScholarshipDiscountBDOToScholarshipDiscount(d, sd); using (var DCEnt = new DCFIEntities()) { DCEnt.ScholarshipDiscounts.Attach(sd); 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 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 Boolean CreateLearningArea(ref LearningAreaBDO laBDO, ref string message) { message = "Learning Area Added Successfully"; bool ret = true; LearningArea la = new LearningArea(); try { ConvertLearningAreaBDOToLearningArea(laBDO, la); using (var DCEnt = new DCFIEntities()) { DCEnt.LearningAreas.Add(la); DCEnt.Entry(la).State = System.Data.Entity.EntityState.Added; int num = DCEnt.SaveChanges(); if (num == 0) { ret = false; message = "Adding of Learning Area 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 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 Boolean CreateSibling(List<SiblingBDO> sbdo, string studentId) { Boolean ret = true; foreach (SiblingBDO s in sbdo) { Sibling sib = new Sibling(); ConvertSiblingBDOToSibling(s, sib, studentId); using (var DCEnt = new DCFIEntities()) { DCEnt.Siblings.Attach(sib); int num = DCEnt.SaveChanges(); if (num != 1) ret = false; } } return ret; }
public Boolean ActivateUser(int userId, ref string message) { message = "User Activated successfully."; Boolean ret = true; try { 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."; } } } 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 Boolean ActivateTimeslot(string timeslotCode, ref string message) { message = "Timeslot Activated successfully."; Boolean ret = true; try { using (var DCEnt = new DCFIEntities()) { Timeslot tInDB = (from t in DCEnt.Timeslots where t.TimeSlotCode == timeslotCode select t).FirstOrDefault(); if (tInDB == null) { throw new Exception("No timeslot with code " + tInDB); } DCEnt.Timeslots.Remove(tInDB); tInDB.Deactivated = false; DCEnt.Timeslots.Attach(tInDB); DCEnt.Entry(tInDB).State = System.Data.Entity.EntityState.Modified; int num = DCEnt.SaveChanges(); if (num != 1) { ret = false; message = "Activation 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 Boolean AddScholarshipDiscounts(List<ScholarshipDiscountBDO> discounts, string scholarshipCode, ref string message) { message = "Scholarship Discounts Added Successfully"; Boolean ret = true; foreach (ScholarshipDiscountBDO d in discounts) { ScholarshipDiscount sd = new ScholarshipDiscount(); ConvertScholarshipDiscountBDOToScholarshipDiscount(d, sd, scholarshipCode); using (var DCEnt = new DCFIEntities()) { DCEnt.ScholarshipDiscounts.Attach(sd); int num = DCEnt.SaveChanges(); if (num != 1) ret = false; } } return ret; }
public Boolean CreateCurriculum(ref CurriculumBDO cbdo, ref string message) { message = "Curriculum Added Successfully"; bool ret = true; Curriculum cur = new Curriculum(); 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"; } } return ret; }
public Boolean CreateFee(ref FeeBDO fBDO, ref string message) { message = "Fee Added Successfully"; bool ret = true; Fee f = new Fee(); 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"; } } return ret; }
public Boolean CreateTrait(ref TraitBDO tBDO, ref string message) { message = "Trait Added Successfully"; bool ret = true; Trait t = new Trait(); 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"; } } return ret; }
public Boolean CreateLearningArea(ref LearningAreaBDO laBDO, ref string message) { message = "Learning Area Added Successfully"; bool ret = true; LearningArea la = new LearningArea(); ConvertLearningAreaBDOToLearningArea(laBDO, la); using (var DCEnt = new DCFIEntities()) { DCEnt.LearningAreas.Add(la); DCEnt.Entry(la).State = System.Data.Entity.EntityState.Added; int num = DCEnt.SaveChanges(); if (num == 0) { ret = false; message = "Adding of Learning Area failed"; } } return ret; }
public Boolean CreateGradeLevel(ref GradeLevelBDO gBDO, ref string message) { message = "Grade Level Added Successfully"; bool ret = true; GradeLevel g = new GradeLevel(); ConvertGradeLevelBDOToGradeLevel(gBDO, g); using (var DCEnt = new DCFIEntities()) { DCEnt.GradeLevels.Attach(g); DCEnt.Entry(g).State = System.Data.Entity.EntityState.Added; int num = DCEnt.SaveChanges(); if (num != 1) { ret = false; message = "Adding of Grade Level failed"; } } return ret; }
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 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 }; try { 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"; } } } 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 Boolean CreateBuilding(ref BuildingBDO buildBDO, ref string message) { message = "Building Added Successfully"; bool ret = true; 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"; } } return ret; }
public Boolean CreateRoom(ref RoomBDO roomBDO, ref string message) { message = "Room Added Successfully"; bool ret = true; Room room = new Room(); ConvertRoomBDOToRoom(roomBDO, room); using (var DCEnt = new DCFIEntities()) { DCEnt.Rooms.Attach(room); DCEnt.Entry(room).State = System.Data.Entity.EntityState.Added; int num = DCEnt.SaveChanges(); if (num != 1) { ret = false; message = "Adding of Room failed"; } return ret; } }
public Boolean AddScholarshipDiscount(ScholarshipDiscountBDO discount, string scholarshipCode, ref string message) { message = "Scholarship Discount Added Successfully"; Boolean ret = true; ScholarshipDiscount sd = new ScholarshipDiscount(); ConvertScholarshipDiscountBDOToScholarshipDiscount(discount, sd, scholarshipCode); using (var DCEnt = new DCFIEntities()) { DCEnt.ScholarshipDiscounts.Attach(sd); DCEnt.Entry(sd).State = System.Data.Entity.EntityState.Added; int num = DCEnt.SaveChanges(); if (num != 1) { ret = false; message = "Adding of Scholarship Discount failed"; } return ret; } }
public Boolean CreateScholarship(ref ScholarshipBDO sBDO, ref string message) { message = "Scholarship Added Successfully"; bool ret = true; Scholarship s = new Scholarship(); ConvertScholarshipBDOToScholarship(sBDO, s); using (var DCEnt = new DCFIEntities()) { DCEnt.Scholarships.Add(s); DCEnt.Entry(s).State = System.Data.Entity.EntityState.Added; int num = DCEnt.SaveChanges(); sBDO.ScholarshipCode = s.ScholarshipCode; if (num != 1) { ret = false; message = "Adding of Scholarship failed"; } } return ret; }