示例#1
0
        public async Task <ActionResult <Customers> > PostCustomers(Customers customers)
        {
            // check for duplicate Email
            if (_repo.Exists(customers.Email))
            {
                return(Conflict());
            }

            try
            {
                await _repo.Add(customers);

                return(CreatedAtAction("GetCustomers", new { id = customers.Id }, customers.Id));
            }
            catch (DbUpdateException)
            {
                return(new StatusCodeResult(422));
            }
        }
示例#2
0
 private bool CustomerExists(Guid id)
 {
     return(_customersRepo.Exists(id));
 }