mirror of https://github.com/abpframework/abp.git
11 changed files with 205 additions and 0 deletions
@ -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<BlogUserDto> FindAsync(string username); |
|||
} |
|||
@ -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<BlogUser, Guid> _userRepository; |
|||
|
|||
public MemberAppService(IRepository<BlogUser, Guid> userRepository) |
|||
{ |
|||
_userRepository = userRepository; |
|||
} |
|||
|
|||
public async Task<BlogUserDto> FindAsync(string username) |
|||
{ |
|||
var user = await _userRepository.FindAsync(x => x.UserName == username); |
|||
|
|||
return ObjectMapper.Map<BlogUser, BlogUserDto>(user); |
|||
} |
|||
} |
|||
@ -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<BloggingResource> L |
|||
@inject ICurrentUser CurrentUser |
|||
|
|||
|
|||
|
|||
<main class="pt-4" id="MemberDetail"> |
|||
<div class="container"> |
|||
<div class="row gx-lg-5"> |
|||
<div class="col-md-4 mb-5 mb-md-0"> |
|||
<div class="card h-auto member-profile-info"> |
|||
<div class="card-body"> |
|||
@if (Model.User.UserName == CurrentUser.UserName) |
|||
{ |
|||
<div class="d-inline-block position-relative"> |
|||
<img src="~/assets/noimg-user.jpeg" loading="lazy" data-src="https://localhost:44300/api/account/profile-picture-file/ + @Model.User.Id" class="profile-pic"/> |
|||
</div> |
|||
} |
|||
else |
|||
{ |
|||
<img src="~/assets/noimg-user.jpeg" loading="lazy" data-src="https://localhost:44300/api/account/profile-picture-file/ + @Model.User.Id" class="profile-pic"/> |
|||
} |
|||
@if (Model.User.UserName != null) |
|||
{ |
|||
<h2 class="m-0">@Model.User.UserName</h2> |
|||
} |
|||
|
|||
<small class="d-block">@L["UserName"].Value.ToUpper()</small> |
|||
<h5>@Model.User.UserName</h5> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="col-md-8"> |
|||
<abp-tabs> |
|||
<abp-tab name="all-posts" title="All @L["Blogs"].Value"> |
|||
<div class="mt-4 pt-3"> |
|||
@foreach (var post in Model.Posts) |
|||
{ |
|||
<div class="post-item"> |
|||
<div class="post-type-cont"> |
|||
|
|||
<a href="/members/@Model.User.UserName" class="text-decoration-none"> |
|||
<img src="~/assets/noimg-user.jpeg" data-src="https://localhost:44300/api/account/profile-picture-file/@Model.User.Id" class="post-member-img rounded-circle d-block"> |
|||
</a> |
|||
</div> |
|||
<div class="post-detail-cont"> |
|||
<div class="post-info fs-12 mb-2"> |
|||
<a href="/members/@Model.User.UserName" class="text-decoration-none"> |
|||
<span class="text-dark dot">@Model.User.UserName</span> |
|||
</a> |
|||
<span class="text-dark-200 dot">@post.CreationTime.ToString("MMMM yyyy")</span> |
|||
<span class="text-dark-200">@post.ReadCount.ToString() @L["Views"]</span> |
|||
</div> |
|||
|
|||
<h3 class="post-title mb-3"> |
|||
@if ((post.Title).Any()) |
|||
{ |
|||
@foreach (var highlight in post.Title) |
|||
{ |
|||
@Html.Raw(highlight) |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
@post.Title |
|||
} |
|||
</h3> |
|||
</div> |
|||
<div class="post-img-cont"> |
|||
<img src="~/assets/noimg.png" data-src="@post.CoverImage" class="" loading="lazy"/> |
|||
</div> |
|||
</div> |
|||
} |
|||
</div> |
|||
</abp-tab> |
|||
</abp-tabs> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</main> |
|||
@ -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<PostWithDetailsDto> Posts { get; set; } |
|||
|
|||
public IndexModel(IPostAppService postAppService, IMemberAppService memberAppService) |
|||
{ |
|||
_postAppService = postAppService; |
|||
_memberAppService = memberAppService; |
|||
} |
|||
|
|||
public async Task<IActionResult> 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<IActionResult> OnPostAsync() |
|||
{ |
|||
return Redirect($"/members/{CurrentUser.UserName}"); |
|||
} |
|||
|
|||
} |
|||
Loading…
Reference in new issue