Exemplo n.º 1
0
        public int InsertSlug(PostModel post, int categoryId, int argumentId)
        {
            int slugId = 0;

            if (argumentId == 0)
            {
                slugId = _categoryService.GetById(categoryId).slugId;
            }
            else
            {
                slugId = _argumentService.GetById(argumentId).slugId;
            }

            var categoryArgumentSlug = _slugService.GetById(slugId).name;
            var name = string.Concat(categoryArgumentSlug, _commonService.cleanStringPath(post.title), '/');

            var model = new SlugModel();

            model.name       = name;
            model.entityname = "Post";

            _slugService.Insert(model);

            return(_slugService.GetByName(name).id);
        }
Exemplo n.º 2
0
        public int InsertSlug(ArgumentModel argument, int categoryId)
        {
            var categorySlugId = _categoryService.GetById(categoryId).slugId;
            var categorySlug   = _slugService.GetById(categorySlugId).name;
            var name           = "";

            if (argument.idPadre > 0)
            {
                var idPadre   = _argumentService.GetById(argument.idPadre).id;
                var nomePadre = _argumentService.GetById(idPadre).name;
                name = string.Concat(categorySlug, nomePadre, '/', _commonService.cleanStringPath(argument.name), '/');
            }
            else
            {
                name = string.Concat(categorySlug, _commonService.cleanStringPath(argument.name), '/');
            }

            var model = new SlugModel();

            model.name       = name;
            model.entityname = "Argument";

            _slugService.Insert(model);

            return(_slugService.GetByName(name).id);
        }
Exemplo n.º 3
0
        public int InsertSlug(CategoryModel category)
        {
            var name = string.Concat("/Blog", '/', _commonService.cleanStringPath(category.name), '/');

            var model = new SlugModel();

            model.name       = name;
            model.entityname = "Category";

            _slugService.Insert(model);

            return(_slugService.GetByName(name).id);
        }
Exemplo n.º 4
0
        public IActionResult Index()
        {
            var request = HttpContext.Request;
            var host    = request.Host;
            var slug    = request.QueryString.Value.Replace("?param=", "/Blog/");

            var entity = _slugService.GetByName(slug).entityname;
            var id     = _slugService.GetByName(slug).id;

            if (entity == "Category")
            {
                var categoryId = _categoryService.GetBySlugId(id).id;
                var arguments  = _argumentService.GetByCategoryId(categoryId);

                var argumentModel = new ArgumentController(_argumentService, _categoryService, _postService, _slugService, _photoService).List(categoryId, 50, 1);

                //SEO
                ViewBag.description = _categoryService.GetById(categoryId).description;

                return(View("~/Views/Argument/List.cshtml", argumentModel));
            }
            else if (entity == "Argument")
            {
                var argumentId = _argumentService.GetBySlugId(id).id;
                var posts      = _postService.GetByArgumentId(argumentId);

                if (posts.Count == 0 || posts.Count > 1)
                {
                    var postListModel = new PostController(_categoryService, _argumentService, _postService, _albumService, _photoService, _videoService, _slugService, _reviewService).List(argumentId, 50, 1);

                    //SEO
                    ViewBag.description = _argumentService.GetById(argumentId).description;

                    return(View("~/Views/Post/List.cshtml", postListModel));
                }
                else
                {
                    var idPost    = posts[0].id;
                    var modelPost = new PostController(_categoryService, _argumentService, _postService, _albumService, _photoService, _videoService, _slugService, _reviewService).GetByPostId(idPost);

                    //SEO
                    ViewBag.description = Regex.Replace(modelPost.testo, "<.*?>", string.Empty).Substring(0, 255);

                    //POST TITLE
                    ViewBag.title    = modelPost.title;
                    ViewBag.subtitle = modelPost.subtitle;

                    return(View("~/Views/Post/GetById.cshtml", modelPost));
                }
            }

            var postId    = _postService.GetBySlugId(id).id;
            var postModel = new PostController(_categoryService, _argumentService, _postService, _albumService, _photoService, _videoService, _slugService, _reviewService).GetByPostId(postId);

            //SEO
            ViewBag.description = Regex.Replace(postModel.testo, "<.*?>", string.Empty).Substring(0, 255);

            //POST TITLE
            ViewBag.title    = postModel.title;
            ViewBag.subtitle = postModel.subtitle;

            return(View("~/Views/Post/GetById.cshtml", postModel));
        }