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")); }
public ActionResult EnrollInClass() { ViewBag.Message = "Classes Available to Enroll In"; var user = (Models.UserModel)Session["User"]; var classes = classManager.Classes .Select(c => new Models.ClassModel(c.Id, c.Name, c.Description, c.Price)) .ToList(); var studentClasses = classManager.StudentClasses(user.Id) .Select(c => new Models.ClassModel(c.Id, c.Name, c.Description, c.Price)) .ToArray(); classes.RemoveAll(c => studentClasses.Any(s => s.Name == c.Name)); var openClasses = classes.ToArray(); var enrollInClassModel = new EnrollInClassModel { Classes = openClasses, ClassId = 0 }; return(View(enrollInClassModel)); }