Esempio n. 1
0
        public ActionResult Work(int id, string tag)
        {
            Activity model = new Activity();

            BDDAccess bddAccess = new BDDAccess();

            if (bddAccess.Connect(Path.Combine(Server.MapPath("~").ToString(), "bdd.bin")))
            {
                if (bddAccess.Information != null && bddAccess.Information != "")
                {
                    ViewBag.Erreur = bddAccess.Information;

                    return(View("Error"));
                }

                Student student = new Student()
                {
                    FirstName = (Session["User"] as User).FirstName, LastName = (Session["User"] as User).LastName, Class = new Class()
                    {
                        ClassName = Student.GetClass((Session["User"] as User).Groups[0])
                    }
                };

                if (tag == "saved")
                {
                    model = bddAccess.GetSavedActivity(id, student);
                }
                else
                {
                    model = bddAccess.GetActivity(id);
                }

                model.GetTextToDisplay("");

                model.CountWords();

                Session["Activity"] = model;
            }
            else
            {
                ViewBag.Error = bddAccess.Information;

                return(View("Error"));
            }

            return(View(model));
        }