Example #1
0
        public VMPaciente(Paciente paciente)
        {
            this.pacienteID = paciente.pacienteID;
            this.nombre = paciente.nombre;
            this.apellidoP = paciente.apellidoP;
            this.apellidoM = paciente.apellidoM;
            this.telefono = paciente.telefono;
            this.direccion = paciente.direccion;



        }
        public JsonResult CreateAjax(Paciente paciente)
        {

            String mensaje = String.Empty;

            try
            {
                if (ModelState.IsValid)
                {
                    db.pacientes.Add(paciente);
                    db.SaveChanges();



                    mensaje = "Registro guardado";
                }
            }
            catch (Exception exc)
            {
                mensaje = "maldito servido F**K YOU!: " + exc.Message;
            }
            return Json(new { mensaje = mensaje }, JsonRequestBehavior.AllowGet);
        }
        public JsonResult AjaxEdit(Paciente paciente)
        {
            String mensaje = String.Empty;

            try
            {
                db.Entry(paciente).State = EntityState.Modified;
                int c = db.SaveChanges();
                mensaje = "Se ha editado los datos del alumno satisfactoriamente";
            }
            catch (Exception exc)
            {
                mensaje = "Hubo un error en el servidor: " + exc.Message;
            }


            return Json(new { mensaje = mensaje }, JsonRequestBehavior.AllowGet);
        }