public IHttpActionResult PutNumeroCasa(int id, NumeroCasa numeroCasa)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != numeroCasa.IDNumero)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PostNumeroCasa(NumeroCasa numeroCasa)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.NumeroCasa.Add(numeroCasa);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (NumeroCasaExists(numeroCasa.IDNumero))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = numeroCasa.IDNumero }, numeroCasa));
        }
        public IHttpActionResult GetNumeroCasa(int id)
        {
            NumeroCasa numeroCasa = db.NumeroCasa.Find(id);

            if (numeroCasa == null)
            {
                return(NotFound());
            }

            return(Ok(numeroCasa));
        }
        public bool Update(NumeroCasa entity)
        {
            try
            {
                context.Entry(entity).State = EntityState.Modified;
            }
            catch (System.Exception)
            {
                return(false);
            }

            return(true);
        }
        public IHttpActionResult DeleteNumeroCasa(int id)
        {
            NumeroCasa numeroCasa = db.NumeroCasa.Find(id);

            if (numeroCasa == null)
            {
                return(NotFound());
            }

            db.NumeroCasa.Remove(numeroCasa);
            db.SaveChanges();

            return(Ok(numeroCasa));
        }
        public bool save(NumeroCasa entity)
        {
            try
            {
                context.Set <NumeroCasa>().Add(entity);
                context.SaveChanges();
            }
            catch (System.Exception)
            {
                return(false);
            }

            return(true);
        }
        public bool Delete(int id)
        {
            var result = new NumeroCasa();

            try
            {
                result = context.NumeroCasa.Single(x => x.IDNumero == id);
                context.NumeroCasa.Remove(result);
            }
            catch (System.Exception)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 8
0
 public bool Update(NumeroCasa entity)
 {
     return(_casaRepository.Update(entity));
 }
Ejemplo n.º 9
0
 public bool save(NumeroCasa entity)
 {
     return(_casaRepository.save(entity));
 }