public async Task <ActionResult <Transfer_Specialty> > GetByIdAsync(int id) { _logger.LogInformation($"Retrieving specialties with id {id}."); if (await _specialtyRepository.GetSpecialtyByIdAsync(id) is Inner_Specialty specialty) { return(Ok(specialty)); } _logger.LogInformation($"No specialties found with id {id}."); return(NotFound()); }
public async Task <IActionResult> PostAsync(Transfer_Provider provider) { try { _logger.LogInformation($"Adding new provider."); var checkProvider = new CheckerClass(_facilityRepository, _specialtyRepository); checkProvider.CheckProvider(provider); Inner_Provider transformedProvider = new Inner_Provider { ProviderId = 0, ProviderFirstName = provider.ProviderFirstName, ProviderLastName = provider.ProviderLastName, ProviderPhoneNumber = provider.ProviderPhoneNumber, Facility = await _facilityRepository.GetFacilityByIdAsync(provider.FacilityId), Specialty = await _specialtyRepository.GetSpecialtyByIdAsync(provider.FacilityId) }; await _providerRepository.AddProviderAsync(transformedProvider); return(CreatedAtAction(nameof(GetByIdAsync), new { id = provider.ProviderId }, provider)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }