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<TraitBDO> GetAllTraitsForCategory(int gradeLevel) { List<Trait> tList = new List<Trait>(); List<TraitBDO> tBDOList = new List<TraitBDO>(); try { using (var DCEnt = new DCFIEntities()) { tList = (from t in DCEnt.Traits where t.Category ==gradeLevel select t).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<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 void TranslateTraitToTraitBDO(Trait trait, TraitBDO tbdo) { tbdo.Description = trait.Description; tbdo.CurrTrait = trait.CurrTrait; tbdo.TraitsID = trait.TraitsID; tbdo.Category = trait.Category; }
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 void ConvertTraitToTraitBDO(Trait t, TraitBDO tBDO) { tBDO.CurrTrait = t.CurrTrait; tBDO.Description = t.Description; tBDO.TraitsID = t.TraitsID; tBDO.Category =(int) t.Category; }
public List<TraitBDO> ToTraitBDOList(List<Trait> tbList) { List<TraitBDO> tList = new List<TraitBDO>(); foreach (Trait t in tbList) { TraitBDO tb = new TraitBDO(); TranslateTraitToTraitBDO(t, tb); tList.Add(tb); } return tList; }
public void TranslateTraitBDOToTrait(TraitBDO tbdo, Trait t) { t.Description = tbdo.Description; t.CurrTrait = tbdo.CurrTrait; t.TraitsID = tbdo.TraitsID; t.Category = tbdo.Category; switch (tbdo.Category) { case 1: t.Cat = "Pre-School"; break; case 2: t.Cat = "Elementary"; break; case 3: t.Cat = "Secondary"; break; } }
public List<TraitBDO> GetAllTraits() { List<Trait> tList = new List<Trait>(); using (var DCEnt = new DCFIEntities()) { var allTraits = (DCEnt.Traits); tList = allTraits.ToList<Trait>(); } List<TraitBDO> tBDOList = new List<TraitBDO>(); foreach (Trait t in tList) { TraitBDO tBDO = new TraitBDO(); ConvertTraitToTraitBDO(t, tBDO); tBDOList.Add(tBDO); } return tBDOList; }
public List<TraitBDO> GetAllTraits(string gradeLevel) { List<Trait> tList = new List<Trait>(); using (var DCEnt = new DCFIEntities()) { tList = (from t in DCEnt.Traits where t.GradeLevel ==gradeLevel select t).ToList<Trait>(); } List<TraitBDO> tBDOList = new List<TraitBDO>(); foreach (Trait t in tList) { TraitBDO tBDO = new TraitBDO(); ConvertTraitToTraitBDO(t, tBDO); tBDOList.Add(tBDO); } return tBDOList; }
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 void ConvertStuTraitsToStuTraitsBDO(StudentTrait st, StudentTraitBDO stbdo) { stbdo.StudentSY = st.StudentSY; stbdo.TraitsID = st.TraitsID; stbdo.GradeSectionCode = st.GradeSectionCode; stbdo.FirstPeriodicRating = st.FirstPeriodicRating; stbdo.SecondPeriodicRating = st.SecondPeriodicRating; stbdo.ThirdPeriodicRating = st.ThirdPeriodicRating; stbdo.FourthPeriodicRating = st.FourthPeriodicRating; stbdo.StudentEnrTraitCode = st.StudentEnrTraitCode; stbdo.FirstEntered = st.FirstEntered; stbdo.FirstLocked = st.FirstLocked; stbdo.FourthEntered = st.FourthEntered; stbdo.FourthLocked = st.FourthLocked; stbdo.LockCFourth = st.LockCFourth; stbdo.LockFirst = st.LockFirst; stbdo.LockSecond = st.LockSecond; stbdo.LockThird = st.LockThird; stbdo.SecondEntered = st.SecondEntered; stbdo.SecondLocked = st.SecondLocked; stbdo.ThirdEntered = st.ThirdEntered; stbdo.ThirdLocked = st.ThirdLocked; TraitDAO td = new TraitDAO(); TraitBDO tb = new TraitBDO(); td.ConvertTraitToTraitBDO(st.Trait, tb); stbdo.Trait = tb; StudentEnrolmentDAO sed = new StudentEnrolmentDAO(); StudentEnrollmentBDO seb = new StudentEnrollmentBDO(); sed.ConvertEnrolToEnrolBDO(st.StudentEnrollment, seb); stbdo.StudentEnrollment = seb; GradeSectionDAO gsd = new GradeSectionDAO(); GradeSectionBDO gs = new GradeSectionBDO(); gsd.ConvertGradeSectionToGradeSectionBDO(st.GradeSection, gs); stbdo.GradeSection = gs; }
public Boolean UpdateTrait(ref TraitBDO tbdo, ref string message) { return tdao.UpdateTrait(ref tbdo, ref message); }
private void ConvertTraitToTraitBDO(Trait t, TraitBDO tBDO) { tBDO.Description = t.Description; tBDO.GradeLevel = t.GradeLevel; tBDO.TraitCode = t.TraitCode; }
public void TranslateTraitBDOToTrait(TraitBDO tbdo, Trait t) { t.Description = tbdo.Description; t.GradeLevel = tbdo.GradeLevel; t.TraitCode = tbdo.TraitCode; }
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 Boolean UpdateTrait(ref TraitBDO tBDO, ref string message) { message = "Trait updated successfully."; Boolean ret = true; try { using (var DCEnt = new DCFIEntities()) { var traitCode = tBDO.TraitsID; Trait tInDB = (from t in DCEnt.Traits where t.TraitsID == traitCode select t).FirstOrDefault(); if (tInDB == null) { throw new Exception("No Trait with TraitsIS " + tBDO.TraitsID); } DCEnt.Traits.Remove(tInDB); ConvertTraitBDOToTrait(tBDO, tInDB); 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."; } } } 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 bool UpdateTrait(ref Trait trait, ref string message) { TraitBDO tbdo = new TraitBDO(); TranslateTraitToTraitBDO(trait, tbdo); return tlogic.UpdateTrait(ref tbdo, ref message); }
public void TranslateTraitToTraitBDO(Trait trait, TraitBDO tbdo) { tbdo.Description = trait.Description; tbdo.GradeLevel = trait.GradeLevel; tbdo.TraitCode = trait.TraitCode; }