예제 #1
0
        public ActionResult EditTest(FormCollection form)
        {
            if (!user.IsTeacher())
            {
                return(View("Error"));
            }
            int    test_code = Convert.ToInt32(form["test_code"]);
            string test_name = form["test_name"];
            string password  = "";

            if (form["password"] != "")
            {
                password = Common.Encryptor.MD5Hash(form["password"]);
            }
            int    id_subject = Convert.ToInt32(form["id_subject"]);
            int    time_to_do = Convert.ToInt32(form["time_to_do"]);
            string note       = "";

            if (form["note"] != "")
            {
                note = form["note"];
            }
            bool edit = Model.EditTest(test_code, test_name, password, time_to_do, note);

            if (edit)
            {
                TempData["status_id"] = true;
                TempData["status"]    = "Sửa Thành Công";
            }
            else
            {
                TempData["status_id"] = false;
                TempData["status"]    = "Sửa Thất Bại";
            }
            return(RedirectToAction("EditTest/" + test_code));
        }