public ActionResult EnrollToAClass(FormCollection model)
        {
            if (ModelState.IsValid)

            {
                string returnUrl = "Enroll";

                if (Session["User"] == null)

                {
                    return(RedirectToAction("login", "Home", new { id = returnUrl }));
                }


                Models.UserModel user = (Ziglearning.Website.Models.UserModel)Session["User"];


                //*************************Selected Class Object Retrieved from Drop-Down List***********************

                string classId = model.GetValue("classes").AttemptedValue;                //get Id string

                int classIdInt = !string.IsNullOrEmpty(classId) ? int.Parse(classId) : 0; //get id int

                Business.ClassModel chosenclas = classManager.Clas(classIdInt);           //return classModel based on class id int



                //*************************Array of Classes Already Taken by that User*********************************

                var takenclasses = classManager.ForUser(user.Id);


                //**********************Loop Through Taken Classes Array and compare  with selected class Object

                int i;

                if (takenclasses.Length > 0)
                {
                    for (i = 0; i < takenclasses.Length; i++)

                    {
                        var x = takenclasses[i];
                        var y = chosenclas;

                        if (takenclasses[i].Id == chosenclas.Id)
                        {
                            return(View("AlreadyTaken"));
                        }
                    }

                    if (classIdInt > 0)
                    {
                        var enrolled = classManager.AddUserToClass(user.Id, classIdInt);
                        //return View("Thanks");
                        return(RedirectToAction("StudentClasses", new { id = user.Id }));
                    }
                }

                //********************* No Classes were already taken, so we enroll directly

                else if (takenclasses.Length == 0)
                {
                    if (classIdInt > 0)

                    {
                        var enrolled = classManager.AddUserToClass(user.Id, classIdInt);
                        //return View("Thanks");
                        var userfin = (Ziglearning.Website.Models.UserModel)Session["User"];
                        return(RedirectToAction("StudentClasses", new { id = userfin.Id }));
                    }
                }

                var userend = (Ziglearning.Website.Models.UserModel)Session["User"];

                return(RedirectToAction("StudentClasses", new { id = userend.Id }));
            }

            else
            {
                return(View());
            }
        }