From 284d40f7ae3e551c5fce83e44ee20689714fa87b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Onur=20P=C4=B1=C3=A7akc=C4=B1?= Date: Tue, 18 Apr 2023 17:46:02 +0300 Subject: [PATCH 01/10] member profile added --- .../Blogging/Members/IMemberAppService.cs | 10 +++ .../Volo/Blogging/Posts/IPostAppService.cs | 3 + .../Volo/Blogging/Members/MemberAppService.cs | 24 ++++++ .../Volo/Blogging/Posts/PostAppService.cs | 11 +++ .../Volo/Blogging/Posts/IPostRepository.cs | 2 + .../Blogging/Posts/EfCorePostRepository.cs | 9 ++ .../Volo/Blogging/PostsController.cs | 8 ++ .../Blogging/Posts/MongoPostRepository.cs | 8 ++ .../Volo.Blogging.Web/BloggingWebModule.cs | 1 + .../Pages/Members/Index.cshtml | 86 +++++++++++++++++++ .../Pages/Members/Index.cshtml.cs | 43 ++++++++++ 11 files changed, 205 insertions(+) create mode 100644 modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Members/IMemberAppService.cs create mode 100644 modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Members/MemberAppService.cs create mode 100644 modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml create mode 100644 modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml.cs diff --git a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Members/IMemberAppService.cs b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Members/IMemberAppService.cs new file mode 100644 index 0000000000..5e06d20956 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Members/IMemberAppService.cs @@ -0,0 +1,10 @@ +using System.Threading.Tasks; +using Volo.Abp.Application.Services; +using Volo.Blogging.Posts; + +namespace Volo.Blogging.Members; + +public interface IMemberAppService : IApplicationService +{ + Task FindAsync(string username); +} \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Posts/IPostAppService.cs b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Posts/IPostAppService.cs index 8f1f2c251d..e4af45a345 100644 --- a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Posts/IPostAppService.cs +++ b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Posts/IPostAppService.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Threading.Tasks; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; @@ -20,5 +21,7 @@ namespace Volo.Blogging.Posts Task CreateAsync(CreatePostDto input); Task UpdateAsync(Guid id, UpdatePostDto input); + + Task> GetListByUserIdAsync(Guid userId); } } diff --git a/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Members/MemberAppService.cs b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Members/MemberAppService.cs new file mode 100644 index 0000000000..d22c2fae53 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Members/MemberAppService.cs @@ -0,0 +1,24 @@ +using System; +using System.Threading.Tasks; +using Volo.Abp.Domain.Repositories; +using Volo.Blogging.Posts; +using Volo.Blogging.Users; + +namespace Volo.Blogging.Members; + +public class MemberAppService : BloggingAppServiceBase, IMemberAppService +{ + private readonly IRepository _userRepository; + + public MemberAppService(IRepository userRepository) + { + _userRepository = userRepository; + } + + public async Task FindAsync(string username) + { + var user = await _userRepository.FindAsync(x => x.UserName == username); + + return ObjectMapper.Map(user); + } +} \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAppService.cs b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAppService.cs index 15506ecf70..da2db68db4 100644 --- a/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAppService.cs +++ b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAppService.cs @@ -188,6 +188,17 @@ namespace Volo.Blogging.Posts return ObjectMapper.Map(post); } + public async Task> GetListByUserIdAsync(Guid userId) + { + var posts = await PostRepository.GetListByUserIdAsync(userId); + + if (CurrentUser != null) + { + + } + return ObjectMapper.Map, List>(posts); + } + [Authorize(BloggingPermissions.Posts.Create)] public async Task CreateAsync(CreatePostDto input) { diff --git a/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Posts/IPostRepository.cs b/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Posts/IPostRepository.cs index b5446515bf..33a6377264 100644 --- a/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Posts/IPostRepository.cs +++ b/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Posts/IPostRepository.cs @@ -15,5 +15,7 @@ namespace Volo.Blogging.Posts Task GetPostByUrl(Guid blogId, string url, CancellationToken cancellationToken = default); Task> GetOrderedList(Guid blogId,bool descending = false, CancellationToken cancellationToken = default); + + Task> GetListByUserIdAsync(Guid userId, CancellationToken cancellationToken = default); } } diff --git a/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Posts/EfCorePostRepository.cs b/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Posts/EfCorePostRepository.cs index a676816dee..34d835d447 100644 --- a/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Posts/EfCorePostRepository.cs +++ b/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Posts/EfCorePostRepository.cs @@ -8,6 +8,7 @@ using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; using Volo.Blogging.EntityFrameworkCore; +using Volo.Blogging.Users; namespace Volo.Blogging.Posts { @@ -61,6 +62,14 @@ namespace Volo.Blogging.Posts } + public async Task> GetListByUserIdAsync(Guid userId, CancellationToken cancellationToken = default) + { + var query = (await GetDbSetAsync()).Where(p => p.CreatorId == userId) + .OrderBy(p => p.CreationTime); + + return await query.ToListAsync(GetCancellationToken(cancellationToken)); + } + public override async Task> WithDetailsAsync() { return (await GetQueryableAsync()).IncludeDetails(); diff --git a/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/PostsController.cs b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/PostsController.cs index 03cd460ed2..f2f31261a6 100644 --- a/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/PostsController.cs +++ b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/PostsController.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Volo.Abp; @@ -60,6 +61,13 @@ namespace Volo.Blogging { return _postAppService.UpdateAsync(id, input); } + + [HttpGet] + [Route("user/{userId}")] + public Task> GetListByUserIdAsync(Guid userId) + { + return _postAppService.GetListByUserIdAsync(userId); + } [HttpDelete] [Route("{id}")] diff --git a/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Posts/MongoPostRepository.cs b/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Posts/MongoPostRepository.cs index a2d79c9466..7c64cd79e9 100644 --- a/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Posts/MongoPostRepository.cs +++ b/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Posts/MongoPostRepository.cs @@ -58,5 +58,13 @@ namespace Volo.Blogging.Posts return await query.OrderByDescending(x => x.CreationTime).ToListAsync(GetCancellationToken(cancellationToken)); } + + public async Task> GetListByUserIdAsync(Guid userId, CancellationToken cancellationToken = default) + { + var query = (await GetMongoQueryableAsync(cancellationToken)).Where(x => x.CreatorId == userId) + .OrderBy(x => x.CreationTime); + + return await query.ToListAsync(GetCancellationToken(cancellationToken)); + } } } diff --git a/modules/blogging/src/Volo.Blogging.Web/BloggingWebModule.cs b/modules/blogging/src/Volo.Blogging.Web/BloggingWebModule.cs index 1391a5de19..dd8d65ea6b 100644 --- a/modules/blogging/src/Volo.Blogging.Web/BloggingWebModule.cs +++ b/modules/blogging/src/Volo.Blogging.Web/BloggingWebModule.cs @@ -95,6 +95,7 @@ namespace Volo.Blogging options.Conventions.AddPageRoute("/Blogs/Posts/Detail", routePrefix + "{blogShortName:blogNameConstraint}/{postUrl}"); options.Conventions.AddPageRoute("/Blogs/Posts/Edit", routePrefix + "{blogShortName}/posts/{postId}/edit"); options.Conventions.AddPageRoute("/Blogs/Posts/New", routePrefix + "{blogShortName}/posts/new"); + options.Conventions.AddPageRoute("/Members/Index", routePrefix + "members/{userName}"); }); Configure(options => diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml new file mode 100644 index 0000000000..1084d2bd35 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml @@ -0,0 +1,86 @@ +@page +@using System.Text +@using Microsoft.Extensions.Localization +@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Alert +@using Volo.Abp.Users +@using Volo.Blogging.Localization +@model Volo.Blogging.Pages.Members.IndexModel +@inject IStringLocalizer L +@inject ICurrentUser CurrentUser + + + +
+
+
+
+
+
+ @if (Model.User.UserName == CurrentUser.UserName) + { +
+ +
+ } + else + { + + } + @if (Model.User.UserName != null) + { +

@Model.User.UserName

+ } + + @L["UserName"].Value.ToUpper() +
@Model.User.UserName
+
+
+
+
+ + +
+ @foreach (var post in Model.Posts) + { +
+
+ + + + +
+
+ + +

+ @if ((post.Title).Any()) + { + @foreach (var highlight in post.Title) + { + @Html.Raw(highlight) + } + } + else + { + @post.Title + } +

+
+
+ +
+
+ } +
+
+
+
+
+
+
\ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml.cs b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml.cs new file mode 100644 index 0000000000..13881fb408 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; +using Volo.Blogging.Members; +using Volo.Blogging.Posts; + +namespace Volo.Blogging.Pages.Members; + +public class IndexModel : AbpPageModel +{ + private readonly IPostAppService _postAppService; + + private readonly IMemberAppService _memberAppService; + public BlogUserDto User { get; set; } + public List Posts { get; set; } + + public IndexModel(IPostAppService postAppService, IMemberAppService memberAppService) + { + _postAppService = postAppService; + _memberAppService = memberAppService; + } + + public async Task OnGetAsync(string userName) + { + User = await _memberAppService.FindAsync(userName); + + if (User is null) + { + return Redirect("/abp"); + } + + Posts = await _postAppService.GetListByUserIdAsync(User.Id); + + return Page(); + } + + public async Task OnPostAsync() + { + return Redirect($"/members/{CurrentUser.UserName}"); + } + +} \ No newline at end of file From 94f9f765ab8f2fc205dbb5ec52b666eef30a1a76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Onur=20P=C4=B1=C3=A7akc=C4=B1?= Date: Wed, 19 Apr 2023 12:10:12 +0300 Subject: [PATCH 02/10] user interface edits have been made --- .../Blogging/Localization/Resources/en.json | 3 +- .../Helpers/PostCoverImageHelper.cs | 48 ++++++++++++++++ .../Pages/Blogs/Posts/Detail.cshtml | 11 +++- .../Pages/Blogs/Posts/Index.cshtml | 12 +++- .../Pages/Members/Index.cshtml | 55 ++++++++++--------- .../Pages/Members/Index.cshtml.cs | 1 + .../Volo.Blogging.Web/Pages/Members/Index.css | 3 + 7 files changed, 99 insertions(+), 34 deletions(-) create mode 100644 modules/blogging/src/Volo.Blogging.Web/Helpers/PostCoverImageHelper.cs create mode 100644 modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.css diff --git a/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Localization/Resources/en.json b/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Localization/Resources/en.json index b9f4e44bde..e0bc82f669 100644 --- a/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Localization/Resources/en.json +++ b/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Localization/Resources/en.json @@ -59,6 +59,7 @@ "ClearCacheConfirmationMessage": "Are you sure you want to clear the cache?", "MarkdownSupported": "Markdown is supported", "FileUploadInfo": "Drag, drop, or paste a copied image.", - "PostDescriptionHint": "* Will be rendered in the article link preview, supports HTML" + "PostDescriptionHint": "* Will be rendered in the article link preview, supports HTML", + "ReadMore": "Continue Reading" } } \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Web/Helpers/PostCoverImageHelper.cs b/modules/blogging/src/Volo.Blogging.Web/Helpers/PostCoverImageHelper.cs new file mode 100644 index 0000000000..a2fc22daea --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Web/Helpers/PostCoverImageHelper.cs @@ -0,0 +1,48 @@ +using System; +using System.Linq; + +namespace Volo.Blogging.Helpers; + +public static class PostCoverImageHelper +{ + private static readonly string[] PostColors = + { + "linear-gradient(135deg, #4b2d21 0%, #7d4b37 100%)", + "linear-gradient(135deg, #41003d 0%, #a10097 100%)", + "linear-gradient(135deg, #163e4b 0%, #297791 100%)", + "linear-gradient(135deg, #660040 0%, #aa006b 100%)", + "linear-gradient(135deg, #240d88 0%, #571fff 100%)", + "linear-gradient(135deg, #0d6a88 0%, #16b0e1 100%)", + "linear-gradient(135deg, #329063 0%, #4be099 100%)", + "linear-gradient(135deg, #904432 0%, #f07153 100%)", + "linear-gradient(135deg, #903282 0%, #e04cca 100%)", + "linear-gradient(135deg, #901943 0%, #f02a70 100%)", + "linear-gradient(135deg, #2e634a 0%, #4da57b 100%)", + "linear-gradient(135deg, #9c003f 0%, #e41d6f 100%)", + "linear-gradient(135deg, #806419 0%, #d5a72a 100%)", + "linear-gradient(135deg, #545975 0%, #8890bd 100%)", + "linear-gradient(135deg, #67172a 0%, #ba2549 100%)" + }; + + public static string GetRandomColor(string postTitle) + { + long total = postTitle.Truncate(32).ToCharArray().Sum(c => c); + return PostColors[total % PostColors.Length]; + } + + public static string GetTitleCapitals(string postTitle) + { + if (postTitle.Length < 2) + { + return postTitle.ToUpperInvariant(); + } + + if (postTitle.Contains(" ")) + { + var splitted = postTitle.Split(" "); + return (splitted[0][0].ToString() + splitted[1][0].ToString()).ToUpperInvariant(); + } + + return postTitle.ToUpperInvariant().Left(2); + } +} \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Detail.cshtml b/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Detail.cshtml index 5912e4e6c9..f893907e66 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Detail.cshtml +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Detail.cshtml @@ -65,14 +65,19 @@
@if (Model.Post.Writer != null) { - + + + }
@if (Model.Post.Writer != null) { -
@(Model.Post.Writer.UserName) @BloggingPageHelper.ConvertDatetimeToTimeAgo(Model.Post.CreationTime)
- + +
+ @(Model.Post.Writer.UserName) @BloggingPageHelper.ConvertDatetimeToTimeAgo(Model.Post.CreationTime) +
+
} @L["WiewsWithCount", @Model.Post.ReadCount] diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Index.cshtml b/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Index.cshtml index 03514aaf3a..e14dadc874 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Index.cshtml +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Index.cshtml @@ -59,11 +59,17 @@
- + + +
-
@post.Writer.UserName @BloggingPageHelper.ConvertDatetimeToTimeAgo(post.CreationTime)
- @L["WiewsWithCount", post.ReadCount] + +
+ @post.Writer.UserName @BloggingPageHelper.ConvertDatetimeToTimeAgo(post.CreationTime) +
+
+ @L["WiewsWithCount", post.ReadCount] @*| @L["CommentWithCount", post.CommentCount]*@
diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml index 1084d2bd35..f698f9a0b9 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml @@ -1,13 +1,19 @@ @page -@using System.Text @using Microsoft.Extensions.Localization -@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Alert +@using Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers @using Volo.Abp.Users +@using Volo.Blogging.Helpers @using Volo.Blogging.Localization @model Volo.Blogging.Pages.Members.IndexModel @inject IStringLocalizer L @inject ICurrentUser CurrentUser +@{ + ViewBag.Title = @Model.User.UserName.ToUpper() + " - " + L["Blogs"].Value; +} +@section styles { + +}
@@ -16,21 +22,13 @@
- @if (Model.User.UserName == CurrentUser.UserName) - { -
- -
- } - else - { - - } +
+ +
@if (Model.User.UserName != null) {

@Model.User.UserName

} - @L["UserName"].Value.ToUpper()
@Model.User.UserName
@@ -38,7 +36,7 @@
- +
@foreach (var post in Model.Posts) { @@ -46,8 +44,12 @@
- + + + + @L["Blog"].Value.ToUpper() +
-

- @if ((post.Title).Any()) - { - @foreach (var highlight in post.Title) - { - @Html.Raw(highlight) - } - } - else - { + @post.Title - } +

+

+ + @(post.Description.Length >= 150 ? post.Description.Substring(0, 150) + "..." : post.Description) + + @L["ReadMore"] +

- +
+ @PostCoverImageHelper.GetTitleCapitals(post.Title) +
} diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml.cs b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml.cs index 13881fb408..d57534ac2b 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml.cs +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; +using Volo.Blogging.Blogs.Dtos; using Volo.Blogging.Members; using Volo.Blogging.Posts; diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.css b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.css new file mode 100644 index 0000000000..4c5167a694 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.css @@ -0,0 +1,3 @@ +.post-desc { + overflow-wrap: break-word; +} \ No newline at end of file From a5352d5fef6ae759a9de592a3c74527ee47a46d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Onur=20P=C4=B1=C3=A7akc=C4=B1?= Date: Wed, 19 Apr 2023 12:43:32 +0300 Subject: [PATCH 03/10] Update PostAppService.cs --- .../Volo/Blogging/Posts/PostAppService.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAppService.cs b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAppService.cs index da2db68db4..0158dc0e5a 100644 --- a/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAppService.cs +++ b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAppService.cs @@ -191,11 +191,7 @@ namespace Volo.Blogging.Posts public async Task> GetListByUserIdAsync(Guid userId) { var posts = await PostRepository.GetListByUserIdAsync(userId); - - if (CurrentUser != null) - { - - } + return ObjectMapper.Map, List>(posts); } From 20ec1b371a261935dbb094d806dbd7f2fce4b3d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Onur=20P=C4=B1=C3=A7akc=C4=B1?= Date: Wed, 19 Apr 2023 12:46:04 +0300 Subject: [PATCH 04/10] fix clientProxy --- .../ClientProxies/PostsClientProxy.Generated.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/blogging/src/Volo.Blogging.HttpApi.Client/ClientProxies/PostsClientProxy.Generated.cs b/modules/blogging/src/Volo.Blogging.HttpApi.Client/ClientProxies/PostsClientProxy.Generated.cs index 17ee93818a..697606f05c 100644 --- a/modules/blogging/src/Volo.Blogging.HttpApi.Client/ClientProxies/PostsClientProxy.Generated.cs +++ b/modules/blogging/src/Volo.Blogging.HttpApi.Client/ClientProxies/PostsClientProxy.Generated.cs @@ -1,5 +1,6 @@ // This file is automatically generated by ABP framework to use MVC Controllers from CSharp using System; +using System.Collections.Generic; using System.Threading.Tasks; using Volo.Abp.Application.Dtos; using Volo.Abp.Http.Client; @@ -65,6 +66,14 @@ public partial class PostsClientProxy : ClientProxyBase, IPostA }); } + public virtual async Task> GetListByUserIdAsync(Guid userId) + { + return await RequestAsync>(nameof(GetListByUserIdAsync), new ClientProxyRequestTypeValue + { + { typeof(Guid), userId } + }); + } + public virtual async Task DeleteAsync(Guid id) { await RequestAsync(nameof(DeleteAsync), new ClientProxyRequestTypeValue From e74a057553282dfb5999924e0ac8d03d9cf846f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Onur=20P=C4=B1=C3=A7akc=C4=B1?= Date: Wed, 19 Apr 2023 16:55:31 +0300 Subject: [PATCH 05/10] refactor code --- .../Pages/_ViewImports.cshtml | 5 ++ .../Blogging/Members/IMemberAppService.cs | 2 +- .../Volo/Blogging/Members/MemberAppService.cs | 6 +-- .../Helpers/PostCoverImageHelper.cs | 48 ------------------- .../Pages/Blogs/Posts/Index.cshtml | 1 + .../Pages/Members/Index.cshtml | 18 ++++--- .../Pages/Members/Index.cshtml.cs | 10 ++-- 7 files changed, 24 insertions(+), 66 deletions(-) create mode 100644 modules/blogging/app/Volo.BloggingTestApp/Pages/_ViewImports.cshtml delete mode 100644 modules/blogging/src/Volo.Blogging.Web/Helpers/PostCoverImageHelper.cs diff --git a/modules/blogging/app/Volo.BloggingTestApp/Pages/_ViewImports.cshtml b/modules/blogging/app/Volo.BloggingTestApp/Pages/_ViewImports.cshtml new file mode 100644 index 0000000000..caae8c9ac5 --- /dev/null +++ b/modules/blogging/app/Volo.BloggingTestApp/Pages/_ViewImports.cshtml @@ -0,0 +1,5 @@ +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers +@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI +@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap +@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bundling +@addTagHelper *, Volo.Blogging.Web \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Members/IMemberAppService.cs b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Members/IMemberAppService.cs index 5e06d20956..0cf992a467 100644 --- a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Members/IMemberAppService.cs +++ b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Members/IMemberAppService.cs @@ -6,5 +6,5 @@ namespace Volo.Blogging.Members; public interface IMemberAppService : IApplicationService { - Task FindAsync(string username); + Task GetAsync(string username); } \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Members/MemberAppService.cs b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Members/MemberAppService.cs index d22c2fae53..936a0ae0ef 100644 --- a/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Members/MemberAppService.cs +++ b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Members/MemberAppService.cs @@ -14,10 +14,10 @@ public class MemberAppService : BloggingAppServiceBase, IMemberAppService { _userRepository = userRepository; } - - public async Task FindAsync(string username) + + public async Task GetAsync(string username) { - var user = await _userRepository.FindAsync(x => x.UserName == username); + var user = await _userRepository.GetAsync(x => x.UserName == username); return ObjectMapper.Map(user); } diff --git a/modules/blogging/src/Volo.Blogging.Web/Helpers/PostCoverImageHelper.cs b/modules/blogging/src/Volo.Blogging.Web/Helpers/PostCoverImageHelper.cs deleted file mode 100644 index a2fc22daea..0000000000 --- a/modules/blogging/src/Volo.Blogging.Web/Helpers/PostCoverImageHelper.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Linq; - -namespace Volo.Blogging.Helpers; - -public static class PostCoverImageHelper -{ - private static readonly string[] PostColors = - { - "linear-gradient(135deg, #4b2d21 0%, #7d4b37 100%)", - "linear-gradient(135deg, #41003d 0%, #a10097 100%)", - "linear-gradient(135deg, #163e4b 0%, #297791 100%)", - "linear-gradient(135deg, #660040 0%, #aa006b 100%)", - "linear-gradient(135deg, #240d88 0%, #571fff 100%)", - "linear-gradient(135deg, #0d6a88 0%, #16b0e1 100%)", - "linear-gradient(135deg, #329063 0%, #4be099 100%)", - "linear-gradient(135deg, #904432 0%, #f07153 100%)", - "linear-gradient(135deg, #903282 0%, #e04cca 100%)", - "linear-gradient(135deg, #901943 0%, #f02a70 100%)", - "linear-gradient(135deg, #2e634a 0%, #4da57b 100%)", - "linear-gradient(135deg, #9c003f 0%, #e41d6f 100%)", - "linear-gradient(135deg, #806419 0%, #d5a72a 100%)", - "linear-gradient(135deg, #545975 0%, #8890bd 100%)", - "linear-gradient(135deg, #67172a 0%, #ba2549 100%)" - }; - - public static string GetRandomColor(string postTitle) - { - long total = postTitle.Truncate(32).ToCharArray().Sum(c => c); - return PostColors[total % PostColors.Length]; - } - - public static string GetTitleCapitals(string postTitle) - { - if (postTitle.Length < 2) - { - return postTitle.ToUpperInvariant(); - } - - if (postTitle.Contains(" ")) - { - var splitted = postTitle.Split(" "); - return (splitted[0][0].ToString() + splitted[1][0].ToString()).ToUpperInvariant(); - } - - return postTitle.ToUpperInvariant().Left(2); - } -} \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Index.cshtml b/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Index.cshtml index e14dadc874..78c466e8c9 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Index.cshtml +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Index.cshtml @@ -1,5 +1,6 @@ @page @using Microsoft.AspNetCore.Authorization +@using Volo.Blogging.Areas.Blog.Helpers.TagHelpers @using Volo.Abp.AspNetCore.Mvc.UI.Packages.OwlCarousel @using Volo.Blogging @inject IAuthorizationService Authorization diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml index f698f9a0b9..cfe77816a9 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml @@ -2,7 +2,6 @@ @using Microsoft.Extensions.Localization @using Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers @using Volo.Abp.Users -@using Volo.Blogging.Helpers @using Volo.Blogging.Localization @model Volo.Blogging.Pages.Members.IndexModel @inject IStringLocalizer L @@ -15,15 +14,14 @@ } - -
+
- +
@if (Model.User.UserName != null) { @@ -36,7 +34,7 @@
- +
@foreach (var post in Model.Posts) { @@ -44,7 +42,7 @@
- + @@ -65,16 +63,16 @@

- + @(post.Description.Length >= 150 ? post.Description.Substring(0, 150) + "..." : post.Description) @L["ReadMore"]

-
- @PostCoverImageHelper.GetTitleCapitals(post.Title) -
+
+ +
} diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml.cs b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml.cs index d57534ac2b..4debc19527 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml.cs +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; +using Volo.Blogging.Blogs; using Volo.Blogging.Blogs.Dtos; using Volo.Blogging.Members; using Volo.Blogging.Posts; @@ -13,9 +14,10 @@ public class IndexModel : AbpPageModel private readonly IPostAppService _postAppService; private readonly IMemberAppService _memberAppService; + public BlogUserDto User { get; set; } public List Posts { get; set; } - + public IndexModel(IPostAppService postAppService, IMemberAppService memberAppService) { _postAppService = postAppService; @@ -24,15 +26,15 @@ public class IndexModel : AbpPageModel public async Task OnGetAsync(string userName) { - User = await _memberAppService.FindAsync(userName); + User = await _memberAppService.GetAsync(userName); if (User is null) { - return Redirect("/abp"); + return Redirect("/"); } Posts = await _postAppService.GetListByUserIdAsync(User.Id); - + return Page(); } From 17bd337678390d8ff63e23f3e312ea21040cd324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Onur=20P=C4=B1=C3=A7akc=C4=B1?= Date: Thu, 20 Apr 2023 12:45:20 +0300 Subject: [PATCH 06/10] user interface designs and queries have been edited --- .../Blogging/Localization/Resources/en.json | 3 +- .../Blogging/Posts/EfCorePostRepository.cs | 2 +- .../Pages/Members/Index.cshtml | 97 +++++++++++-------- .../Pages/Members/Index.cshtml.cs | 30 +++++- 4 files changed, 82 insertions(+), 50 deletions(-) diff --git a/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Localization/Resources/en.json b/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Localization/Resources/en.json index e0bc82f669..a9120aae79 100644 --- a/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Localization/Resources/en.json +++ b/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Localization/Resources/en.json @@ -60,6 +60,7 @@ "MarkdownSupported": "Markdown is supported", "FileUploadInfo": "Drag, drop, or paste a copied image.", "PostDescriptionHint": "* Will be rendered in the article link preview, supports HTML", - "ReadMore": "Continue Reading" + "ReadMore": "Continue Reading", + "MemberNotPublishedPostYet": "This member hasn't published any posts yet." } } \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Posts/EfCorePostRepository.cs b/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Posts/EfCorePostRepository.cs index 34d835d447..48dfabb77e 100644 --- a/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Posts/EfCorePostRepository.cs +++ b/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Posts/EfCorePostRepository.cs @@ -65,7 +65,7 @@ namespace Volo.Blogging.Posts public async Task> GetListByUserIdAsync(Guid userId, CancellationToken cancellationToken = default) { var query = (await GetDbSetAsync()).Where(p => p.CreatorId == userId) - .OrderBy(p => p.CreationTime); + .OrderByDescending(p => p.CreationTime); return await query.ToListAsync(GetCancellationToken(cancellationToken)); } diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml index cfe77816a9..c237389dcb 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml @@ -32,54 +32,65 @@
-
- - -
- @foreach (var post in Model.Posts) - { -
-
+ @if (Model.Posts is not null && Model.Posts.Any()) + { +
+ + +
+ @foreach (var post in Model.Posts) + { +
+
- - - - - - @L["Blog"].Value.ToUpper() - -
-
- -

- - @post.Title - -

-

- - @(post.Description.Length >= 150 ? post.Description.Substring(0, 150) + "..." : post.Description) - - @L["ReadMore"] -

-
-
-
- +
+ +

+ + @post.Title + +

+

+ + @(post.Description.Length >= 150 ? post.Description.Substring(0, 150) + "..." : post.Description) + + @L["ReadMore"] +

+
+
+
+ +
-
- } -
- - -
+ } +
+ + +
+ } + else + { +
+
+

@L["MemberNotPublishedPostYet"]

+
+
+ }
\ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml.cs b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml.cs index 4debc19527..b8a215c923 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml.cs +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml.cs @@ -1,9 +1,10 @@ +using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; using Volo.Blogging.Blogs; -using Volo.Blogging.Blogs.Dtos; using Volo.Blogging.Members; using Volo.Blogging.Posts; @@ -15,13 +16,18 @@ public class IndexModel : AbpPageModel private readonly IMemberAppService _memberAppService; + private readonly IBlogAppService _blogAppService; + public BlogUserDto User { get; set; } public List Posts { get; set; } + + public Dictionary BlogShortNameMap { get; set; } - public IndexModel(IPostAppService postAppService, IMemberAppService memberAppService) + public IndexModel(IPostAppService postAppService, IMemberAppService memberAppService, IBlogAppService blogAppService) { _postAppService = postAppService; _memberAppService = memberAppService; + _blogAppService = blogAppService; } public async Task OnGetAsync(string userName) @@ -32,15 +38,29 @@ public class IndexModel : AbpPageModel { return Redirect("/"); } - + Posts = await _postAppService.GetListByUserIdAsync(User.Id); + + var blogIds = Posts.Select(x => x.BlogId).Distinct(); + BlogShortNameMap = new Dictionary(); + + foreach (var blogId in blogIds) + { + BlogShortNameMap[blogId] = (await _blogAppService.GetAsync(blogId)).ShortName; + } return Page(); } + public string GetBlogPostUrl(PostWithDetailsDto post) + { + var blogShortName = BlogShortNameMap[post.BlogId]; + + return "/" + blogShortName + "/" + post.Url; + } - public async Task OnPostAsync() + public string GetMemberProfileUrl(BlogUserDto user) { - return Redirect($"/members/{CurrentUser.UserName}"); + return "/members/" + user.UserName; } } \ No newline at end of file From 562622dd04854d3a954674330c9a88e62872017a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Onur=20P=C4=B1=C3=A7akc=C4=B1?= Date: Tue, 25 Apr 2023 08:22:48 +0300 Subject: [PATCH 07/10] updated user profile ui --- .../blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml index c237389dcb..471eb765ab 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml @@ -27,7 +27,7 @@ {

@Model.User.UserName

} - @L["UserName"].Value.ToUpper() + @L["UserName"].Value.ToUpper()
@Model.User.UserName
From f41d4f07b28fc3ac0d5907808ab3447d012e7fe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alper=20Ebi=C3=A7o=C4=9Flu?= <9526587+ebicoglu@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:20:32 +0300 Subject: [PATCH 08/10] Update en.json --- .../Volo/Blogging/Localization/Resources/en.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Localization/Resources/en.json b/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Localization/Resources/en.json index a9120aae79..d4bfede795 100644 --- a/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Localization/Resources/en.json +++ b/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Localization/Resources/en.json @@ -61,6 +61,6 @@ "FileUploadInfo": "Drag, drop, or paste a copied image.", "PostDescriptionHint": "* Will be rendered in the article link preview, supports HTML", "ReadMore": "Continue Reading", - "MemberNotPublishedPostYet": "This member hasn't published any posts yet." + "MemberNotPublishedPostYet": "No posts yet!" } -} \ No newline at end of file +} From 61e79c7366183dae9bb2b871784a33080c84c3dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Onur=20P=C4=B1=C3=A7akc=C4=B1?= Date: Tue, 25 Apr 2023 11:12:39 +0300 Subject: [PATCH 09/10] refactoring --- .../Blogging/Members/IMemberAppService.cs | 2 +- .../Volo/Blogging/Members/MemberAppService.cs | 4 +-- .../MembersClientProxy.Generated.cs | 28 +++++++++++++++++++ .../ClientProxies/MembersClientProxy.cs | 7 +++++ .../Blogging/Posts/MongoPostRepository.cs | 2 +- .../Pages/Members/Index.cshtml | 2 +- .../Pages/Members/Index.cshtml.cs | 2 +- 7 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 modules/blogging/src/Volo.Blogging.HttpApi.Client/ClientProxies/MembersClientProxy.Generated.cs create mode 100644 modules/blogging/src/Volo.Blogging.HttpApi.Client/ClientProxies/MembersClientProxy.cs diff --git a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Members/IMemberAppService.cs b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Members/IMemberAppService.cs index 0cf992a467..5e06d20956 100644 --- a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Members/IMemberAppService.cs +++ b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Members/IMemberAppService.cs @@ -6,5 +6,5 @@ namespace Volo.Blogging.Members; public interface IMemberAppService : IApplicationService { - Task GetAsync(string username); + Task FindAsync(string username); } \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Members/MemberAppService.cs b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Members/MemberAppService.cs index 936a0ae0ef..eab4f43009 100644 --- a/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Members/MemberAppService.cs +++ b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Members/MemberAppService.cs @@ -15,9 +15,9 @@ public class MemberAppService : BloggingAppServiceBase, IMemberAppService _userRepository = userRepository; } - public async Task GetAsync(string username) + public async Task FindAsync(string username) { - var user = await _userRepository.GetAsync(x => x.UserName == username); + var user = await _userRepository.FindAsync(x => x.UserName == username); return ObjectMapper.Map(user); } diff --git a/modules/blogging/src/Volo.Blogging.HttpApi.Client/ClientProxies/MembersClientProxy.Generated.cs b/modules/blogging/src/Volo.Blogging.HttpApi.Client/ClientProxies/MembersClientProxy.Generated.cs new file mode 100644 index 0000000000..dfabaed346 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.HttpApi.Client/ClientProxies/MembersClientProxy.Generated.cs @@ -0,0 +1,28 @@ +// This file is automatically generated by ABP framework to use MVC Controllers from CSharp +using System; +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Http.Client; +using Volo.Abp.Http.Modeling; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Http.Client.ClientProxying; +using Volo.Blogging.Blogs; +using Volo.Blogging.Blogs.Dtos; +using Volo.Blogging.Members; +using Volo.Blogging.Posts; + +// ReSharper disable once CheckNamespace +namespace Volo.Blogging.ClientProxies; + +[Dependency(ReplaceServices = true)] +[ExposeServices(typeof(IMemberAppService), typeof(MembersClientProxy))] +public partial class MembersClientProxy : ClientProxyBase, IMemberAppService +{ + public Task FindAsync(string username) + { + return RequestAsync(nameof(FindAsync), new ClientProxyRequestTypeValue + { + { typeof(string), username } + }); + } +} diff --git a/modules/blogging/src/Volo.Blogging.HttpApi.Client/ClientProxies/MembersClientProxy.cs b/modules/blogging/src/Volo.Blogging.HttpApi.Client/ClientProxies/MembersClientProxy.cs new file mode 100644 index 0000000000..61e4f3df1e --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.HttpApi.Client/ClientProxies/MembersClientProxy.cs @@ -0,0 +1,7 @@ +// This file is part of MembersClientProxy, you can customize it here +// ReSharper disable once CheckNamespace +namespace Volo.Blogging.ClientProxies; + +public partial class MembersClientProxy +{ +} diff --git a/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Posts/MongoPostRepository.cs b/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Posts/MongoPostRepository.cs index 7c64cd79e9..be6942eac2 100644 --- a/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Posts/MongoPostRepository.cs +++ b/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Posts/MongoPostRepository.cs @@ -62,7 +62,7 @@ namespace Volo.Blogging.Posts public async Task> GetListByUserIdAsync(Guid userId, CancellationToken cancellationToken = default) { var query = (await GetMongoQueryableAsync(cancellationToken)).Where(x => x.CreatorId == userId) - .OrderBy(x => x.CreationTime); + .OrderByDescending(x => x.CreationTime); return await query.ToListAsync(GetCancellationToken(cancellationToken)); } diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml index 471eb765ab..62841ae158 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml @@ -66,7 +66,7 @@

