Example #1
0
        public ActionResult FilterClasses([Bind(Include = "SelectedDiscipline, SelectedInstructor, SelectedDate")] FitnessViewModel oldModel)
        {
            if (oldModel == null)
            {
                return(Content("oldmodel er null"));
            }
            if (oldModel.SelectedDiscipline == null)
            {
                return(Content("SelectedDiscipline er null"));
            }

            int      disId        = oldModel.SelectedDiscipline.Id;
            int      insId        = 1; //oldModel.SelectedInstructor.InstructorId;
            DateTime?selectedDate = oldModel.SelectedDate;
            //Er property/binding validering fra brugers side gået godt:
            //if (!ModelState.IsValid)
            //{
            //Hvis input i formen ikke er valid. Giv mere sigende feedback i stedet...
            //ModelState.AddModelError("Error", "Det var ikke muligt at filtre i holdene. ModelState not valid.");
            //return Content("Modelstate not valid ");
            //return RedirectToAction("LogIn");
            //}
            var filtered = service.FilterFitnessClasses(disId, insId, selectedDate);
            var newModel = service.LoadFitnessViewModel();

            newModel.Classes = filtered;

            if (newModel == null)
            {
                return(Content("newModel is null"));
            }
            else
            {
                return(View("UserProfile", newModel));
            }
        }