Пример #1
0
        // GET: Articles/Details/5
        public IActionResult Details(string?id)
        {
            //is this a direct link to Details/int or from rewrite?
            var articleId = 0;

            int.TryParse(id, out articleId);

            Article article;

            if (articleId == 0)
            {
                //it was a rewrite
                if (id == null)
                {
                    return(NotFound());
                }
                else
                {
                    article = _repo.FindByUrl(id);
                }
            }
            else
            {
                article = _repo.FindById(int.Parse(id));
            }


            if (article == null)
            {
                return(NotFound());
            }

            return(View(article));
        }