예제 #1
0
        public IHttpActionResult PostTMPROVEEDOR(TMPROVEEDOR tMPROVEEDOR)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.TMPROVEEDORs.Add(tMPROVEEDOR);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (TMPROVEEDORExists(tMPROVEEDOR.NIF))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = tMPROVEEDOR.NIF }, tMPROVEEDOR));
        }
예제 #2
0
        public IHttpActionResult PutTMPROVEEDOR(string id, TMPROVEEDOR tMPROVEEDOR)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tMPROVEEDOR.NIF)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #3
0
        public IHttpActionResult GetTMPROVEEDOR(string id)
        {
            TMPROVEEDOR tMPROVEEDOR = db.TMPROVEEDORs.Find(id);

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

            return(Ok(tMPROVEEDOR));
        }
예제 #4
0
        public IHttpActionResult DeleteTMPROVEEDOR(string id)
        {
            TMPROVEEDOR tMPROVEEDOR = db.TMPROVEEDORs.Find(id);

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

            db.TMPROVEEDORs.Remove(tMPROVEEDOR);
            db.SaveChanges();

            return(Ok(tMPROVEEDOR));
        }