Пример #1
0
        public async Task <IHttpActionResult> PutBrowarnia(int id, Browarnia browarnia)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #2
0
        public async Task <IHttpActionResult> PostBrowarnia(Browarnia browarnia)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Browarnias.Add(browarnia);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = browarnia.Id }, browarnia));
        }
Пример #3
0
        public async Task <IHttpActionResult> DeleteBrowarnia(int id)
        {
            Browarnia browarnia = await db.Browarnias.FindAsync(id);

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

            db.Browarnias.Remove(browarnia);
            await db.SaveChangesAsync();

            return(Ok(browarnia));
        }