public async Task <IActionResult> PutFoodWithOrder([FromRoute] long id, [FromForm] FoodWithOrder foodWithOrder)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            _context.Entry(foodWithOrder).State = EntityState.Modified;

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

            return(NoContent());
        }
Example #2
0
 public OrderWithFood(
     FoodWithOrder foodWithOrder,
     OrderInfo _orderInfo)
 {
     InitializeComponent();
     _foodWithOrder = foodWithOrder;
     orderInfo      = _orderInfo;
     setupOrderWithFoodUI();
 }
        public async Task <IActionResult> PostFoodWithOrder([FromForm] FoodWithOrder foodWithOrder)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.FoodWithOrders.Add(foodWithOrder);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetFoodWithOrder", new { id = foodWithOrder.Id }, foodWithOrder));
        }