public void SeedData(int nCusomers, int nOrders) { if (!_ctx.customers.Any()) { SeedCustomers(nCusomers); _ctx.SaveChanges(); } if (!_ctx.orders.Any()) { SeedOrders(nOrders); _ctx.SaveChanges(); } if (!_ctx.servers.Any()) { SeedServers(); _ctx.SaveChanges(); } }
public IActionResult Post([FromBody] Customer customer) { if (customer == null) { return(BadRequest()); } else { _ctx.customers.Add(customer); _ctx.SaveChanges(); return(CreatedAtRoute("GetCustomer", new { id = customer.Id }, customer)); } }