Ejemplo 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());
     }
 }
Ejemplo n.º 2
0
 // POST: Student/Edit/5
 //  [HttpPost]
 public ActionResult Eite(StudentModel smodel)
 {
     try
     {
         StudentDBHandle sdb = new StudentDBHandle();
         sdb.UpdateDetails(smodel);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Edit(int id, Student student)
 {
     try
     {
         StudentDBHandle dbhandle = new StudentDBHandle();
         dbhandle.UpdateDetails(student);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 4
0
 public ActionResult Edit(int id, StudentModel student)
 {
     try
     {
         // TODO: Add update logic here
         StudentDBHandle dBHandle = new StudentDBHandle();
         dBHandle.UpdateDetails(student);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        public IHttpActionResult Edit([FromUri] int id, [FromBody] StudentModel smodel)
        {
            try
            {
                StudentDBHandle sdb = new StudentDBHandle();
                smodel.Id = id;
                if (sdb.UpdateDetails(smodel))
                {
                    return(Ok("Student Details Updated Successfully"));
                }

                return(NotFound());
            }
            catch
            {
                return(BadRequest());
            }
        }