public virtual TViewModelEntity GetViewModel(Guid id) { try { var find = Get(id); var entity = _mapper.Map <TViewModelEntity>(find); _logger.LogInformation($"Get ID Success"); return(entity); } catch (Exception e) { _logger.LogError($"Get Id Fail"); throw; } }
public async Task <IEnumerable <OrderServiceResult> > GetOrdersAsync(int customerId) { var client = _httpClientFactory.CreateClient(nameof(OrdersExternalServiceProvider)); try { var response = await client.GetAsync($"api/v1/orders/customer/{customerId}"); if (response.IsSuccessStatusCode) { var content = await response.Content.ReadAsByteArrayAsync(); var options = new JsonSerializerOptions() { PropertyNameCaseInsensitive = true }; var result = JsonSerializer.Deserialize <IEnumerable <OrderServiceResult> >(content, options); return(result); } } catch (Exception e) { Console.WriteLine(e); _logger?.LogError(e.Message); } return(new List <OrderServiceResult>()); }
public IActionResult Microsoft() { _microsoftLogger.LogTrace("Microsoft Trace"); _microsoftLogger.LogDebug("Microsoft Debug"); _microsoftLogger.LogInformation("Microsoft Information"); _microsoftLogger.LogWarning("Microsoft Warning"); _microsoftLogger.LogError("Microsoft Error"); _microsoftLogger.LogCritical("Microsoft Critical"); return(Ok()); }
private bool TryRead(LogEventReader reader, out LogEvent?evt) { try { return(reader.TryRead(out evt)); } catch (JsonReaderException ex) { // As we are reading/streaming one line at a time in the JSON file // Thus we can not report the line number, as it will always be 1 _logger.LogError(ex, "Unable to parse a line in the JSON log file"); evt = null; return(true); } }