Esempio n. 1
0
        public async Task <IActionResult> AddContactData(AddContactDataDTO contactDataDTO)
        {
            if (!contactDataValidator.Validate((contactDataDTO.ContactData)))
            {
                return(new BadRequestObjectResult($"Contact data with type '{contactDataDTO.ContactData.Type}' and value '{contactDataDTO.ContactData.Value}' is invalid"));
            }
            try
            {
                await _repository.AddContactData(contactDataDTO);
            }
            catch (KeyNotFoundException)
            {
                return(new BadRequestObjectResult($"Customer with id '{contactDataDTO.CustomerId}' not found"));
            }


            return(new ObjectResult($"Contact data succesfully added to customer with id '{contactDataDTO.CustomerId}'"));
        }