public async Task <IActionResult> PutProduct([FromRoute] int id, [FromBody] Product product) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != product.Id) { return(BadRequest()); } _context.Entry(product).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public Task CreateAsync(IEnumerable <Shipping> entities) { if (entities == null || entities.Count() == 0) { return(null); } _context.Shipping.AddRange(entities); return(_context.SaveChangesAsync()); }
public async Task CreateAsync(IEnumerable <Product> entities) { if (entities == null || entities.Count() == 0) { return; } _context.Product.AddRange(entities); await _context.SaveChangesAsync(); }
public async Task <IActionResult> PostBill([FromBody] Bill Bill) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Bills.Add(Bill); await _context.SaveChangesAsync(); return(CreatedAtAction("GetBill", new { id = Bill.Id }, Bill)); }