Method to get the details of the CFP entity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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