public ActionResult Crud(int?id, EstudianteModelo model)
        {
            bool   result = false;
            string msg    = string.Empty;

            try
            {
                if (ModelState.IsValid)
                {
                    if (id == 0)
                    {
                        id = null;
                    }
                    bool isNew = !id.HasValue;
                    _serviceEst.AddEdditEstudiante(isNew, model);
                    result = true;
                    msg    = "Dato guardado";
                }
                else
                {
                    result = false;
                    msg    = "Ha ocurrido un error";
                }
            } catch (Exception ex)
            {
                result = false;
                throw ex;
            }

            // return RedirectToAction("Index");
            return(Json(new { response = result, message = msg, href = "~/Estudiante" }, JsonRequestBehavior.AllowGet));
        }
 public ActionResult AddEditEstudiante(int?id, EstudianteModel model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             bool isNew = !id.HasValue;
             _ServiceEst.AddEdditEstudiante(isNew, model);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(RedirectToAction("Index"));
 }
Exemple #3
0
        public ActionResult Crud(int?id, EstudianteModelo estudiante)
        {
            bool   result = false;
            string msg    = string.Empty;

            if (ModelState.IsValid)
            {
                if (id == 0)
                {
                    id = null;
                }
                bool isNew = !id.HasValue;
                _serviceEst.AddEdditEstudiante(isNew, estudiante);
                result = true;
                msg    = "Ok";
            }
            else
            {
                result = false;
                msg    = "Error";
            }
            return(Json(new { Response = result, message = msg }, JsonRequestBehavior.AllowGet));
        }