public FitnessViewModel LoadFitnessViewModel() { var model = new FitnessViewModel(); model.Classes = db.Classes.ToList(); model.Disciplines = db.Disciplines.ToList(); model.Instructors = db.Instructors.ToList(); model.SelectedDate = null; model.User = null; return(model); }
public ActionResult About() { FitnessViewModel VM = new FitnessViewModel(); VM.Students = db.Students.ToList(); List <RunData> temp = new List <RunData>(); FileStream fitFile = new FileStream(Server.MapPath("~/App_Data/7CMA3933.FIT"), FileMode.Open); temp.Add(ParseFastFit(fitFile)); fitFile.Close(); FileStream fitFile2 = new FileStream(Server.MapPath("~/App_Data/81PD5011.FIT"), FileMode.Open); temp.Add(ParseFastFit(fitFile2)); fitFile2.Close(); VM.RunInfo = temp; return(View(VM)); }
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)); } }