[HttpGet("posts/edit/{id}")] // displays page for editing an existing post public IActionResult EditPost(string id) { var postid = Guid.Parse(id); var request = new GetBlogPostRequest { PostId = postid }; var response = _getBlogPostInteractor.GetBlogPost(request); var dto = new BlogPostDTOModel(); if (response.RequestSuccessful) { dto = MapBlogPostToDTOModel(response.Post); } return(View(dto)); }
[HttpGet("posts/{id}")] // displays page for a specific post public IActionResult GetPost(string id) { var postid = Guid.Parse(id); var request = new GetBlogPostRequest { PostId = postid }; var response = _getBlogPostInteractor.GetBlogPost(request); var viewmodel = new BlogGetPostViewModel(); if (response.RequestSuccessful) { viewmodel.Post = MapBlogPostToDTOModel(response.Post); viewmodel.User = MapBlogUserToDTOModel(response.User); } return(View(viewmodel)); }
public GetBlogPostResponse Get(GetBlogPostRequest request) { var model = repository .AsQueryable<Module.Blog.Models.BlogPost>(blogPost => blogPost.Id == request.BlogPostId) .Select(blogPost => new BlogPostModel { Id = blogPost.Id, Version = blogPost.Version, CreatedBy = blogPost.CreatedByUser, CreatedOn = blogPost.CreatedOn, LastModifiedBy = blogPost.ModifiedByUser, LastModifiedOn = blogPost.ModifiedOn, BlogPostUrl = blogPost.PageUrl, Title = blogPost.Title, IntroText = blogPost.Description, IsPublished = blogPost.Status == PageStatus.Published, PublishedOn = blogPost.PublishedOn, LayoutId = blogPost.Layout != null && !blogPost.Layout.IsDeleted ? blogPost.Layout.Id : (Guid?)null, MasterPageId = blogPost.MasterPage != null && !blogPost.MasterPage.IsDeleted ? blogPost.MasterPage.Id : (Guid?)null, CategoryId = blogPost.Category != null && !blogPost.Category.IsDeleted ? blogPost.Category.Id : (Guid?)null, CategoryName = blogPost.Category != null && !blogPost.Category.IsDeleted ? blogPost.Category.Name : null, AuthorId = blogPost.Author != null && !blogPost.Author.IsDeleted ? blogPost.Author.Id : (Guid?)null, AuthorName = blogPost.Author != null && !blogPost.Author.IsDeleted ? blogPost.Author.Name : null, MainImageId = blogPost.Image != null && !blogPost.Image.IsDeleted ? blogPost.Image.Id : (Guid?)null, MainImageUrl = blogPost.Image != null && !blogPost.Image.IsDeleted ? blogPost.Image.PublicUrl : null, MainImageThumbnauilUrl = blogPost.Image != null && !blogPost.Image.IsDeleted ? blogPost.Image.PublicThumbnailUrl : null, MainImageCaption = blogPost.Image != null && !blogPost.Image.IsDeleted ? blogPost.Image.Caption : null, ActivationDate = blogPost.ActivationDate, ExpirationDate = blogPost.ExpirationDate, IsArchived = blogPost.IsArchived, UseCanonicalUrl = blogPost.UseCanonicalUrl, }) .FirstOne(); model.MainImageUrl = fileUrlResolver.EnsureFullPathUrl(model.MainImageUrl); model.MainImageThumbnauilUrl = fileUrlResolver.EnsureFullPathUrl(model.MainImageThumbnauilUrl); return new GetBlogPostResponse { Data = model }; }
public GetBlogPostResponse Get(GetBlogPostRequest request) { var model = repository .AsQueryable<Module.Blog.Models.BlogPost>(blogPost => blogPost.Id == request.BlogPostId) .Select(blogPost => new BlogPostModel { Id = blogPost.Id, Version = blogPost.Version, CreatedBy = blogPost.CreatedByUser, CreatedOn = blogPost.CreatedOn, LastModifiedBy = blogPost.ModifiedByUser, LastModifiedOn = blogPost.ModifiedOn, BlogPostUrl = blogPost.PageUrl, Title = blogPost.Title, IntroText = blogPost.Description, IsPublished = blogPost.Status == PageStatus.Published, PublishedOn = blogPost.PublishedOn, LayoutId = blogPost.Layout != null && !blogPost.Layout.IsDeleted ? blogPost.Layout.Id : (Guid?)null, MasterPageId = blogPost.MasterPage != null && !blogPost.MasterPage.IsDeleted ? blogPost.MasterPage.Id : (Guid?)null, AuthorId = blogPost.Author != null && !blogPost.Author.IsDeleted ? blogPost.Author.Id : (Guid?)null, AuthorName = blogPost.Author != null && !blogPost.Author.IsDeleted ? blogPost.Author.Name : null, MainImageId = blogPost.Image != null && !blogPost.Image.IsDeleted ? blogPost.Image.Id : (Guid?)null, MainImageUrl = blogPost.Image != null && !blogPost.Image.IsDeleted ? blogPost.Image.PublicUrl : null, MainImageThumbnauilUrl = blogPost.Image != null && !blogPost.Image.IsDeleted ? blogPost.Image.PublicThumbnailUrl : null, MainImageThumbnailUrl = blogPost.Image != null && !blogPost.Image.IsDeleted ? blogPost.Image.PublicThumbnailUrl : null, MainImageCaption = blogPost.Image != null && !blogPost.Image.IsDeleted ? blogPost.Image.Caption : null, SecondaryImageId = blogPost.SecondaryImage != null && !blogPost.SecondaryImage.IsDeleted ? blogPost.SecondaryImage.Id : (Guid?)null, SecondaryImageUrl = blogPost.SecondaryImage != null && !blogPost.SecondaryImage.IsDeleted ? blogPost.SecondaryImage.PublicUrl : null, SecondaryImageThumbnailUrl = blogPost.SecondaryImage != null && !blogPost.SecondaryImage.IsDeleted ? blogPost.SecondaryImage.PublicThumbnailUrl : null, SecondaryImageCaption = blogPost.SecondaryImage != null && !blogPost.SecondaryImage.IsDeleted ? blogPost.SecondaryImage.Caption : null, FeaturedImageId = blogPost.FeaturedImage != null && !blogPost.FeaturedImage.IsDeleted ? blogPost.FeaturedImage.Id : (Guid?)null, FeaturedImageUrl = blogPost.FeaturedImage != null && !blogPost.FeaturedImage.IsDeleted ? blogPost.FeaturedImage.PublicUrl : null, FeaturedImageThumbnailUrl = blogPost.FeaturedImage != null && !blogPost.FeaturedImage.IsDeleted ? blogPost.FeaturedImage.PublicThumbnailUrl : null, FeaturedImageCaption = blogPost.FeaturedImage != null && !blogPost.FeaturedImage.IsDeleted ? blogPost.FeaturedImage.Caption : null, ActivationDate = blogPost.ActivationDate, ExpirationDate = blogPost.ExpirationDate, IsArchived = blogPost.IsArchived, UseCanonicalUrl = blogPost.UseCanonicalUrl, LanguageId = blogPost.Language != null ? blogPost.Language.Id : (Guid?)null, LanguageCode = blogPost.Language != null ? blogPost.Language.Code : null, LanguageGroupIdentifier = blogPost.LanguageGroupIdentifier }) .FirstOne(); model.MainImageUrl = fileUrlResolver.EnsureFullPathUrl(model.MainImageUrl); model.MainImageThumbnauilUrl = fileUrlResolver.EnsureFullPathUrl(model.MainImageThumbnauilUrl); model.MainImageThumbnailUrl = fileUrlResolver.EnsureFullPathUrl(model.MainImageThumbnailUrl); model.SecondaryImageUrl = fileUrlResolver.EnsureFullPathUrl(model.SecondaryImageUrl); model.SecondaryImageThumbnailUrl = fileUrlResolver.EnsureFullPathUrl(model.SecondaryImageThumbnailUrl); model.FeaturedImageUrl = fileUrlResolver.EnsureFullPathUrl(model.FeaturedImageUrl); model.FeaturedImageThumbnailUrl = fileUrlResolver.EnsureFullPathUrl(model.FeaturedImageThumbnailUrl); LoadContentId(model); model.Categories = (from pagePr in repository.AsQueryable<Module.Blog.Models.BlogPost>() from category in pagePr.Categories where pagePr.Id == model.Id && !category.IsDeleted select new CategoryModel { Id = category.Category.Id, Version = category.Version, CreatedBy = category.CreatedByUser, CreatedOn = category.CreatedOn, LastModifiedBy = category.ModifiedByUser, LastModifiedOn = category.ModifiedOn, Name = category.Category.Name }).ToList(); return new GetBlogPostResponse { Data = model }; }
public async Task <BlogPost> GetBlogPost([FromBody] GetBlogPostRequest request) { return(await _cmsService.GetBlogPost(request.Id)); }