Beispiel #1
0
        public IHttpActionResult PutPERSONA(int id, PERSONA pERSONA)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != pERSONA.ID_PERSONAS)
            {
                return(BadRequest());
            }

            db.Entry(pERSONA).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PERSONAExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
 public void Eliminar(int id)
 {
     using (var contexto = new PersonasEntities())
     {
         var registro = (from y in contexto.Persona select y).
                        Where(z => z.Id.Equals(id)).FirstOrDefault();
         contexto.Persona.Remove(registro);
         contexto.SaveChanges();
     }
 }
Beispiel #3
0
        public void Crear(PersonaModel p)
        {
            using (var contexto = new PersonasEntities())
            {
                Persona per = new Persona();
                per.Nombre    = p.Nombre;
                per.Cedula    = p.Cedula;
                per.Telefono  = p.Telefono;
                per.Direccion = p.Direccion;

                contexto.Persona.Add(per);
                contexto.SaveChanges();
            }
        }
Beispiel #4
0
        public void ActualizarPersona(PersonaModel per)
        {
            using (var contexto = new PersonasEntities())
            {
                var registro = (from x in contexto.Persona select x).
                               Where(z => z.Id.Equals(per.Id)).FirstOrDefault();

                //3 cambiar
                registro.Nombre    = per.Nombre;
                registro.Cedula    = per.Cedula;
                registro.Telefono  = per.Telefono;
                registro.Direccion = per.Direccion;
                contexto.SaveChanges();
            }
        }