public async Task <ViewResult> GetPerson(int id) { ViewData["Title"] = "Single Person"; ViewData["RequestStart"] = DateTime.Now; try { var person = await reader.GetPersonAsync(id); if (person == null || person?.Id == 0) { throw new KeyNotFoundException($"Person ID: {id} not found"); } var people = new List <Person>(); people.Add(person); return(View("Index", people)); } catch (Exception ex) { var errors = new List <Exception>() { ex }; return(View("Error", errors)); } finally { ViewData["RequestEnd"] = DateTime.Now; } }
public async Task <Person> GetPersonAsync(int id) { try { return(await _wrappedReader.GetPersonAsync(id)); } catch (Exception ex) { await _logger?.LogException(ex); throw; } }
public async Task <Person> GetPersonAsync(int id) { _retryCount++; try { var person = await _wrappedReader.GetPersonAsync(id); _retryCount = 0; return(person); } catch (Exception) { if (_retryCount >= 3) { throw; } await Task.Delay(_retryDelay); return(await this.GetPersonAsync(id)); } }