Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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);
- }
Add Comment
Please, Sign In to add comment