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 SchoolYearBDO GetSYBDO(string sy) { SchoolYearBDO SYbdo = null; try { using (var DCEnt = new DCFIEntities()) { SchoolYear SY = (from u in DCEnt.SchoolYears where u.SY == sy select u).FirstOrDefault(); if (SY != null) { SYbdo = new SchoolYearBDO() { SY = SY.SY, CurrentSY = SY.CurrentSY }; } } } 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 SYbdo; }
public void ConvertGradeSectionToGradeSectionBDO(GradeSection gs, GradeSectionBDO gsBDO) { RoomDAO r = new RoomDAO(); RoomBDO room = new RoomBDO(); TeacherDAO t = new TeacherDAO(); TeacherBDO teach = new TeacherBDO(); SchoolYearDAO s = new SchoolYearDAO(); SchoolYearBDO sy = new SchoolYearBDO(); s.ConvertSYToSYBDO(gs.SchoolYear, sy); t.ConvertTeacherToTeacherBDO(gs.Teacher, teach); r.ConvertRoomToRoomBDO(gs.Room, room); gsBDO.Deactivated = gs.Deactivated; gsBDO.GradeLevel = gs.GradeLevel; gsBDO.GradeSectionCode = gs.GradeSectionCode; gsBDO.HomeRoomNumber = (int)gs.HomeRoomNumber; gsBDO.HomeRoomTeacherId = gs.HomeRoomTeacherId; gsBDO.Section = gs.Section; gsBDO.SY = gs.SY; gsBDO.Class = gs.Class; gsBDO.HomeRoom = room; gsBDO.HomeRoomTeacher = teach; gsBDO.SchoolYear = sy; }
public Boolean UpdateSY(ref SchoolYear schoolyear, ref string message) { message = String.Empty; SchoolYearBDO syBDO = new SchoolYearBDO(); TranslateSYDTOToSYBDO(schoolyear, syBDO); return syLogic.UpdateSY(ref syBDO, ref message); }
public SchoolYear GetSY(string schoolyear) { SchoolYearBDO SYbdo = new SchoolYearBDO(); SYbdo = syLogic.GetSY(schoolyear); SchoolYear u = new SchoolYear(); TranslateSYBDOToSYDTO(SYbdo, u); return u; }
public Boolean UpdateSY(ref SchoolYearBDO syBDO, ref string message) { if (SYExists(syBDO.SY)) return syDAO.UpdateSY(ref syBDO, ref message); else { message = "Cannot get School Year"; return false; } }
public Boolean CreateSY(ref SchoolYearBDO schoolYearBDO, ref string message) { Boolean ret = false; SchoolYearBDO syBDO = GetSY(schoolYearBDO.SY); if (syBDO == null) ret = syDAO.CreateSY(ref schoolYearBDO, ref message); else message = "SchoolYear already exists. Please select another username"; return ret; }
public List<SchoolYearBDO> GetAllSY() { List<SchoolYear> syList = new List<SchoolYear>(); using (var DCEnt = new DCFIEntities()) { var allSY = (DCEnt.SchoolYears); syList = allSY.ToList<SchoolYear>(); } List<SchoolYearBDO> syBDOList = new List<SchoolYearBDO>(); foreach (SchoolYear u in syList) { SchoolYearBDO syBDO = new SchoolYearBDO(); ConvertSYToSYBDO(u, syBDO); syBDOList.Add(syBDO); } return syBDOList; }
public SchoolYearBDO GetSYBDO(string sy) { SchoolYearBDO SYbdo = null; using (var DCEnt = new DCFIEntities()) { SchoolYear SY = (from u in DCEnt.SchoolYears where u.SY == sy select u).FirstOrDefault(); if (SY != null) { SYbdo = new SchoolYearBDO() { SY = SY.SY, CurrentSY = SY.CurrentSY }; } } return SYbdo; }
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; }
private void ConvertSYToSYBDO(SchoolYear schoolyear, SchoolYearBDO syBDO) { syBDO.SY = schoolyear.SY; syBDO.CurrentSY = schoolyear.CurrentSY; }
public Boolean UpdateSY(ref SchoolYearBDO syBDO, ref string message) { message = "School Year updated successfully."; Boolean ret = true; using (var DCEnt = new DCFIEntities()) { var SY = syBDO.SY; SchoolYear syInDB = (from u in DCEnt.SchoolYears where u.SY == SY select u).FirstOrDefault(); if (syInDB == null) { throw new Exception(syBDO.SY + " doesn't exist"); } DCEnt.SchoolYears.Remove(syInDB); syInDB.SY = syBDO.SY; syInDB.CurrentSY = syBDO.CurrentSY; DCEnt.SchoolYears.Attach(syInDB); DCEnt.Entry(syInDB).State = System.Data.Entity.EntityState.Modified; int num = DCEnt.SaveChanges(); if (num != 1) { ret = false; message = "No SY is updated."; } } return ret; }
private void TranslateSYBDOToSYDTO(SchoolYearBDO syBDO, SchoolYear schoolyear) { schoolyear.SY = syBDO.SY; schoolyear.CurrentSY = syBDO.CurrentSY; }
public Boolean UpdateSY(ref SchoolYearBDO syBDO, ref string message) { message = "School Year updated successfully."; Boolean ret = true; try { using (var DCEnt = new DCFIEntities()) { var SY = syBDO.SY; SchoolYear syInDB = (from u in DCEnt.SchoolYears where u.SY == SY select u).FirstOrDefault(); if (syInDB == null) { throw new Exception(syBDO.SY + " doesn't exist"); } DCEnt.SchoolYears.Remove(syInDB); syInDB.SY = syBDO.SY; syInDB.CurrentSY = syBDO.CurrentSY; DCEnt.SchoolYears.Attach(syInDB); DCEnt.Entry(syInDB).State = System.Data.Entity.EntityState.Modified; int num = DCEnt.SaveChanges(); if (num != 1) { ret = false; message = "No SY 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 void ConvertSYBDOToSY(SchoolYearBDO syBDO, SchoolYear sy) { sy.SY = syBDO.SY; sy.CurrentSY = syBDO.CurrentSY; }
public List<SchoolYearBDO> GetAllSY() { List<SchoolYear> syList = new List<SchoolYear>(); List<SchoolYearBDO> syBDOList = new List<SchoolYearBDO>(); try { using (var DCEnt = new DCFIEntities()) { var allSY = (DCEnt.SchoolYears); syList = allSY.ToList<SchoolYear>(); foreach (SchoolYear u in syList) { SchoolYearBDO syBDO = new SchoolYearBDO(); ConvertSYToSYBDO(u, syBDO); syBDOList.Add(syBDO); } } } 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 syBDOList; }