public async Task <IActionResult> GetVisitsTicketTariffsAsync(string visitTariffId) { if (string.IsNullOrEmpty(visitTariffId)) { return(OnInvalidParameterError($"Parameter '{nameof(visitTariffId)}' cannot be null or empty.")); } try { var visitTariff = await _visitTariffDbService.GetAsync(visitTariffId); var visitsTicketTariffDto = MapToDtoEnumerable(visitTariff.TicketTariffs.AsEnumerable()); var response = new ResponseWrapper(visitsTicketTariffDto); return(Ok(response)); } catch (InvalidOperationException ex) { return(OnNotFoundError($"Cannot found element '{typeof(VisitTariff).Name}' with specified id: '{visitTariffId}'.", ex)); } catch (InternalDbServiceException ex) { LogInternalDbServiceException(ex); throw; } catch (Exception ex) { LogUnexpectedException(ex); throw; } }
public async Task <IActionResult> GetTariffAsync(string id) { _logger.LogInformation($"Starting method '{nameof(GetTariffAsync)}'."); if (string.IsNullOrEmpty(id)) { return(OnInvalidParameterError($"Parameter '{nameof(id)}' cannot be null or empty.")); } try { var tariff = await _tariffDbService.GetAsync(id); var tariffDto = MapToDto(tariff); var response = new ResponseWrapper(tariffDto); _logger.LogInformation($"Finished method '{nameof(GetTariffAsync)}'."); return(Ok(response)); } catch (InvalidOperationException ex) { return(OnNotFoundError($"Cannot found element '{typeof(VisitTariff).Name}' with specified id: '{id}'.", ex)); } catch (InternalDbServiceException ex) { LogInternalDbServiceException(ex, _tariffDbService.GetType()); throw; } catch (Exception ex) { LogUnexpectedException(ex); throw; } }