public ActionResult Enroll(ClassViewModel classViewModel) { if (ModelState.IsValid) { string selectedClass = classViewModel.SelectedClass; var userId = ((Models.UserModel)Session["User"]).Id; int classId = int.Parse(selectedClass); classManager.AddClass(userId, classId); return(Redirect("~/Home/Student")); } var classes = classManager.GetAll() .Select(c => new MyWebApp.WebSite.Models.ClassModel { Id = c.Id, Name = c.Name, Description = c.Description, Price = c.Price }).ToArray(); var model = new ClassViewModel { Classes = classes }; model.ClassSelectList = new SelectList(classes, "Id", "Name"); return(View(model)); }
public ActionResult EnrollInClass(FinalProject.Models.EnrollClassModel enrollClassModel) { var user = Session["User"] as FinalProject.Models.UserModel; var userClass = classManager.AddClass(enrollClassModel.SelectedClassId, user.UserId); return(RedirectToAction("StudentClasses")); }
public ActionResult EnrollInClass(EnrollInClassModel enrollInClassModel) { ViewBag.Message = "Classes Available to Enroll In"; var user = (Models.UserModel)Session["User"]; classManager.AddClass(enrollInClassModel.ClassId, user.Id); return(Redirect("~/Home/StudentClasses")); }