public ActionResult EnrollInClass(EnrollInClassViewModel viewModel) { var user = (UserModel)Session["User"]; if (ModelState.IsValid) { var enrolledClass = userClassManager.Add(user.Id, viewModel.SelectedClassId); var classes = userClassManager.Classes(user.Id) .Select(t => new UserClassModel { ClassId = t.ClassId, ClassName = t.ClassName, ClassDescription = t.ClassDescription, ClassPrice = t.ClassPrice }) .ToArray(); return(View("StudentClasses", classes)); } else { var model = new EnrollInClassViewModel { AvailableClasses = GetAvailableClasses(user.Id) }; return(View(model)); } }
public ActionResult EnrollInClass() { var user = (UserModel)Session["User"]; var model = new EnrollInClassViewModel { AvailableClasses = GetAvailableClasses(user.Id) }; return(View(model)); }
public ActionResult EnrollInClass() { // get all the classes to populate the drop down in the form var classes = classMasterManager.ClassMasters .Select(t => new TheLearningCenter.Models.ClassMasterModel(t.Id, t.Name, t.Description, t.Price, t.Sessions)) .ToArray(); // get Session["User"] var user = (TheLearningCenter.Models.UserModel)Session["User"]; EnrollInClassViewModel enrollInClassModelData = new EnrollInClassViewModel { ClassMasters = classes, UserId = user.Id }; return(View(enrollInClassModelData)); }