public void UpdateTimeslot(Timeslot timeslot) { //ToDo: Add error handling here. Brian Hall had an unhandled exception when he tried to submit a timeslot that was a past date-time. using (var db = new CC.Data.CCDB()) { var t = db.Timeslots.Find(timeslot.ID); t.Name = timeslot.Name; t.StartTime = timeslot.StartTime; t.EndTime = timeslot.EndTime; db.SaveChanges(); } }
public void CreateTimeslot(Timeslot timeslot) { using (var db = new CC.Data.CCDB()) { Data.Timeslot t = new Data.Timeslot() { Event_ID = timeslot.EventID, Name = timeslot.Name, StartTime = timeslot.StartTime, EndTime = timeslot.EndTime }; db.Timeslots.Add(t); db.SaveChanges(); } }
public static Timeslot Map(this Data.Timeslot t) { Timeslot timeslot = new Timeslot() { ID = t.ID, EventID = t.Event_ID, Name = t.Name, StartTime = t.StartTime ?? DateTime.MinValue, // why am I doing this? EndTime = t.EndTime ?? DateTime.MinValue }; return timeslot; }