From 28f057325af04acc5b4a75577d7eb8f0ef4cadf4 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Tue, 23 Mar 2021 17:26:38 +0430 Subject: [PATCH] #99 moving user public profile api to RMuseum --- RMuseum/Controllers/AppUserController.cs | 9 ++-- RMuseum/Controllers/GanjoorController.cs | 36 +++++++++++++ .../ViewModel/GanjoorUserPublicProfile.cs | 7 +-- RMuseum/RMuseum.xml | 53 +++++++++++++++++++ .../Controllers/AppUserControllerBase.cs | 38 ------------- RSecurityBackend/RSecurityBackend.xml | 53 ------------------- .../Services/Implementation/AppUserService.cs | 2 + 7 files changed, 99 insertions(+), 99 deletions(-) rename RSecurityBackend/Models/Auth/ViewModels/RUserPublicProfile.cs => RMuseum/Models/Auth/ViewModel/GanjoorUserPublicProfile.cs (89%) diff --git a/RMuseum/Controllers/AppUserController.cs b/RMuseum/Controllers/AppUserController.cs index a3f6c66b..6eac578f 100644 --- a/RMuseum/Controllers/AppUserController.cs +++ b/RMuseum/Controllers/AppUserController.cs @@ -1,11 +1,9 @@ -using Microsoft.AspNetCore.Cors; -using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using RSecurityBackend.Services; using RSecurityBackend.Controllers; using Microsoft.AspNetCore.Identity.UI.Services; using Microsoft.Extensions.Configuration; -using Audit.WebApi; namespace RMuseum.Controllers { @@ -30,11 +28,11 @@ namespace RMuseum.Controllers : base(configuration, appUserService, httpContextAccessor, userPermissionChecker, emailSender, imageFileService, captchaService) { - } + } + - /// /// Sign Up Email Subject @@ -197,5 +195,6 @@ namespace RMuseum.Controllers return true; } + } } diff --git a/RMuseum/Controllers/GanjoorController.cs b/RMuseum/Controllers/GanjoorController.cs index c3995659..70e832ab 100644 --- a/RMuseum/Controllers/GanjoorController.cs +++ b/RMuseum/Controllers/GanjoorController.cs @@ -3,11 +3,13 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; using RMuseum.Models.Auth.Memory; +using RMuseum.Models.Auth.ViewModel; using RMuseum.Models.Ganjoor; using RMuseum.Models.Ganjoor.ViewModels; using RMuseum.Models.GanjoorAudio.ViewModels; using RMuseum.Models.GanjoorIntegration.ViewModels; using RMuseum.Services; +using RSecurityBackend.Models.Auth.ViewModels; using RSecurityBackend.Models.Generic; using RSecurityBackend.Models.Image; using RSecurityBackend.Services; @@ -793,6 +795,40 @@ namespace RMuseum.Controllers return BadRequest(res.ExceptionString); } + /// + /// Get user public profile + /// + /// + /// + [HttpGet("user/profile/{id}")] + [AllowAnonymous] + [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(GanjoorUserPublicProfile))] + [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] + [ProducesResponseType((int)HttpStatusCode.NotFound)] + public async Task GetUserPublicProfile(Guid id) + { + RServiceResult userInfo = await _appUserService.GetUserInformation(id); + if (userInfo.Result == null) + { + if (string.IsNullOrEmpty(userInfo.ExceptionString)) + return NotFound(); + return BadRequest(userInfo.ExceptionString); + } + return Ok + ( + new GanjoorUserPublicProfile() + { + Id = id, + FirstName = userInfo.Result.FirstName, + SureName = userInfo.Result.SureName, + NickName = userInfo.Result.NickName, + Bio = userInfo.Result.Bio, + Website = userInfo.Result.Website, + RImageId = userInfo.Result.RImageId + } + ); + } + /// /// Get Verses By query diff --git a/RSecurityBackend/Models/Auth/ViewModels/RUserPublicProfile.cs b/RMuseum/Models/Auth/ViewModel/GanjoorUserPublicProfile.cs similarity index 89% rename from RSecurityBackend/Models/Auth/ViewModels/RUserPublicProfile.cs rename to RMuseum/Models/Auth/ViewModel/GanjoorUserPublicProfile.cs index c7a68315..20c3be2c 100644 --- a/RSecurityBackend/Models/Auth/ViewModels/RUserPublicProfile.cs +++ b/RMuseum/Models/Auth/ViewModel/GanjoorUserPublicProfile.cs @@ -1,11 +1,11 @@ using System; -namespace RSecurityBackend.Models.Auth.ViewModels +namespace RMuseum.Models.Auth.ViewModel { /// - /// user public profile + /// ganjoor user public profile /// - public class RUserPublicProfile + public class GanjoorUserPublicProfile { /// /// Id @@ -48,5 +48,6 @@ namespace RSecurityBackend.Models.Auth.ViewModels /// web site /// public string Website { get; set; } + } } diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index 22538f3f..19a85a1b 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -842,6 +842,13 @@ + + + Get user public profile + + + + Get Verses By query @@ -2149,6 +2156,52 @@ list of forms and their permissions + + + ganjoor user public profile + + + + + Id + + + + + First Name + + + Hamid Reza + + + + + Sure Name + + + Mohammadi + + + + + user image + + + + + nick name + + + + + biography + + + + + web site + + Bookmark Type diff --git a/RSecurityBackend/Controllers/AppUserControllerBase.cs b/RSecurityBackend/Controllers/AppUserControllerBase.cs index 4d3bb9b4..ee6d0762 100644 --- a/RSecurityBackend/Controllers/AppUserControllerBase.cs +++ b/RSecurityBackend/Controllers/AppUserControllerBase.cs @@ -254,44 +254,6 @@ namespace RSecurityBackend.Controllers return Ok(userInfo.Result); } - /// - /// Get user public profile - /// - /// - /// - [HttpGet("profile/{id}")] - [AllowAnonymous] - [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(RUserPublicProfile))] - [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] - [ProducesResponseType((int)HttpStatusCode.NotFound)] - [ProducesResponseType((int)HttpStatusCode.Forbidden)] - public async Task GetUserPublicProfile(Guid id) - { - RServiceResult userInfo = await _appUserService.GetUserInformation(id); - if (userInfo.Result == null) - { - if (string.IsNullOrEmpty(userInfo.ExceptionString)) - return NotFound(); - return BadRequest(userInfo.ExceptionString); - } - return Ok - ( - new RUserPublicProfile() - { - Id = id, - FirstName = userInfo.Result.FirstName, - SureName = userInfo.Result.SureName, - NickName = userInfo.Result.NickName, - Bio = userInfo.Result.Bio, - Website = userInfo.Result.Website, - RImageId = userInfo.Result.RImageId - } - ); - } - - - - /// /// add a new user (if you are trying to add an admin user you yourself should be admin) /// diff --git a/RSecurityBackend/RSecurityBackend.xml b/RSecurityBackend/RSecurityBackend.xml index c23fef5e..b3c4cb71 100644 --- a/RSecurityBackend/RSecurityBackend.xml +++ b/RSecurityBackend/RSecurityBackend.xml @@ -116,13 +116,6 @@ user id user information - - - Get user public profile - - - - add a new user (if you are trying to add an admin user you yourself should be admin) @@ -1400,52 +1393,6 @@ Test!123 - - - user public profile - - - - - Id - - - - - First Name - - - Hamid Reza - - - - - Sure Name - - - Mohammadi - - - - - user image - - - - - nick name - - - - - biography - - - - - web site - - set password model diff --git a/RSecurityBackend/Services/Implementation/AppUserService.cs b/RSecurityBackend/Services/Implementation/AppUserService.cs index b129fc38..ab63416c 100644 --- a/RSecurityBackend/Services/Implementation/AppUserService.cs +++ b/RSecurityBackend/Services/Implementation/AppUserService.cs @@ -342,6 +342,8 @@ namespace RSecurityBackend.Services.Implementation { RAppUser appUser = await _userManager.Users.Where(u => u.Id == userId).SingleOrDefaultAsync(); + if (appUser == null) + return new RServiceResult(null); return new RServiceResult( new PublicRAppUser() {