// GET: Contact/Details/5 public async Task <IActionResult> Details(int?id) { try { if (id == null) { return(NotFound()); } var contact = await _contactModel.GetContact(id.Value); if (contact == null) { return(NotFound()); } return(View(contact)); } catch (Exception ex) { _logger.LogError($"{ ex.Message } {(ex.InnerException != null ? ex.InnerException.Message : string.Empty)} {ex.StackTrace}"); return(RedirectToAction(nameof(Error))); } }
public Contact GetContact(int id) { if (id > 0) { var product = contactModel.GetContact(id); if (product == null) { return(null); } return(product); } else { return(null); } }