Skip to content

Instantly share code, notes, and snippets.

@jfversluis
Created July 16, 2018 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfversluis/79cb3bed2977c64a47d786477f762c42 to your computer and use it in GitHub Desktop.
Save jfversluis/79cb3bed2977c64a47d786477f762c42 to your computer and use it in GitHub Desktop.
Method to get the details of the CFP entity
public IActionResult Details(string id)
{
if (string.IsNullOrWhiteSpace(id))
return RedirectToAction("index", "home");
var selectedCfp = _cfpContext.Cfps.SingleOrDefault(cfp => cfp.Slug == id);
if (selectedCfp == null)
{
// Check it the id happens to be a Guid
if (Guid.TryParse(id, out Guid guidId))
{
if (guidId != Guid.Empty)
selectedCfp = _cfpContext.Cfps.SingleOrDefault(cfp => cfp.Id == guidId);
}
if (selectedCfp == null)
// TODO to error page?
return RedirectToAction("index", "home");
}
// ... Non relevant code
return View(selectedCfp);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment