示例#1
0
        public ActionResult VisitInfo_When_SAC(VisitInfoViewModel vm)
        {
            var svvm = new ScheduleVisitTaskViewModel("VisitInfo");

            ViewBag.VisitInfoViewModel = vm.Fluff();
            ViewBag.TaskViewModel = svvm;

            return View(svvm.CurrStep.View, vm);
        }
示例#2
0
        public ActionResult VisitInfo_SAC(VisitInfoViewModel vm)
        {
            var svvm = new ScheduleVisitTaskViewModel("VisitInfo");

            //if (vm.VisitLength == null)
            //{
            //    ModelState.AddModelError("VisitLength", "Please specify a value");
            //}
            //if (vm.NumAttendees == null)
            //{
            //    ModelState.AddModelError("NumAttendees", "Please specify a value");
            //}
            if ( ModelState.IsValid )
            {
                if (vm.StartDate == null) // Need to get Time before proceeding
                {
                    var gotoView = "";

                    switch (vm.VisitLength)
                    {
                        case VisitInfoViewModel.VLength.Full: gotoView = "VisitInfoFullDay";
                            break;
                        case VisitInfoViewModel.VLength.Hourly: gotoView = "VisitInfoHourly";
                            break;
                        case VisitInfoViewModel.VLength.Multi: gotoView = "VisitInfoMultiDay";
                            break;
                    }

                    return View(gotoView, GetView(svvm));
                }
                // else user is back on main VisitInfo view and it's time to really Save

                if (Repository.VisitModel == null)
                {
                    Repository.VisitModel = new VisitModel
                    {
                        VisitID = 99,
                        VisitName = vm.VisitName,
                        VisitTypeID = vm.VisitTypeID,
                        SiteID = vm.SiteID,
                        IsOffSite = vm.IsOffSite,
                        StartDate = vm.StartDate.Value,
                        EndDate = vm.EndDate.Value
                    };
                    Repository.Dbs["VisitInfo"] = StepState.Complete;
                }
                else
                {
                    // store updated info?
                }

                TempData["VisitID"] = Repository.VisitModel.VisitID;

                return RedirectToAction("Navigate", new { view = svvm.GetNextView(svvm.CurrStep.View) });
            }
            else // VisitInfo view has errors that user must correct
            {
                return View("VisitInfo", vm.Fluff());
            }
        }