Ejemplo n.º 1
0
        public ActionResult AddStudent(FormCollection form)                         // thêm học sinh
        {
            if (!user.IsAdmin())
            {
                return(View("Error"));
            }
            Model.UpdateLastSeen("Thêm Sinh Viên", Url.Action("AddStudent"));
            string name          = form["name"];
            string username      = form["username"];
            string password      = form["password"];
            string email         = form["email"];
            string gender        = form["gender"];
            string birthday      = form["birthday"];
            int    id_speciality = Convert.ToInt32(form["id_speciality"]);
            int    id_class      = Convert.ToInt32(form["id_class"]);
            bool   add           = Model.AddStudent(name, username, password, gender, email, birthday, id_speciality, id_class);

            if (add)
            {
                TempData["status_id"] = true;
                TempData["status"]    = "Thêm Thành Công";
            }
            else
            {
                TempData["status_id"] = false;
                TempData["status"]    = "Thêm Thất Bại";
            }
            return(RedirectToAction("StudentManager"));
        }
Ejemplo n.º 2
0
 public IActionResult AddStudent(UserInfo student)
 {
     try
     {
         int Logged = Convert.ToInt32(HttpContext.Session.GetInt32("Logged"));
         int User   = Convert.ToInt32(HttpContext.Session.GetInt32("User"));
         if (Logged == 1 && User == 1)
         {
             adminDAObj.AddStudent(student);
             string success = "Student added successfully";
             return(RedirectToAction("StudentList", new { message = success }));
         }
         else
         {
             return(RedirectToAction("Login", "Home"));
         }
     }
     catch (Exception ex)
     {
         string exMessage = "oops! There is a problem in adding student.";
         return(RedirectToAction("Index", "ExeptionHandler", new { Exeption = exMessage }));
     }
 }