예제 #1
0
        public async Task <ActionResult <Customer> > CreateNewCustomer([FromBody] Customer customer)
        {
            long id;

            try
            {
                id = await Task.Run(() => m_facade.AddNewCustomer(customer));
            }
            catch (DuplicateDetailsException ex)
            {
                return(StatusCode(400, $"{{ error: \"{ex.Message}\" }}"));
            }
            customer.Id = id;
            return(Created($"api/Anonymous/CreateNewCustomer/{id}", JsonConvert.SerializeObject(customer)));
        }