Beispiel #1
0
        public IHttpActionResult Postcntros(cntros cntros)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.cntros.Add(cntros);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (cntrosExists(cntros.cntros_cdgo))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = cntros.cntros_cdgo }, cntros));
        }
Beispiel #2
0
        public IHttpActionResult Putcntros(string id, cntros cntros)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != cntros.cntros_cdgo)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #3
0
        public IHttpActionResult Getcntros(string id)
        {
            cntros cntros = db.cntros.Find(id);

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

            return(Ok(cntros));
        }
Beispiel #4
0
        public IHttpActionResult Deletecntros(string id)
        {
            cntros cntros = db.cntros.Find(id);

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

            db.cntros.Remove(cntros);
            db.SaveChanges();

            return(Ok(cntros));
        }