Exemplo n.º 1
0
        // PUT api/Food/5
        public async Task<IHttpActionResult> PutFood(int id, Food food)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

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

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }
Exemplo n.º 2
0
        public async Task<IHttpActionResult> PostFood(Food food)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Foods.Add(food);
            await db.SaveChangesAsync();

            return CreatedAtRoute("DefaultApi", new { id = food.Id }, food);
        }
Exemplo n.º 3
0
 public void SelectEditFood(Food food)
 {
 }
Exemplo n.º 4
-1
 public void DeleteFood(Food food)
 {
 }