Ejemplo n.º 1
0
        public async Task <ActionResult> AddContactToCompanyAsync(int id, [FromBody] CompanyAddContact contactData)
        {
            var company = await _companyService.GetCompanyAsync(id);

            if (company is null)
            {
                return(NotFound($"No company with id '{id}' exists"));
            }

            var employeeContact = await _contactService.GetEmployeeAsync(contactData.ContactId);

            var freelancerContact = await _contactService.GetFreelancerAsync(contactData.ContactId);

            if ((employeeContact is null) == (freelancerContact is null))
            {
                return(BadRequest($"No employee or freelance contact with id '{contactData.ContactId}' exists"));
            }

            await _companyService.AddContactToCompanyAsync(id, contactData);

            return(Ok());
        }
Ejemplo n.º 2
0
 public Task AddContactToCompanyAsync(int id, CompanyAddContact contactData)
 {
     return(_companyCommand.AddContactToCompanyAsync(id, contactData.ContactId));
 }