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}'")); }
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}'")); }