Esempio n. 1
0
        // POST: odata/Supplaiers
        public async Task <IHttpActionResult> Post(Supplaier supplaier)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Supplaiers.Add(supplaier);
            await db.SaveChangesAsync();

            return(Created(supplaier));
        }
Esempio n. 2
0
        // DELETE: odata/Supplaiers(5)
        public async Task <IHttpActionResult> Delete([FromODataUri] int key)
        {
            Supplaier supplaier = await db.Supplaiers.FindAsync(key);

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

            db.Supplaiers.Remove(supplaier);
            await db.SaveChangesAsync();

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 3
0
        // PUT: odata/Supplaiers(5)
        public async Task <IHttpActionResult> Put([FromODataUri] int key, Delta <Supplaier> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Supplaier supplaier = await db.Supplaiers.FindAsync(key);

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

            patch.Put(supplaier);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SupplaierExists(key))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(supplaier));
        }