示例#1
0
        public IHttpActionResult PutMaterialInStore(int id, MaterialInStore materialInStore)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != materialInStore.Id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
        public IHttpActionResult GetMaterialInStore(int id)
        {
            MaterialInStore materialInStore = db.MaterialInStores.Find(id);

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

            return(Ok(materialInStore));
        }
示例#3
0
        public IHttpActionResult PostMaterialInStore(MaterialInStore materialInStore)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.MaterialInStores.Add(materialInStore);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = materialInStore.Id }, materialInStore));
        }
示例#4
0
        public IHttpActionResult DeleteMaterialInStore(int id)
        {
            MaterialInStore materialInStore = db.MaterialInStores.Find(id);

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

            db.MaterialInStores.Remove(materialInStore);
            db.SaveChanges();

            return(Ok(materialInStore));
        }