Exemplo n.º 1
0
 public ActionResult Create(StudentModel smodel)
 {
     try
     {
         //if (ModelState.IsValid)
         //{
         StudentDBHandle sdb = new StudentDBHandle();
         if (smodel.Id > 0)
         {
             sdb.UpdateDetails(smodel);
             return(RedirectToAction("Index"));
             //if (sdb.UpdateDetails(smodel))
             //{
             //    ViewBag.Message = "Student Details Updated Successfully";
             //    ModelState.Clear();
             //}
         }
         else
         {
             if (sdb.AddStudent(smodel))
             {
                 // ViewBag.Message = "Student Details Added Successfully";
                 return(RedirectToAction("Index"));
                 //  ModelState.Clear();
             }
         }
         //}
         return(View());
     }
     catch
     {
         return(View());
     }
 }
 public IHttpActionResult Create(StudentModel smodel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             StudentDBHandle sdb = new StudentDBHandle();
             if (sdb.AddStudent(smodel))
             {
                 return(Ok("Student Details Added Successfully"));
             }
         }
         return(BadRequest(ModelState));
     }
     catch
     {
         return(InternalServerError());
     }
 }
Exemplo n.º 3
0
 public ActionResult Create(StudentModel smodel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             StudentDBHandle sdb = new StudentDBHandle();
             if (sdb.AddStudent(smodel))
             {
                 ViewBag.Message = "Student Details Added Successfully";
                 ModelState.Clear();
             }
         }
         return(View());
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Create(Student student)
 {
     try
     {
         if (ModelState.IsValid)
         {
             StudentDBHandle dbhandle = new StudentDBHandle();
             if (dbhandle.AddStudent(student))
             {
                 ViewBag.Message = "Student Added Successfully";
                 ModelState.Clear();
             }
         }
         return(View());
     }
     catch (Exception e)
     {
         ViewBag.Message = e.ToString();
         return(View());
     }
 }
Exemplo n.º 5
0
 public ActionResult Create(StudentModel oStudentModel)
 {
     try
     {
         // TODO: Add insert logic here
         if (ModelState.IsValid)
         {
             StudentDBHandle oStudent = new StudentDBHandle();
             if (oStudent.AddStudent(oStudentModel))
             {
                 ViewBag.Message = "Estudiante agregado exitosamente";
                 ModelState.Clear();
             }
         }
         return(View());
     }
     catch
     {
         return(View());
     }
 }
Exemplo n.º 6
0
        public ActionResult Create(StudentModel student)
        {
            try
            {
                // TODO: Add insert logic here
                if (ModelState.IsValid)
                {
                    StudentDBHandle dBHandle = new StudentDBHandle();

                    if (dBHandle.AddStudent(student))
                    {
                        ViewBag.Message = "STUDENT DETAILS ADDED SUCCESSFULLY.";
                        ModelState.Clear();
                    }
                }
                return(View());
            }
            catch
            {
                return(View());
            }
        }