public async Task UpdateCompanyAsync(Employer entity, string companyName) { var company = await _companiesRepository.GetCompanyByNameAsync(companyName); if (company == null) { throw new EntityNotFoundException($"Company by name {companyName} not found"); } entity.CompanyId = company.Id; try { await Task.WhenAll(_advertisementsRepository.DeleteByEmployerAsync(entity.Id), UpdateAsync(entity)); } catch { throw new DatabaseException("Failed to update employer"); } }