Esempio n. 1
0
        public JsonResult Create(CarePlanViewModel model)
        {
            if (model.Completed == true)
            {
                Validate(model);
            }
            var carePlan = new API.Models.CarePlan
            {
                CarePlanId      = model.CarePlanId,
                Title           = model.Title,
                PatientName     = model.PatientName,
                UserName        = model.UserName,
                ActualStartDate = model.ActualStartDate,
                TargetDate      = model.TargetDate,
                Reason          = model.Reason,
                Action          = model.Action,
                Completed       = model.Completed,
                EndDate         = model.EndDate,
                OutCome         = model.OutCome
            };

            if (ModelState.IsValid)
            {
                Db.CarePlan.Add(carePlan);
                Db.SaveChanges();
            }
            return(Json(new { Success = true }));
        }
Esempio n. 2
0
 private void Validate(CarePlanViewModel model)
 {
     if (model.EndDate <= model.ActualStartDate)
     {
         ModelState.AddModelError("EndDate", $@"End Date error: Cannot before start date");
     }
 }
Esempio n. 3
0
        public ActionResult GetCarePlan(int id)
        {
            CarePlanViewModel model;
            var carePlan = Db.CarePlan.FirstOrDefault(x => x.CarePlanId == id);

            model = new CarePlanViewModel(carePlan);

            return(View("CreateCarePlan", model));
        }