public IQueryable <Schedule> GetSchedules() { var dataContext = new ScheduleModelDataContext(); var schedules = (from m in dataContext.Schedules select m); return(schedules); }
public void addSchedule(Schedule schedule) { var dataContext = new ScheduleModelDataContext(); dataContext.Schedules.InsertOnSubmit(schedule); dataContext.SubmitChanges(); using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\Public\homecarelog.txt", true)) { file.WriteLine(DateTime.Now + " new schedule with id " + schedule.Id + " created"); } }
public void deleteScheduleById(int?id) { var dataContext = new ScheduleModelDataContext(); var query = (from m in dataContext.Schedules where m.Id == id select m); dataContext.Schedules.DeleteOnSubmit(query.First()); dataContext.SubmitChanges(); using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\Public\homecarelog.txt", true)) { file.WriteLine(DateTime.Now + " schedule with id " + id + " deleted"); } }
public Schedule getScheduleById(int?id) { var dataContext = new ScheduleModelDataContext(); var query = (from m in dataContext.Schedules where m.Id == id select m); var schedule = query.First(); if (schedule != null) { return(schedule); } else { return(null); } }
public void updateSchedule(Schedule schedule) { var dataContext = new ScheduleModelDataContext(); var query = (from m in dataContext.Schedules where m.Id == schedule.Id select m); var sched = query.First(); sched.customer_Id = schedule.customer_Id; sched.employee_Id = schedule.employee_Id; sched.date = schedule.date; sched.task_Id = schedule.task_Id; sched.time = schedule.time; dataContext.SubmitChanges(); using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\Public\homecarelog.txt", true)) { file.WriteLine(DateTime.Now + " schedule with id " + schedule.Id + " updated"); } }