public PostModel GetById(int id) { var model = new PostModel(); var post = _postService.GetById(id); if (post.albumId > 0) { model.album = _albumService.GetById(post.albumId); } model.id = post.id; model.albumId = post.albumId; model.PhotoId = post.PhotoId; model.title = post.title; model.subtitle = post.subtitle; model.testo = post.testo; model.PostsPath = GetAllPath(); model.categoryId = post.categoryId; model.argumentId = post.argumentId; model.pubblico = post.pubblico; //Get category and argument name model.categoryName = _categoryService.GetById(post.categoryId).name; if (post.argumentId > 0) { model.argumentName = _argumentService.GetById(post.argumentId).name; } else { model.argumentName = ""; } return(model); }
public IActionResult GetById(int id) { var argument = _argumentService.GetById(id); var argumentDto = _mapper.Map <ArgumentDto>(argument); return(Ok(argumentDto)); }
public PostModel List(int argumentId, int pageSize, int pageNumber) { var model = new PostModel(); //SEO ViewBag.description = _argumentService.GetById(argumentId).description; var excludeRecords = (pageSize * pageNumber) - pageSize; var total = _postService.GetByArgumentId(argumentId).Count; model.sectionName = _argumentService.GetById(argumentId).name; model.pageSize = pageSize; model.pageTotal = Math.Ceiling((double)total / pageSize); model.posts = _postService.GetByArgumentId(argumentId); //BreadCrumb model.categoryId = _argumentService.GetById(argumentId).categoryId; model.categoryName = _categoryService.GetById(_argumentService.GetById(argumentId).categoryId).name; model.argumentName = _argumentService.GetById(argumentId).name; model.breadcrumb.Add(new breadcrumbs() { name = model.categoryName, slug = _slugService.GetById(_categoryService.GetById(model.categoryId).slugId).name }); model.breadcrumb.Add(new breadcrumbs() { name = model.argumentName, slug = _slugService.GetById(_argumentService.GetById(argumentId).slugId).name }); foreach (var post in model.posts) { model.postsDisplay.Add(new PostDisplayModel() { id = post.id, slug = _slugService.GetById(post.slugId).name, coverImage = _photoService.GetById(post.PhotoId).path, title = post.title, testo = Regex.Replace(post.testo, "<.*?>", string.Empty).Substring(0, 200) }); } return(model); }
public ArgumentModel GetById(int id) { var model = new ArgumentModel(); var argument = _argumentService.GetById(id); model.id = argument.id; model.categoryId = argument.categoryId; model.livello = argument.livello; model.category = _categoryService.GetById(argument.categoryId); model.categories = _categoryService.GetAll(); model.name = argument.name; model.description = argument.description; model.coverImageId = argument.coverImageId; return(model); }
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)); }