public async Task <IActionResult> Details(string id) { if (string.IsNullOrWhiteSpace(id)) { return(RedirectToAction("index", "home")); } var selectedCfp = _cfpService.GetCfpBySlug(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 = _cfpService.GetCfpById(guidId); } } if (selectedCfp == null) { // TODO to error page? return(RedirectToAction("index", "home")); } } if (selectedCfp.DuplicateOfId != null && selectedCfp.DuplicateOfId != Guid.Empty) { var originalCfp = _cfpService.GetCfpById((Guid)selectedCfp.DuplicateOfId); return(RedirectToAction("details", "cfp", new { id = originalCfp.Slug })); } selectedCfp.Views++; await _cfpService.SaveChangesAsync(); return(View(selectedCfp)); }
public IActionResult Get(Guid id) { var cfp = _cfpService.GetCfpById(id); return(new OkObjectResult(TinyMapper.Map <CfpData>(cfp))); }