Esempio n. 1
0
        public IQueryable <Schedule> GetSchedules()
        {
            var dataContext = new ScheduleModelDataContext();
            var schedules   = (from m in dataContext.Schedules
                               select m);

            return(schedules);
        }
Esempio n. 2
0
        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");
            }
        }
Esempio n. 3
0
        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");
            }
        }
Esempio n. 4
0
        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);
            }
        }
Esempio n. 5
0
        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");
            }
        }