예제 #1
0
        public IHttpActionResult PutDocumentoTDB(long id, DocumentoTDB documentoTDB)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != documentoTDB.idDocumento)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
        public IHttpActionResult GetDocumentoTDB(long id)
        {
            DocumentoTDB documentoTDB = db.DocumentoTDB.Find(id);

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

            return(Ok(documentoTDB));
        }
예제 #3
0
        public IHttpActionResult PostDocumentoTDB(DocumentoTDB documentoTDB)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.DocumentoTDB.Add(documentoTDB);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = documentoTDB.idDocumento }, documentoTDB));
        }
예제 #4
0
        public IHttpActionResult DeleteDocumentoTDB(long id)
        {
            DocumentoTDB documentoTDB = db.DocumentoTDB.Find(id);

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

            db.DocumentoTDB.Remove(documentoTDB);
            db.SaveChanges();

            return(Ok(documentoTDB));
        }