コード例 #1
0
 public ActionResult TaskComplete(Tasks t)
 {
     if (ModelState.IsValid)
     {
         db.Entry(t).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(t);
 }
コード例 #2
0
        //populate today's Shedule based on Tasks
        public ActionResult GenerateSched()
        {
            if (hasAdminAccess())
            {
            DateTime date = DateTime.Today; //date will be set to today
            String[] days = { "Sun", "Mon", "Tue", "Wed", "Thr", "Fri", "Sat" };
            String dow = days[(int)date.DayOfWeek]; //day of week
            int dom = date.Day;
            //call static method from tasks model to get all the tasks needed to generate schedule.
            var tasks = Services.getTasks(db, date, dow, dom);

            Tasks sc = new Tasks();
            //populate schedule with new records
            foreach (var item in tasks.ToList())
            {
                sc.taskID = item.ID;
                sc.PatientID = item.PatientID;
                sc.Task = item.Task;
                sc.RoomNo = item.RoomNo;
                sc.duration = item.duration;
                sc.tDate = DateTime.Today + item.dtStart.TimeOfDay;
                db.Tasks.Add(sc);
                db.SaveChanges();
            }
            return View(db.Tasks.ToList());
            }
            else
            {
                return RedirectToAction("Index");
            }
        }
コード例 #3
0
        //populate today's Shedule based on Tasks
        public ActionResult GenerateSched()
        {
            if (hasAdminAccess())
            {
                DateTime date = DateTime.Today; //date will be set to today
                String[] days = { "Su", "M", "Tu", "W", "Th", "F", "Sa" };
                String dow = days[(int)date.DayOfWeek]; //day of week
                int dom = date.Day;

                 //delete previous entries to avoid duplicates

                 DateTime tomorrow = DateTime.Today.AddDays(1);
                 var todayt = from s in db.Tasks
                              where (s.tDate >= DateTime.Today && s.tDate <= tomorrow)
                              select s;
                 foreach (var tTask in todayt)
                 {
                     db.Tasks.Remove(tTask);
                 }
                 db.SaveChanges();

                //call static method from tasks model to get all the tasks needed to generate schedule.
                var tasks = Services.getTasks(db, date, dow, dom);

                Tasks sc = new Tasks();
                //populate schedule with new records
                foreach (var item in tasks.ToList())
                {
                    sc.taskID = item.ID;
                    sc.PatientID = item.PatientID;
                    sc.ClientFirstName = item.ClientFirstName;
                    sc.ClientLastName = item.ClientLastName;
                    sc.Task = item.Task;
                    sc.RoomNo = item.RoomNo;
                    sc.duration = item.duration;
                    sc.tDate = DateTime.Today + item.dtStart.TimeOfDay;
                    db.Tasks.Add(sc);
                    db.SaveChanges();
                }
                return View(db.Tasks.ToList());
            }
            else
            {
                return RedirectToAction("Index");
            }
        }