public async Task <ActionResult <BanqFood> > PostBanqFood(BanqFood banqFood) { if (banqFood.Id != 0) { banqFood.FoodCategoryId = 1; _context.Entry(banqFood).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BanqFoodExists(banqFood.Id)) { return(NotFound()); } else { throw; } } return(NoContent()); } banqFood.FoodCategoryId = 1; _context.BanqFood.Add(banqFood); await _context.SaveChangesAsync(); return(CreatedAtAction("GetBanqFood", new { id = banqFood.Id }, banqFood)); }
public async Task <IActionResult> PutBanqFood(int id, BanqFood banqFood) { if (id != banqFood.Id) { return(BadRequest()); } _context.Entry(banqFood).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BanqFoodExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }