Пример #1
0
        public IHttpActionResult Postapp_articulo(app_articulo app_articulo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.app_articulo.Add(app_articulo);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (app_articuloExists(app_articulo.id_articulo))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = app_articulo.id_articulo }, app_articulo));
        }
Пример #2
0
        public IHttpActionResult Putapp_articulo(string id, app_articulo app_articulo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != app_articulo.id_articulo)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #3
0
        public IHttpActionResult Getapp_articulo(string id)
        {
            app_articulo app_articulo = db.app_articulo.Find(id);

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

            return(Ok(app_articulo));
        }
Пример #4
0
        public IHttpActionResult Deleteapp_articulo(string id)
        {
            app_articulo app_articulo = db.app_articulo.Find(id);

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

            db.app_articulo.Remove(app_articulo);
            db.SaveChanges();

            return(Ok(app_articulo));
        }