#99 user public profile api

This commit is contained in:
Hamid Reza Mohammadi 2021-03-23 16:17:47 +04:30
parent ef9ebde91f
commit e1cb37487e
3 changed files with 142 additions and 0 deletions

View File

@ -254,6 +254,43 @@ namespace RSecurityBackend.Controllers
return Ok(userInfo.Result);
}
/// <summary>
/// Get user public profile
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[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<IActionResult> GetUserPublicProfile(Guid id)
{
RServiceResult<PublicRAppUser> 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
}
);
}
/// <summary>
/// add a new user (if you are trying to add an admin user you yourself should be admin)

View File

@ -0,0 +1,52 @@
using System;
namespace RSecurityBackend.Models.Auth.ViewModels
{
/// <summary>
/// user public profile
/// </summary>
public class RUserPublicProfile
{
/// <summary>
/// Id
/// </summary>
public Guid Id { get; set; }
/// <summary>
/// First Name
/// </summary>
/// <example>
/// Hamid Reza
/// </example>
public string FirstName { get; set; }
/// <summary>
/// Sure Name
/// </summary>
/// <example>
/// Mohammadi
/// </example>
public string SureName { get; set; }
/// <summary>
/// user image
/// </summary>
public Guid? RImageId { get; set; }
/// <summary>
/// nick name
/// </summary>
public string NickName { get; set; }
/// <summary>
/// biography
/// </summary>
public string Bio { get; set; }
/// <summary>
/// web site
/// </summary>
public string Website { get; set; }
}
}

View File

@ -116,6 +116,13 @@
<param name="id">user id</param>
<returns>user information</returns>
</member>
<member name="M:RSecurityBackend.Controllers.AppUserControllerBase.GetUserPublicProfile(System.Guid)">
<summary>
Get user public profile
</summary>
<param name="id"></param>
<returns></returns>
</member>
<member name="M:RSecurityBackend.Controllers.AppUserControllerBase.Post(RSecurityBackend.Models.Auth.ViewModels.RegisterRAppUser)">
<summary>
add a new user (if you are trying to add an admin user you yourself should be admin)
@ -1393,6 +1400,52 @@
Test!123
</example>
</member>
<member name="T:RSecurityBackend.Models.Auth.ViewModels.RUserPublicProfile">
<summary>
user public profile
</summary>
</member>
<member name="P:RSecurityBackend.Models.Auth.ViewModels.RUserPublicProfile.Id">
<summary>
Id
</summary>
</member>
<member name="P:RSecurityBackend.Models.Auth.ViewModels.RUserPublicProfile.FirstName">
<summary>
First Name
</summary>
<example>
Hamid Reza
</example>
</member>
<member name="P:RSecurityBackend.Models.Auth.ViewModels.RUserPublicProfile.SureName">
<summary>
Sure Name
</summary>
<example>
Mohammadi
</example>
</member>
<member name="P:RSecurityBackend.Models.Auth.ViewModels.RUserPublicProfile.RImageId">
<summary>
user image
</summary>
</member>
<member name="P:RSecurityBackend.Models.Auth.ViewModels.RUserPublicProfile.NickName">
<summary>
nick name
</summary>
</member>
<member name="P:RSecurityBackend.Models.Auth.ViewModels.RUserPublicProfile.Bio">
<summary>
biography
</summary>
</member>
<member name="P:RSecurityBackend.Models.Auth.ViewModels.RUserPublicProfile.Website">
<summary>
web site
</summary>
</member>
<member name="T:RSecurityBackend.Models.Auth.ViewModels.SetPasswordModel">
<summary>
set password model