Exemple #1
0
        public async Task <IActionResult> CreateCustomer(Customer customer)
        {
            foreach (ContactData contactData in customer.ContactData)
            {
                if (!contactDataValidator.Validate(contactData))
                {
                    return(new BadRequestObjectResult($"Contact data with type '{contactData.Type}' and value '{contactData.Value}' is invalid"));
                }
            }

            await _repository.CreateCustomer(customer);

            return(new ObjectResult($"Customer succesfully created with id '{customer.id}'"));
        }
Exemple #2
0
        public async Task <IActionResult> CreateInvoice(Invoice invoice)
        {
            foreach (ContactData contactData in invoice.Customer.ContactData)
            {
                if (!contactDataValidator.Validate(contactData))
                {
                    return(new BadRequestObjectResult($"Contact data with type '{contactData.Type}' and value '{contactData.Value}' is invalid"));
                }
            }

            await _invoiceRepository.CreateInvoice(invoice);

            return(new ObjectResult($"Invoice succesfully created with id '{invoice.id}'"));
        }