- @(post.Description.Length >= 150 ? post.Description.Substring(0, 150) + "..." : post.Description) + @post.Description.TruncateWithPostfix(150) @L["ReadMore"]

diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml.cs b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml.cs index b8a215c923..8018ea23e8 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml.cs +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml.cs @@ -32,7 +32,7 @@ public class IndexModel : AbpPageModel public async Task OnGetAsync(string userName) { - User = await _memberAppService.GetAsync(userName); + User = await _memberAppService.FindAsync(userName); if (User is null) { From d15fba726795a0d6ca5b966fceed36e82cb3f20b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Onur=20P=C4=B1=C3=A7akc=C4=B1?= Date: Tue, 25 Apr 2023 13:06:49 +0300 Subject: [PATCH 10/10] proxy.js updated --- .../Volo/Blogging/Members/MemberAppService.cs | 5 +++++ .../wwwroot/client-proxies/blogging-proxy.js | 21 ++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Members/MemberAppService.cs b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Members/MemberAppService.cs index eab4f43009..e27c0baefa 100644 --- a/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Members/MemberAppService.cs +++ b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Members/MemberAppService.cs @@ -19,6 +19,11 @@ public class MemberAppService : BloggingAppServiceBase, IMemberAppService { var user = await _userRepository.FindAsync(x => x.UserName == username); + if (user == null) + { + return null; + } + return ObjectMapper.Map(user); } } \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Web/wwwroot/client-proxies/blogging-proxy.js b/modules/blogging/src/Volo.Blogging.Web/wwwroot/client-proxies/blogging-proxy.js index c2872c74bf..f3358106d3 100644 --- a/modules/blogging/src/Volo.Blogging.Web/wwwroot/client-proxies/blogging-proxy.js +++ b/modules/blogging/src/Volo.Blogging.Web/wwwroot/client-proxies/blogging-proxy.js @@ -160,6 +160,12 @@ }, ajaxParams)); }; + volo.blogging.posts.getListByUserId = function (userId, ajaxParams) { + return abp.ajax($.extend(true, { + url: abp.appPath + 'api/blogging/posts/user/' + userId + '', + type: 'GET' + }, ajaxParams)); + }; })(); // controller volo.blogging.tags @@ -176,7 +182,20 @@ }; })(); - + + // controller volo.blogging.members + + (function() { + abp.utils.createNamespace(window, 'volo.blogging.members'); + + volo.blogging.members.get = function (username, ajaxParams) { + return abp.ajax($.extend(true, { + url: abp.appPath + 'api/blogging/members/' + username + '', + type: 'GET' + }, ajaxParams)); + }; + })(); + })();