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 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; }
private 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; }
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 Timeslot GetTimeSlot(string timeslotCode) { Timeslot timeslot = new Timeslot(); timeslot = null; using (var DCEnt = new DCFIEntities()) { timeslot = (from t in DCEnt.Timeslots where t.TimeSlotCode == timeslotCode select t).FirstOrDefault(); } return(timeslot); }
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 Timeslot GetTimeSlot(string timeslotCode) { Timeslot timeslot = new Timeslot(); timeslot = null; using (var DCEnt = new DCFIEntities()) { timeslot = (from t in DCEnt.Timeslots where t.TimeSlotCode == timeslotCode select t).FirstOrDefault(); } return timeslot; }
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 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 Boolean DeleteTimeslot(string timeslotCode, ref string message) { message = "Timeslot Deleted 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); DCEnt.Entry(tInDB).State = System.Data.Entity.EntityState.Deleted; int num = DCEnt.SaveChanges(); if (num != 1) { ret = false; message = "Deletion 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; 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 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; }