From adc3585f38962ae9e916479f8014a2c52f30e3a4 Mon Sep 17 00:00:00 2001 From: Berkan Sasmaz Date: Tue, 18 May 2021 16:45:09 +0300 Subject: [PATCH] Change GetMyOrganizationsAsync to GetOrganizationsByUserIdAsync method --- .../Organizations/IOrganizationAppService.cs | 2 +- .../Organizations/OrganizationAppService.cs | 6 ++--- src/EventHub.Web/Pages/Members/Profile.cshtml | 24 ++++++++++++++++--- .../Pages/Members/Profile.cshtml.cs | 3 +-- .../Pages/Organizations/Profile.cshtml | 10 +++++++- 5 files changed, 34 insertions(+), 11 deletions(-) diff --git a/src/EventHub.Application.Contracts/Organizations/IOrganizationAppService.cs b/src/EventHub.Application.Contracts/Organizations/IOrganizationAppService.cs index 8e94ddb..0516a30 100644 --- a/src/EventHub.Application.Contracts/Organizations/IOrganizationAppService.cs +++ b/src/EventHub.Application.Contracts/Organizations/IOrganizationAppService.cs @@ -13,7 +13,7 @@ namespace EventHub.Organizations Task GetProfileAsync(string name); - Task> GetMyOrganizationsAsync(); + Task> GetOrganizationsByUserIdAsync(Guid userId); Task IsOrganizationOwnerAsync(Guid organizationId); diff --git a/src/EventHub.Application/Organizations/OrganizationAppService.cs b/src/EventHub.Application/Organizations/OrganizationAppService.cs index afbb847..50aa906 100644 --- a/src/EventHub.Application/Organizations/OrganizationAppService.cs +++ b/src/EventHub.Application/Organizations/OrganizationAppService.cs @@ -109,11 +109,9 @@ namespace EventHub.Organizations return organizationProfileDto; } - [Authorize] - public async Task> GetMyOrganizationsAsync() + public async Task> GetOrganizationsByUserIdAsync(Guid userId) { - var currentUserId = CurrentUser.GetId(); - var query = (await _organizationRepository.GetQueryableAsync()).Where(o => o.OwnerUserId == currentUserId); + var query = (await _organizationRepository.GetQueryableAsync()).Where(o => o.OwnerUserId == userId); var organizations = await AsyncExecuter.ToListAsync(query); var organizationDto = ObjectMapper.Map, List>(organizations); diff --git a/src/EventHub.Web/Pages/Members/Profile.cshtml b/src/EventHub.Web/Pages/Members/Profile.cshtml index cbea45e..d34f378 100644 --- a/src/EventHub.Web/Pages/Members/Profile.cshtml +++ b/src/EventHub.Web/Pages/Members/Profile.cshtml @@ -1,11 +1,14 @@ @page @using System.Globalization +@using EventHub.Localization @using EventHub.Web.Pages.Events.Components.EventsArea @using EventHub.Web.Pages.Organizations.Components.OrganizationsArea +@using Microsoft.AspNetCore.Mvc.Localization @using Volo.Abp.Timing @using Volo.Abp.Users @inject ICurrentUser CurrentUser @inject IClock Clock +@inject IHtmlLocalizer L @model EventHub.Web.Pages.Members.ProfileModel
@@ -59,9 +62,24 @@
-

Ownered Organizations

- -
+
+
+

+ Ownered Organizations +

+
+ @if (CurrentUser.IsAuthenticated) + { + @if (CurrentUser.Id == Model.User.Id) + { + + } + } +
+ +

Membership Organizations

@await Component.InvokeAsync(typeof(OrganizationsAreaViewComponent), new diff --git a/src/EventHub.Web/Pages/Members/Profile.cshtml.cs b/src/EventHub.Web/Pages/Members/Profile.cshtml.cs index 5b5175f..16ce570 100644 --- a/src/EventHub.Web/Pages/Members/Profile.cshtml.cs +++ b/src/EventHub.Web/Pages/Members/Profile.cshtml.cs @@ -27,8 +27,6 @@ namespace EventHub.Web.Pages.Members public async Task OnGetAsync(string userName) { - Organizations = (await _organizationAppService.GetMyOrganizationsAsync()).Items.ToList(); - if (userName.IsNullOrWhiteSpace()) { if (CurrentUser.IsAuthenticated) @@ -42,6 +40,7 @@ namespace EventHub.Web.Pages.Members } User = await _memberAppService.FindByUserNameAsync(userName); + Organizations = (await _organizationAppService.GetOrganizationsByUserIdAsync(User.Id)).Items.ToList(); if (User != null) { diff --git a/src/EventHub.Web/Pages/Organizations/Profile.cshtml b/src/EventHub.Web/Pages/Organizations/Profile.cshtml index 633e2e8..b17d781 100644 --- a/src/EventHub.Web/Pages/Organizations/Profile.cshtml +++ b/src/EventHub.Web/Pages/Organizations/Profile.cshtml @@ -1,6 +1,8 @@ @page "/organizations/{name}" @inject IHtmlLocalizer L @using EventHub.Localization +@using EventHub.Web.Helpers +@using EventHub.Web.Pages.Events @using EventHub.Web.Pages.Events.Components.EventsArea @using EventHub.Web.Pages.Organizations.Components.JoinArea @using EventHub.Web.Pages.Organizations.Components.MembersArea @@ -20,7 +22,13 @@
@if (Model.Organization.ProfilePictureContent == null) { - @Model.Organization.Name +
+ + @CoverImageHelper.GetContentOfImage(Model.Organization.DisplayName.TruncateWithPostfix(80)) +
+ @CoverImageHelper.GetContentOfImage("EventHub") +
+
} else {