public Boolean CreateTimeslot(ref TimeslotBDO tBDO, ref string message) { message = "Timeslot Added Successfully"; bool ret = true; Timeslot t = new Timeslot() { TimeSlotCode = tBDO.TimeSlotCode, TimeStart = tBDO.TimeStart, TimeEnd = tBDO.TimeEnd, Days = tBDO.Days }; using (var DCEnt = new DCFIEntities()) { DCEnt.Timeslots.Attach(t); DCEnt.Entry(t).State = System.Data.Entity.EntityState.Added; int num = DCEnt.SaveChanges(); tBDO.TimeSlotCode = t.TimeSlotCode; if (num != 1) { ret = false; message = "Adding of Timeslot failed"; } } return ret; }
public void TranslateTimeslotDTOToTimeslotBDo(Timeslot timeslot, TimeslotBDO tBDO) { tBDO.TimeSlotCode = timeslot.TimeSlotCode; tBDO.TimeStart = timeslot.TimeStart; tBDO.TimeEnd = timeslot.TimeEnd; tBDO.Days = timeslot.Days; }
public Boolean CreateTimeslot(ref Timeslot timeslot, ref string message) { message = String.Empty; TimeslotBDO tbdo = new TimeslotBDO(); TranslateTimeslotDTOToTimeslotBDo(timeslot, tbdo); return timeslotLogic.CreateTimeslot(ref tbdo, ref message); }
public Boolean UpdateTimeslot(ref Timeslot timeslot, ref string message) { message = String.Empty; TimeslotBDO tBDO = new TimeslotBDO(); TranslateTimeslotDTOToTimeslotBDo(timeslot, tBDO); return timeslotLogic.UpdateTimeslot(ref tBDO, ref message); }
public void TranslateTimeslotBDOToTimeslotDTo(TimeslotBDO tBDO, Timeslot timeslot) { timeslot.TimeSlotCode = tBDO.TimeSlotCode; timeslot.TimeStart = tBDO.TimeStart; timeslot.TimeEnd = tBDO.TimeEnd; timeslot.Days = tBDO.Days; }
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 TranslateTimeslotBDOToTimeslotDTo(TimeslotBDO tBDO, Timeslot timeslot) { timeslot.TimeSlotCode = tBDO.TimeSlotCode; timeslot.TimeStart = tBDO.TimeStart; timeslot.TimeEnd = tBDO.TimeEnd; timeslot.Days = tBDO.Days; timeslot.TotalMins = tBDO.TotalMins; timeslot.TimeSlotInfo = tBDO.Days + " " + tBDO.TimeStart + "-" + tBDO.TimeEnd; }
public Timeslot GetTimeslot(string timeslotCode) { TimeslotBDO tbdo = new TimeslotBDO(); tbdo = timeslotLogic.GetTimeslot(timeslotCode); Timeslot t = new Timeslot(); TranslateTimeslotBDOToTimeslotDTo(tbdo, t); return t; }
public void ConvertTimeslotToTimeslotBDO(Timeslot timeslot, TimeslotBDO tBDO) { tBDO.TimeSlotCode = timeslot.TimeSlotCode; tBDO.TimeStart = timeslot.TimeStart; tBDO.TimeEnd = timeslot.TimeEnd; tBDO.Days = timeslot.Days; tBDO.Deactivated = timeslot.Deactivated; tBDO.TotalMins = timeslot.TotalMins; }
public Boolean UpdateTimeslot(ref TimeslotBDO timeslotBDO, ref string message) { if (TimeslotExists(timeslotBDO.TimeSlotCode)) return tDAO.UpdateTimeslot(ref timeslotBDO, ref message); else { message = "Cannot get the Timeslot for this Code"; return false; } }
public Boolean CreateTimeslot(ref TimeslotBDO timeslotBDO, ref string message) { Boolean ret = false; TimeslotBDO tBDO = GetTimeslot(timeslotBDO.TimeSlotCode); if (tBDO == null) ret = tDAO.CreateTimeslot(ref timeslotBDO, ref message); else message = "Code already exists. Please select another Code"; return ret; }
public List<TimeslotBDO> GetAllTimeslot() { List<Timeslot> timeslotList = new List<Timeslot>(); using (var DCEnt = new DCFIEntities()) { var allTimeslot = (DCEnt.Timeslots); timeslotList = allTimeslot.ToList<Timeslot>(); } List<TimeslotBDO> timeslotBDOList = new List<TimeslotBDO>(); foreach (Timeslot t in timeslotList) { TimeslotBDO timeslotBDO = new TimeslotBDO(); ConvertTimeslotToTimeslotBDO(t, timeslotBDO); timeslotBDOList.Add(timeslotBDO); } return timeslotBDOList; }
public Boolean CreateTimeslot(ref TimeslotBDO tBDO, ref string message) { message = "Timeslot Added Successfully"; bool ret = true; Timeslot t = new Timeslot() { TimeSlotCode = tBDO.TimeSlotCode, TimeStart = tBDO.TimeStart, TimeEnd = tBDO.TimeEnd, Days = tBDO.Days, TotalMins=tBDO.TotalMins }; try { using (var DCEnt = new DCFIEntities()) { DCEnt.Timeslots.Attach(t); DCEnt.Entry(t).State = System.Data.Entity.EntityState.Added; int num = DCEnt.SaveChanges(); tBDO.TimeSlotCode = t.TimeSlotCode; if (num != 1) { ret = false; message = "Adding of Timeslot 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 TimeslotBDO GetTimeslotBDO(string timeslotCode) { TimeslotBDO timeslotBDO = null; try { 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, TotalMins = timeslot.TotalMins }; } } } 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 timeslotBDO; }
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 Boolean UpdateTimeslot(ref TimeslotBDO tBDO, ref string message) { message = "Timeslot updated successfully."; Boolean ret = true; using (var DCEnt = new DCFIEntities()) { var timeslotCode = tBDO.TimeSlotCode; Timeslot timeslotInDB = (from t in DCEnt.Timeslots where t.TimeSlotCode == timeslotCode select t).FirstOrDefault(); if (timeslotInDB == null) { throw new Exception("No timeslot with code " + tBDO.TimeSlotCode); } DCEnt.Timeslots.Remove(timeslotInDB); timeslotInDB.TimeStart = tBDO.TimeStart; timeslotInDB.TimeEnd = tBDO.TimeEnd; timeslotInDB.Days = tBDO.Days; DCEnt.Timeslots.Attach(timeslotInDB); DCEnt.Entry(timeslotInDB).State = System.Data.Entity.EntityState.Modified; int num = DCEnt.SaveChanges(); if (num != 1) { ret = false; message = "No timeslot is updated."; } } return ret; }
public Boolean UpdateTimeslot(ref TimeslotBDO tBDO, ref string message) { message = "Timeslot updated successfully."; Boolean ret = true; try { using (var DCEnt = new DCFIEntities()) { var timeslotCode = tBDO.TimeSlotCode; Timeslot timeslotInDB = (from t in DCEnt.Timeslots where t.TimeSlotCode == timeslotCode select t).FirstOrDefault(); if (timeslotInDB == null) { throw new Exception("No timeslot with code " + tBDO.TimeSlotCode); } DCEnt.Timeslots.Remove(timeslotInDB); timeslotInDB.TimeStart = tBDO.TimeStart; timeslotInDB.TimeEnd = tBDO.TimeEnd; timeslotInDB.Days = tBDO.Days; timeslotInDB.TotalMins = tBDO.TotalMins; DCEnt.Timeslots.Attach(timeslotInDB); DCEnt.Entry(timeslotInDB).State = System.Data.Entity.EntityState.Modified; int num = DCEnt.SaveChanges(); if (num != 1) { ret = false; message = "No timeslot 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<TimeslotBDO> GetAllTimeslot() { List<Timeslot> timeslotList = new List<Timeslot>(); List<TimeslotBDO> timeslotBDOList = new List<TimeslotBDO>(); try { using (var DCEnt = new DCFIEntities()) { var allTimeslot = (from t in DCEnt.Timeslots orderby t.Days select t); timeslotList = allTimeslot.ToList<Timeslot>(); } foreach (Timeslot t in timeslotList) { TimeslotBDO timeslotBDO = new TimeslotBDO(); ConvertTimeslotToTimeslotBDO(t, timeslotBDO); timeslotBDOList.Add(timeslotBDO); } } 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 timeslotBDOList; }