示例#1
0
        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();
            }
        }
示例#2
0
        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));
            }
        }