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