Initial ...
This commit is contained in:
+13
@@ -0,0 +1,13 @@
|
||||
#
|
||||
bin
|
||||
obj
|
||||
|
||||
#
|
||||
Db/*
|
||||
!Db/.gitkeep
|
||||
|
||||
#
|
||||
Migrations/*
|
||||
|
||||
#
|
||||
wwwroot/*
|
||||
@@ -0,0 +1,33 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xCommons.Attributes;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Providers;
|
||||
using xIdentityService.Controllers;
|
||||
using xIdentityService.Interfaces;
|
||||
|
||||
namespace xApi.Base
|
||||
{
|
||||
[ApiController]
|
||||
[ApiVersion("1.0")]
|
||||
[RequireXPowered(true)]
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
public abstract class XIBaseV1Controller : XIBaseController
|
||||
{
|
||||
//
|
||||
#region Constructor ...
|
||||
protected XIBaseV1Controller(
|
||||
ILogger<XIBaseV1Controller> logger,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider
|
||||
) : base(
|
||||
logger,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider
|
||||
)
|
||||
{ }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xCommons.Attributes;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Extensions;
|
||||
using xCommons.Providers;
|
||||
using xDataService.Interfaces;
|
||||
using xIdentityService.Controllers;
|
||||
using xIdentityService.Interfaces;
|
||||
using xModels.Base;
|
||||
using xPushService.Base;
|
||||
using xPushService.Constants;
|
||||
|
||||
namespace xApi.Base
|
||||
{
|
||||
[ApiController]
|
||||
[ApiVersion("1.0")]
|
||||
[RequireXPowered(true)]
|
||||
[Route("api/v{version:apiVersion}/entities/[controller]")]
|
||||
public abstract class XIBaseV1EntityController<TEntity, TKey> : XIBaseEntityController<TEntity, TKey>
|
||||
where TEntity : XBaseEntity<TKey>
|
||||
{
|
||||
//
|
||||
#region Constructor ...
|
||||
protected XIBaseV1EntityController(
|
||||
ILogger<XIBaseV1EntityController<TEntity, TKey>> logger,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider,
|
||||
IXBaseRepository<TEntity, TKey> repository
|
||||
) : base(
|
||||
logger,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider,
|
||||
repository
|
||||
)
|
||||
{ }
|
||||
#endregion
|
||||
}
|
||||
|
||||
public abstract class XIBaseV1EntityHubController<TEntity, TKey> : XIBaseV1EntityController<TEntity, TKey>
|
||||
where TEntity : XBaseEntity<TKey>
|
||||
{
|
||||
//
|
||||
#region Props ...
|
||||
public IHubContext<XBaseEntityHub<TEntity, TKey>> Hub { get; }
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Constructor ...
|
||||
protected XIBaseV1EntityHubController(
|
||||
ILogger<XIBaseV1EntityHubController<TEntity, TKey>> logger,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider,
|
||||
IXBaseRepository<TEntity, TKey> repository,
|
||||
IHubContext<XBaseEntityHub<TEntity, TKey>> hub = null
|
||||
) : base(
|
||||
logger,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider,
|
||||
repository
|
||||
)
|
||||
{
|
||||
Hub = hub;
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Hub ...
|
||||
[NonAction]
|
||||
public async Task SendPush(
|
||||
string action,
|
||||
string payLoad
|
||||
)
|
||||
{
|
||||
//
|
||||
var actions = new List<string>
|
||||
{
|
||||
XBaseEntityHubAction.Add.GetStringValue(),
|
||||
XBaseEntityHubAction.Update.GetStringValue(),
|
||||
XBaseEntityHubAction.Delete.GetStringValue(),
|
||||
XBaseEntityHubAction.AddMany.GetStringValue(),
|
||||
XBaseEntityHubAction.DeleteMany.GetStringValue(),
|
||||
XBaseEntityHubAction.UpdateMany.GetStringValue(),
|
||||
XBaseEntityHubAction.AddOrUpdate.GetStringValue(),
|
||||
};
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
var isValid =
|
||||
!Hub.IsNull() &&
|
||||
!action.IsNullOrEmpty() &&
|
||||
!payLoad.IsNullOrEmpty() &&
|
||||
actions.Contains(action);
|
||||
if (!isValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Connection Id ...
|
||||
var connectionId = GetConnectionId();
|
||||
var clients = Hub.Clients.All;
|
||||
if (!connectionId.IsNullOrEmpty())
|
||||
{
|
||||
clients = Hub.Clients.AllExcept(connectionId);
|
||||
}
|
||||
|
||||
//
|
||||
await clients.SendAsync(action, payLoad, connectionId);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Providers;
|
||||
using xIdentityService.Controllers;
|
||||
using xIdentityService.Interfaces;
|
||||
|
||||
namespace xApi.Base
|
||||
{
|
||||
[Route("api/v{version:apiVersion}/services/[controller]")]
|
||||
public abstract class XIBaseV1ProviderController : XIBaseProviderController
|
||||
{
|
||||
//
|
||||
#region Constructor ...
|
||||
protected XIBaseV1ProviderController(
|
||||
ILogger logger,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider
|
||||
) : base(
|
||||
logger,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider
|
||||
)
|
||||
{ }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using xIdentityHelper;
|
||||
using xCommons.Attributes;
|
||||
using xCommons.Extensions;
|
||||
using xIdentityModels.Dtos;
|
||||
|
||||
namespace xApi.Controllers {
|
||||
public partial class AccountController {
|
||||
//
|
||||
#region Admin Actions ...
|
||||
/// <summary>
|
||||
/// Ban Specific Users
|
||||
/// </summary>
|
||||
/// <param name="model">an instance of <see>XUserNameIdRequest</see> which represents user identifier list to Ban</param>
|
||||
/// <returns>a list of banned users identifiers</returns>
|
||||
[RequireXPowered]
|
||||
[HttpPost ("Ban")]
|
||||
[Authorize (Policy = XPolicies.EnabledAdmin)]
|
||||
public async Task<ActionResult<IEnumerable<string>>> Ban (
|
||||
[FromBody] XUserNameIdRequest model
|
||||
) {
|
||||
//
|
||||
// Do Action ...
|
||||
try {
|
||||
//
|
||||
// Validate Args ...
|
||||
await ValidationProvider
|
||||
.GroupValidationBuilder ()
|
||||
.AddNotNull (model)
|
||||
.AddNotZeroChilds (model.Ids)
|
||||
.ValidateGroupAsync ();
|
||||
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse ();
|
||||
var result = await identityProvider
|
||||
.Ban (
|
||||
tokens,
|
||||
model
|
||||
);
|
||||
|
||||
//
|
||||
return Ok (result)
|
||||
.ToDynamicObject ();
|
||||
} catch (Exception ex) {
|
||||
//
|
||||
var exResult = GetExceptionActionResult (ex);
|
||||
return exResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// UnBann Specific Users
|
||||
/// </summary>
|
||||
/// <param name="model">an instance of <see>XUserNameIdRequest</see> which represents user identifier list to Ban</param>
|
||||
/// <returns>a list of unbanned users identifiers</returns>
|
||||
[RequireXPowered]
|
||||
[HttpPost ("UnBan")]
|
||||
[Authorize (Policy = XPolicies.EnabledAdmin)]
|
||||
public async Task<ActionResult<IEnumerable<string>>> UnBan (
|
||||
[FromBody] XUserNameIdRequest model
|
||||
) {
|
||||
//
|
||||
// Do Action ...
|
||||
try {
|
||||
//
|
||||
// Validate Args ...
|
||||
await ValidationProvider
|
||||
.GroupValidationBuilder ()
|
||||
.AddNotNull (model)
|
||||
.AddNotZeroChilds (model.Ids)
|
||||
.ValidateGroupAsync ();
|
||||
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse ();
|
||||
var result = await identityProvider
|
||||
.UnBan (
|
||||
tokens,
|
||||
model
|
||||
);
|
||||
|
||||
//
|
||||
return Ok (result
|
||||
.ToDynamicObject ());
|
||||
} catch (Exception ex) {
|
||||
//
|
||||
var exResult = GetExceptionActionResult (ex);
|
||||
return exResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check Specific User is Banned or not
|
||||
/// </summary>
|
||||
/// <param name="userSelectByParam">specified user's identifier</param>
|
||||
/// <returns>a boolean value which represent user banned or not</returns>
|
||||
[RequireXPowered]
|
||||
[HttpGet ("IsBanned/{userSelectByParam?}")]
|
||||
[Authorize (Policy = XPolicies.EnabledAdmin)]
|
||||
[Authorize (Policy = XPolicies.EnabledAgent)]
|
||||
public async Task<ActionResult<bool>> IsBanned (
|
||||
[FromRoute] string userSelectByParam = null
|
||||
) {
|
||||
//
|
||||
// Do Action ...
|
||||
try {
|
||||
//
|
||||
// Validate Args ...
|
||||
if (userSelectByParam.IsNullOrEmpty ()) {
|
||||
userSelectByParam = User.Identity.Name;
|
||||
}
|
||||
ValidationProvider.NotEmpty (userSelectByParam);
|
||||
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse ();
|
||||
var result = await identityProvider
|
||||
.IsBanned (
|
||||
tokens,
|
||||
userSelectByParam
|
||||
);
|
||||
|
||||
//
|
||||
return Ok (result);
|
||||
} catch (Exception ex) {
|
||||
//
|
||||
var exResult = GetExceptionActionResult (ex);
|
||||
return exResult;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,388 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using IdentityModel.Client;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using xIdentityHelper;
|
||||
using xCommons.Attributes;
|
||||
using xCommons.Extensions;
|
||||
using xExceptions.Constants;
|
||||
using xIdentityModels.Models;
|
||||
using xModels.Dtos;
|
||||
using static xIdentityHelper.XApiScopeHelper;
|
||||
|
||||
namespace xApi.Controllers {
|
||||
public partial class AccountController {
|
||||
//
|
||||
#region Authentication Actions ...
|
||||
/// <summary>
|
||||
/// Retrieve OAuth Discovery Document
|
||||
/// </summary>
|
||||
/// <returns>an instance of <see>DiscoveryDocumentResponse</see></returns>
|
||||
[AllowAnonymous]
|
||||
[RequireXPowered]
|
||||
[HttpGet ("DiscoveryDocument")]
|
||||
public async Task<ActionResult<DiscoveryDocumentResponse>> GetDiscoveryDocument () {
|
||||
//
|
||||
try {
|
||||
//
|
||||
var result = await identityProvider
|
||||
.RequestDiscoveryDocument ();
|
||||
|
||||
//
|
||||
// Ceck Response Result ...
|
||||
if (result.IsError) {
|
||||
XException.InvalidConfiguration.Throw ();
|
||||
}
|
||||
|
||||
//
|
||||
return Ok (result
|
||||
.ToDynamicObject ());
|
||||
} catch (Exception ex) {
|
||||
//
|
||||
var result = GetExceptionActionResult (ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Request AccessToken for Specific XApiScope
|
||||
/// </summary>
|
||||
/// <param name="scope">a member of <see>XApiScope</see></param>
|
||||
/// <returns>an instance of <see>XTokenResponse</see></returns>
|
||||
[AllowAnonymous]
|
||||
[RequireXPowered]
|
||||
[HttpPost ("RequestScopeAccessToken")]
|
||||
public async Task<ActionResult<XTokenResponse>> RequestScopeAccessToken (
|
||||
[FromHeader] XApiScope scope
|
||||
) {
|
||||
//
|
||||
// Do Action ...
|
||||
try {
|
||||
//
|
||||
// Validate Args ...
|
||||
var scopeName = string.Empty;
|
||||
try {
|
||||
scopeName = scope.GetStringValue ();
|
||||
} catch { }
|
||||
ValidationProvider.NotEmpty (scopeName);
|
||||
|
||||
//
|
||||
var result = await identityProvider
|
||||
.RequestScopeAccessToken (scopeName);
|
||||
|
||||
//
|
||||
return Ok (result
|
||||
.ToDynamicObject ());
|
||||
} catch (Exception ex) {
|
||||
//
|
||||
var result = GetExceptionActionResult (ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Authenticate User
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Sample request:
|
||||
///
|
||||
/// {
|
||||
/// "password": "",
|
||||
/// "userSelectBy": "",
|
||||
/// }
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name="model">User Login Required Info, an instance of <see>XLoginRequest</see></param>
|
||||
/// <returns>an instance of <see>XTokenResponse</see></returns>
|
||||
[AllowAnonymous]
|
||||
[RequireXPowered]
|
||||
[HttpPost ("Authenticate")]
|
||||
public async Task<ActionResult<XTokenResponse>> Authenticate (
|
||||
[FromBody] XLoginRequest model
|
||||
) {
|
||||
try {
|
||||
//
|
||||
// Validate Args ...
|
||||
if (!ModelState.IsValid) {
|
||||
XException.InvalidArgs.Throw ();
|
||||
}
|
||||
await ValidationProvider
|
||||
.GroupValidationBuilder ()
|
||||
.AddNotNull (model)
|
||||
.AddNotEmpty (
|
||||
model.UserSelectBy,
|
||||
model.Password
|
||||
)
|
||||
.ValidateGroupAsync ();
|
||||
|
||||
//
|
||||
var result = await identityProvider
|
||||
.Authenticate (model);
|
||||
|
||||
//
|
||||
return Ok (result
|
||||
.ToDynamicObject ());
|
||||
} catch (Exception ex) {
|
||||
//
|
||||
var result = GetExceptionActionResult (ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Authenticate User
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Sample request:
|
||||
///
|
||||
/// {
|
||||
/// "language": "fa-IR"
|
||||
/// "password": "",
|
||||
/// "userSelectBy": "",
|
||||
/// "device": {
|
||||
/// "os":"Mac",
|
||||
/// "browser":"Chrome",
|
||||
/// "osVersion":"mac-os-x-15",
|
||||
/// "userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36",
|
||||
/// "deviceType":3,
|
||||
/// "identifier":"[Mac]-[mac-os-x-15]-[3]-[Chrome]-[Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36]",
|
||||
/// "token":"96f400dd9aa5c57a8cec9d6f4775bad3"
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name="model">User Login Required Info, an instance of <see>XLoginRequest</see></param>
|
||||
/// <returns>an instance of <see>XLoginResponse</see></returns>
|
||||
[AllowAnonymous]
|
||||
[RequireXPowered]
|
||||
[HttpPost ("Login")]
|
||||
public async Task<ActionResult<XLoginResponse>> Login (
|
||||
[FromBody] XLoginRequest model
|
||||
) {
|
||||
try {
|
||||
//
|
||||
// Validate Args ...
|
||||
if (!ModelState.IsValid) {
|
||||
XException.InvalidArgs.Throw ();
|
||||
}
|
||||
await ValidationProvider
|
||||
.GroupValidationBuilder ()
|
||||
.AddNotNull (
|
||||
model,
|
||||
model.Device)
|
||||
.AddNotEmpty (
|
||||
model.Language,
|
||||
model.UserSelectBy,
|
||||
model.Password
|
||||
)
|
||||
.ValidateGroupAsync ();
|
||||
|
||||
//
|
||||
var result = await identityProvider
|
||||
.Login (model);
|
||||
|
||||
//
|
||||
return Ok (result
|
||||
.ToDynamicObject ());
|
||||
} catch (Exception ex) {
|
||||
//
|
||||
var result = GetExceptionActionResult (ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Logout User
|
||||
/// </summary>
|
||||
[RequireXPowered]
|
||||
[HttpPost ("Logout")]
|
||||
[Authorize (Policy = XPolicies.User)]
|
||||
public async Task<ActionResult> Logout () {
|
||||
try {
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse ();
|
||||
await identityProvider
|
||||
.Logout (tokens);
|
||||
|
||||
//
|
||||
return Ok ();
|
||||
} catch (Exception ex) {
|
||||
//
|
||||
var result = GetExceptionActionResult (ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refresh Expired Tokens
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// in addition to AccessToken, you had to pass RefreshToken due to Headers
|
||||
/// </remarks>
|
||||
/// <returns>an instance of <see>XTokenResponse</see></returns>
|
||||
[AllowAnonymous]
|
||||
[RequireXPowered]
|
||||
[HttpPost ("RefreshTokens")]
|
||||
public async Task<ActionResult<XTokenResponse>> RefreshTokens () {
|
||||
//
|
||||
try {
|
||||
//
|
||||
// Retrieve Toke Response ...
|
||||
var model = await RetrieveTokensAsXTokenResponse ();
|
||||
|
||||
//
|
||||
// Validate Args ...
|
||||
ValidationProvider
|
||||
.GroupValidationBuilder ()
|
||||
.AddNotNull (model)
|
||||
.AddNotEmpty (
|
||||
model.AccessToken,
|
||||
model.RefreshToken)
|
||||
.ValidateGroup ();
|
||||
|
||||
//
|
||||
var result = await identityProvider
|
||||
.RefreshTokens (model);
|
||||
|
||||
//
|
||||
return Ok (result
|
||||
.ToDynamicObject ());
|
||||
} catch (Exception ex) {
|
||||
//
|
||||
var result = GetExceptionActionResult (ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate a Revision Checksum
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost ("Validate")]
|
||||
[Authorize (Policy = XPolicies.EnabledUser)]
|
||||
public async Task<ActionResult<bool>> Validate (
|
||||
[FromBody] XValidateRevisionRequest model
|
||||
) {
|
||||
//
|
||||
// Do Action ...
|
||||
try {
|
||||
//
|
||||
// Validate Args ...
|
||||
await ValidationProvider
|
||||
.GroupValidationBuilder ()
|
||||
.AddNotNull (model)
|
||||
.AddNotEmpty (model.Revision)
|
||||
.ValidateGroupAsync ();
|
||||
|
||||
//
|
||||
// Get Request ...
|
||||
var tokens = await RetrieveTokensAsXTokenResponse ();
|
||||
var result = tokens.ValidateRevisionChecksum (
|
||||
model.Revision,
|
||||
identityProvider.RevisionSecretKey
|
||||
);
|
||||
|
||||
//
|
||||
// Return Result
|
||||
return Ok (result);
|
||||
} catch (Exception ex) {
|
||||
//
|
||||
var result = GetExceptionActionResult (ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Password Actions ...
|
||||
/// <summary>
|
||||
/// Change a User's Password ...
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// for this action you have to provide:
|
||||
/// - Lang: client device currently used locale, such as: en-US.
|
||||
/// - Password: user's current active password.
|
||||
/// - NewPassword: user's new password to change.
|
||||
/// - Device: user's client device which is an instance of XDevice.
|
||||
/// - ReturnUrl: client application Login URL.
|
||||
///
|
||||
/// Sample request:
|
||||
///
|
||||
/// {
|
||||
/// "lang": "fa-IR",
|
||||
/// "password": ""
|
||||
/// "newPassword": "",
|
||||
/// "returnUrl": "http://localhost/login",
|
||||
/// "device": {
|
||||
/// "os":"Mac",
|
||||
/// "browser":"Chrome",
|
||||
/// "osVersion":"mac-os-x-15",
|
||||
/// "userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36",
|
||||
/// "deviceType":3,
|
||||
/// "identifier":"[Mac]-[mac-os-x-15]-[3]-[Chrome]-[Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36]",
|
||||
/// "token":"96f400dd9aa5c57a8cec9d6f4775bad3"
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name="model">an instance of <see>XActionRequest</see> class which provider requirement for action</param>
|
||||
/// <returns></returns>
|
||||
[RequireXPowered]
|
||||
[HttpPost ("ChangePassword")]
|
||||
[Authorize (Policy = XPolicies.User)]
|
||||
[Authorize (Policy = XPolicies.EnabledUser)]
|
||||
public async Task<ActionResult> ChangePassword (
|
||||
[FromBody] XActionRequest model
|
||||
) {
|
||||
//
|
||||
// Do Action ...
|
||||
try {
|
||||
//
|
||||
// Validate Args ...
|
||||
if (!ModelState.IsValid) {
|
||||
XException.InvalidArgs.Throw ();
|
||||
}
|
||||
await ValidationProvider
|
||||
.GroupValidationBuilder ()
|
||||
.AddNotNull (
|
||||
model,
|
||||
model.Device
|
||||
)
|
||||
.AddNotEmpty (
|
||||
model.Lang,
|
||||
model.Password,
|
||||
model.NewPassword,
|
||||
model.ReturnUrl
|
||||
)
|
||||
.ValidateGroupAsync ();
|
||||
|
||||
//
|
||||
// Get User Select By ...
|
||||
var userSelectByParam = GetUserSelectByParam (
|
||||
model,
|
||||
forceNotNull : false
|
||||
);
|
||||
if (userSelectByParam.IsNullOrEmpty ()) {
|
||||
userSelectByParam = User.Identity.Name;
|
||||
}
|
||||
ValidationProvider.NotEmpty (userSelectByParam);
|
||||
|
||||
//
|
||||
// Get Request ...
|
||||
var tokens = await RetrieveTokensAsXTokenResponse ();
|
||||
await identityProvider
|
||||
.ChangePassword (tokens, model);
|
||||
|
||||
//
|
||||
return Ok ();
|
||||
} catch (Exception ex) {
|
||||
//
|
||||
var exResult = GetExceptionActionResult (ex);
|
||||
return exResult;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,910 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using xIdentityHelper;
|
||||
using xCommons.Attributes;
|
||||
using xCommons.Extensions;
|
||||
using xIdentityModels.Constants;
|
||||
using xIdentityModels.Dtos;
|
||||
using xIdentityModels.Navigations;
|
||||
using xModels.Dtos;
|
||||
using System.Linq;
|
||||
using xExceptions.Constants;
|
||||
|
||||
namespace xApi.Controllers
|
||||
{
|
||||
public partial class AccountController
|
||||
{
|
||||
//
|
||||
#region Friendship Actions ...
|
||||
/// <summary>
|
||||
/// Follow a User
|
||||
/// </summary>
|
||||
/// <param name="destUser">a user identifier which represent destination user</param>
|
||||
/// <returns>an instance of <see>XFriendshipFollowing</see></returns>
|
||||
[RequireXPowered]
|
||||
[HttpPost("Friendship/{destUser}/Follow")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public async Task<ActionResult<XFriendshipFollowing>> Follow(
|
||||
[FromRoute] string destUser
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
ValidationProvider.NotEmpty(destUser);
|
||||
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider
|
||||
.Follow(
|
||||
tokens,
|
||||
destUser
|
||||
);
|
||||
|
||||
//
|
||||
// Prepare Push Message ...
|
||||
|
||||
//
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var exResult = GetExceptionActionResult(ex);
|
||||
return exResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancel Following Request
|
||||
/// </summary>
|
||||
/// <param name="destUser">a user identifier which represent destination user</param>
|
||||
/// <returns>a boolean value</returns>
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
[HttpPost("Friendship/{destUser}/Cancel")]
|
||||
public async Task<ActionResult<bool>> Cancel(
|
||||
[FromRoute] string destUser
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
ValidationProvider.NotEmpty(destUser);
|
||||
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider
|
||||
.Cancel(
|
||||
tokens,
|
||||
destUser
|
||||
);
|
||||
|
||||
//
|
||||
// Prepare Push Message ...
|
||||
|
||||
//
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var exResult = GetExceptionActionResult(ex);
|
||||
return exResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unfollow a Follower
|
||||
/// </summary>
|
||||
/// <param name="destUser">a user identifier which represent destination user</param>
|
||||
/// <returns></returns>
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
[HttpPost("Friendship/{destUser}/UnFollowFollower")]
|
||||
public async Task<ActionResult> UnFollowFollower(
|
||||
[FromRoute] string destUser
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
ValidationProvider.NotEmpty(destUser);
|
||||
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
await identityProvider
|
||||
.UnFollowFollower(
|
||||
tokens,
|
||||
destUser
|
||||
);
|
||||
|
||||
//
|
||||
// Prepare Push Message ...
|
||||
|
||||
//
|
||||
return Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var exResult = GetExceptionActionResult(ex);
|
||||
return exResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unfollow Following
|
||||
/// </summary>
|
||||
/// <param name="destUser">a user identifier which represent destination user</param>
|
||||
/// <returns></returns>
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
[HttpPost("Friendship/{destUser}/UnFollowFollowing")]
|
||||
public async Task<ActionResult> UnFollowFollowing(
|
||||
[FromRoute] string destUser
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
ValidationProvider.NotEmpty(destUser);
|
||||
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
await identityProvider
|
||||
.UnFollowFollowing(
|
||||
tokens,
|
||||
destUser
|
||||
);
|
||||
|
||||
//
|
||||
// Prepare Push Message ...
|
||||
|
||||
//
|
||||
return Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var exResult = GetExceptionActionResult(ex);
|
||||
return exResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Block a Follower
|
||||
/// </summary>
|
||||
/// <param name="destUser">a user identifier which represent destination user</param>
|
||||
/// <returns>an instance of <see>XFriendshipFollowing</see></returns>
|
||||
[HttpPost("Friendship/{destUser}/Block")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public async Task<ActionResult<XFriendshipFollowing>> Block(
|
||||
[FromRoute] string destUser
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
ValidationProvider.NotEmpty(destUser);
|
||||
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider
|
||||
.Block(
|
||||
tokens,
|
||||
destUser
|
||||
);
|
||||
|
||||
//
|
||||
// Prepare Push Message ...
|
||||
|
||||
//
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var exResult = GetExceptionActionResult(ex);
|
||||
|
||||
//
|
||||
return exResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unblock a Blocked User
|
||||
/// </summary>
|
||||
/// <param name="destUser">a user identifier which represent destination user</param>
|
||||
/// <returns>an instance of <see>XFriendshipFollowing</see></returns>
|
||||
[HttpPost("Friendship/{destUser}/UnBlock")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public async Task<ActionResult<XFriendshipFollowing>> UnBlock(
|
||||
[FromRoute] string destUser
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
ValidationProvider.NotEmpty(destUser);
|
||||
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider
|
||||
.UnBlock(
|
||||
tokens,
|
||||
destUser
|
||||
);
|
||||
|
||||
//
|
||||
// Prepare Push Message ...
|
||||
|
||||
//
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var exResult = GetExceptionActionResult(ex);
|
||||
return exResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Accept a Following Request
|
||||
/// </summary>
|
||||
/// <param name="destUser">a user identifier which represent destination user</param>
|
||||
/// <returns>an instance of <see>XFriendshipFollower</see></returns>
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
[HttpPost("Friendship/{destUser}/AcceptRequest")]
|
||||
public async Task<ActionResult<XFriendshipFollower>> AcceptRequest(
|
||||
[FromRoute] string destUser
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
ValidationProvider.NotEmpty(destUser);
|
||||
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider
|
||||
.AcceptRequest(
|
||||
tokens,
|
||||
destUser
|
||||
);
|
||||
|
||||
//
|
||||
// Prepare Push Message ...
|
||||
|
||||
//
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var exResult = GetExceptionActionResult(ex);
|
||||
return exResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reject a Following Request
|
||||
/// </summary>
|
||||
/// <param name="destUser">a user identifier which represent destination user</param>
|
||||
/// <returns>an instance of <see>XFriendshipFollower</see></returns>
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
[HttpPost("Friendship/{destUser}/RejectRequest")]
|
||||
public async Task<ActionResult<XFriendshipFollower>> RejectRequest(
|
||||
[FromRoute] string destUser
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
ValidationProvider.NotEmpty(destUser);
|
||||
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider
|
||||
.RejectRequest(
|
||||
tokens,
|
||||
destUser
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var exResult = GetExceptionActionResult(ex);
|
||||
return exResult;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Friendship Getters ...
|
||||
|
||||
/// <summary>
|
||||
/// Get Friendship Info Model between Specific User and Current User
|
||||
/// </summary>
|
||||
/// <param name="destUser">a user identifier which represent destination user</param>
|
||||
/// <returns>an instance of <see>XFriendshipInfoDto</see></returns>
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
[HttpGet("Friendship/{destUser}/FriendshipInfo")]
|
||||
public async Task<ActionResult<XFriendshipInfoDto>> FriendshipInfo(
|
||||
[FromRoute] string destUser
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
ValidationProvider.NotEmpty(destUser);
|
||||
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider
|
||||
.GetFriendshipInfo(
|
||||
tokens,
|
||||
destUser
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var exResult = GetExceptionActionResult(ex);
|
||||
return exResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check a User IsFollower of Requested User
|
||||
/// </summary>
|
||||
/// <param name="destUser">a user identifier which represent destination user</param>
|
||||
/// <returns>a boolean value</returns>
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
[HttpGet("Friendship/{destUser}/IsFollower")]
|
||||
public async Task<ActionResult<bool>> IsFollower(
|
||||
[FromRoute] string destUser
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
ValidationProvider.NotEmpty(destUser);
|
||||
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider
|
||||
.IsFollower(
|
||||
tokens,
|
||||
destUser
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var exResult = GetExceptionActionResult(ex);
|
||||
return exResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Follower State of a User
|
||||
/// </summary>
|
||||
/// <param name="destUser">a user identifier which represent destination user</param>
|
||||
/// <returns>an instance of <see>XFriendshipState</see></returns>
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
[HttpGet("Friendship/{destUser}/FollowerState")]
|
||||
public async Task<ActionResult<XFriendshipState>> FollowerState(
|
||||
[FromRoute] string destUser
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
ValidationProvider.NotEmpty(destUser);
|
||||
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider
|
||||
.GetFollowerState(
|
||||
tokens,
|
||||
destUser
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var exResult = GetExceptionActionResult(ex);
|
||||
return exResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Specific Follower
|
||||
/// </summary>
|
||||
/// <param name="destUser">a user identifier which represent destination user</param>
|
||||
/// <returns>an instance of <see>XFriendshipFollower</see></returns>
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
[HttpGet("Friendship/{destUser}/Follower")]
|
||||
public async Task<ActionResult<XFriendshipFollower>> Follower(
|
||||
[FromRoute] string destUser
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
ValidationProvider.NotEmpty(destUser);
|
||||
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider
|
||||
.GetFollower(
|
||||
tokens,
|
||||
destUser
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var exResult = GetExceptionActionResult(ex);
|
||||
return exResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Followers List Of Current User
|
||||
/// </summary>
|
||||
/// <returns>a collection of <see>XFriendshipFollower</see></returns>
|
||||
[HttpGet("Friendship/Followers")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public async Task<ActionResult<IEnumerable<XFriendshipFollower>>> Followers()
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider
|
||||
.GetFollowers(tokens);
|
||||
|
||||
//
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var exResult = GetExceptionActionResult(ex);
|
||||
|
||||
//
|
||||
return exResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get All Followers List Includes Blocked, Requested and etc
|
||||
/// of Current User
|
||||
/// </summary>
|
||||
/// <returns>a collection of <see>XFriendshipFollower</see></returns>
|
||||
[HttpGet("Friendship/AllFollowers")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public async Task<ActionResult<IEnumerable<XFriendshipFollower>>> AllFollowers()
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider
|
||||
.GetAllFollowers(tokens);
|
||||
|
||||
//
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var exResult = GetExceptionActionResult(ex);
|
||||
return exResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get All Followers List Includes Blocked, Requested and etc
|
||||
/// of Current User based On Query Model ...
|
||||
/// </summary>
|
||||
/// <returns>a Query Result of <see>XFriendDto</see></returns>
|
||||
[HttpGet("Friendship/QueryFollowers")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public async Task<ActionResult<XQueryResult<XFriendDto>>> QueryFollowers(
|
||||
[FromQuery] XQuery query,
|
||||
[FromQuery] string destUser
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Normalizing Dest User ...
|
||||
var userInfo = await GetUserInfo();
|
||||
bool isAdmin = userInfo.Roles.Contains(XUserRoles.ADMIN);
|
||||
if (destUser.IsNullOrEmpty())
|
||||
{
|
||||
destUser = userInfo.UserName;
|
||||
}
|
||||
bool isDestUserValid = isAdmin || destUser == userInfo.UserId || destUser == userInfo.Email || destUser == userInfo.PhoneNumber || destUser == userInfo.UserName;
|
||||
if (!isDestUserValid)
|
||||
{
|
||||
XException.NotAllowed.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider
|
||||
.QueryFollowers(
|
||||
query: query,
|
||||
tokens: tokens,
|
||||
destUser: destUser
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var exResult = GetExceptionActionResult(ex);
|
||||
return exResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check a User is in Followings of Current User
|
||||
/// </summary>
|
||||
/// <param name="destUser">a user identifier which represent destination user</param>
|
||||
/// <returns>a boolean value</returns>
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
[HttpGet("Friendship/{destUser}/IsFollowing")]
|
||||
public async Task<ActionResult<bool>> IsFollowing(
|
||||
[FromRoute] string destUser
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
ValidationProvider.NotEmpty(destUser);
|
||||
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider
|
||||
.IsFollowing(
|
||||
tokens,
|
||||
destUser
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var exResult = GetExceptionActionResult(ex);
|
||||
return exResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Following State Relation between Specific User
|
||||
/// and Current User
|
||||
/// </summary>
|
||||
/// <param name="destUser">a user identifier which represent destination user</param>
|
||||
/// <returns>an instance of <see>XFriendshipState</see></returns>
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
[HttpGet("Friendship/{destUser}/FollowingState")]
|
||||
public async Task<ActionResult<XFriendshipState>> FollowingState(
|
||||
[FromRoute] string destUser
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
ValidationProvider.NotEmpty(destUser);
|
||||
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider
|
||||
.GetFollowingState(
|
||||
tokens,
|
||||
destUser
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var exResult = GetExceptionActionResult(ex);
|
||||
return exResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Specific Following Model
|
||||
/// </summary>
|
||||
/// <param name="destUser">a user identifier which represent destination user</param>
|
||||
/// <returns>an instance of <see>XFriendshipFollowing</see></returns>
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
[HttpGet("Friendship/{destUser}/Following")]
|
||||
public async Task<ActionResult<XFriendshipFollowing>> Following(
|
||||
[FromRoute] string destUser
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
ValidationProvider.NotEmpty(destUser);
|
||||
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider
|
||||
.GetFollowing(
|
||||
tokens,
|
||||
destUser
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var exResult = GetExceptionActionResult(ex);
|
||||
return exResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Followings of Current User
|
||||
/// </summary>
|
||||
/// <returns>a collection of <see>XFriendshipFollowing</see></returns>
|
||||
[HttpGet("Friendship/Followings")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public async Task<ActionResult<IEnumerable<XFriendshipFollowing>>> Followings()
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider
|
||||
.GetFollowings(tokens);
|
||||
|
||||
//
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var exResult = GetExceptionActionResult(ex);
|
||||
return exResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get All Following List Includes Blocked, Requested and etc
|
||||
/// of Current User
|
||||
/// </summary>
|
||||
/// <returns>a collection of <see>XFriendshipFollowing</see></returns>
|
||||
[HttpGet("Friendship/AllFollowings")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public async Task<ActionResult<IEnumerable<XFriendshipFollowing>>> AllFollowings()
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider
|
||||
.GetAllFollowings(tokens);
|
||||
|
||||
//
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var exResult = GetExceptionActionResult(ex);
|
||||
return exResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return Following UserName's List of Current User
|
||||
/// </summary>
|
||||
/// <returns>a collection of UserNames</returns>
|
||||
[HttpGet("Friendship/FollowingsList")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public async Task<ActionResult<IEnumerable<string>>> FollowingsList()
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider
|
||||
.GetFollowingList(tokens);
|
||||
|
||||
//
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var exResult = GetExceptionActionResult(ex);
|
||||
return exResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return Followers UserName's List of Current User
|
||||
/// </summary>
|
||||
/// <returns>a collection of UserNames</returns>
|
||||
[HttpGet("Friendship/FollowersList")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public async Task<ActionResult<IEnumerable<string>>> FollowersList()
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider
|
||||
.GetFollowersList(tokens);
|
||||
|
||||
//
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var exResult = GetExceptionActionResult(ex);
|
||||
return exResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get All Followings List Includes Blocked, Requested and etc
|
||||
/// of Current User based On Query Model ...
|
||||
/// </summary>
|
||||
/// <returns>a Query Result of <see>XFriendDto</see></returns>
|
||||
[HttpGet("Friendship/QueryFollowings")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public async Task<ActionResult<XQueryResult<XFriendDto>>> QueryFollowings(
|
||||
[FromQuery] XQuery query,
|
||||
[FromQuery] string destUser
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Normalizing Dest User ...
|
||||
var userInfo = await GetUserInfo();
|
||||
bool isAdmin = userInfo.Roles.Contains(XUserRoles.ADMIN);
|
||||
if (destUser.IsNullOrEmpty())
|
||||
{
|
||||
destUser = userInfo.UserName;
|
||||
}
|
||||
bool isDestUserValid = isAdmin || destUser == userInfo.UserId || destUser == userInfo.Email || destUser == userInfo.PhoneNumber || destUser == userInfo.UserName;
|
||||
if (!isDestUserValid)
|
||||
{
|
||||
XException.NotAllowed.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider
|
||||
.QueryFollowings(
|
||||
query: query,
|
||||
tokens: tokens,
|
||||
destUser: destUser
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var exResult = GetExceptionActionResult(ex);
|
||||
return exResult;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using xCommons.Attributes;
|
||||
using xCommons.Extensions;
|
||||
using xModels.Dtos;
|
||||
|
||||
namespace xApi.Controllers
|
||||
{
|
||||
public partial class AccountController
|
||||
{
|
||||
#region Open Actions ...
|
||||
[AllowAnonymous]
|
||||
[RequireXPowered]
|
||||
[HttpGet("GetUserInfo")]
|
||||
public async Task<ActionResult<string>> GetUserInfo(
|
||||
[FromHeader] string token,
|
||||
[FromQuery] string request
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
await ValidationProvider
|
||||
.GroupValidationBuilder()
|
||||
.AddNotEmpty(token)
|
||||
.AddNotEmpty(request)
|
||||
.ValidateGroupAsync();
|
||||
|
||||
//
|
||||
var result = await identityProvider.GetUserInfo(
|
||||
token: token,
|
||||
request: request
|
||||
);
|
||||
|
||||
//
|
||||
// Return Result
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[RequireXPowered]
|
||||
[HttpGet("GetUserInfoByDevice")]
|
||||
public async Task<ActionResult<string>> GetUserInfoByDevice(
|
||||
[FromQuery] string userSelectByParam,
|
||||
[FromBody] XDeviceDto device
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
await ValidationProvider
|
||||
.GroupValidationBuilder()
|
||||
.AddNotEmpty(userSelectByParam)
|
||||
.AddNotNull(device)
|
||||
.ValidateGroupAsync();
|
||||
|
||||
//
|
||||
var result = await identityProvider.GetUserInfo(
|
||||
userSelectByParam: userSelectByParam,
|
||||
device: device
|
||||
);
|
||||
|
||||
//
|
||||
// Return Result
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,528 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using xIdentityHelper;
|
||||
using xCommons.Attributes;
|
||||
using xCommons.Extensions;
|
||||
using xIdentityModels.Dtos;
|
||||
using xIdentityModels.Models;
|
||||
using xModels.Dtos;
|
||||
|
||||
namespace xApi.Controllers
|
||||
{
|
||||
public partial class AccountController
|
||||
{
|
||||
//
|
||||
#region Retrieve Actions ...
|
||||
/// <summary>
|
||||
/// Retrieve User Names based on UserIds
|
||||
/// </summary>
|
||||
/// <param name="ids">a comma seperated list of UserIds</param>
|
||||
/// <returns>a collection of UserNames</returns>
|
||||
[RequireXPowered]
|
||||
[HttpGet("Profile/{ids}/GetNames")]
|
||||
[Authorize(Policy = XPolicies.User)]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public async Task<ActionResult<IEnumerable<string>>> GetNames(
|
||||
[FromRoute] string ids
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
ValidationProvider.NotEmpty(ids);
|
||||
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider.GetUserNames(
|
||||
tokens,
|
||||
ids
|
||||
);
|
||||
|
||||
//
|
||||
// Return Result
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get user ids and retrieve corresponding user names
|
||||
/// </summary>
|
||||
/// <param name="model">an instance of <see>XUserNameIdRequest</see> which represent required UserIds collection</param>
|
||||
/// <returns>a collection of <see>XUserNameIdResponse</see> instance</returns>
|
||||
[RequireXPowered]
|
||||
[HttpPost("Profile/GetNameIds")]
|
||||
[Authorize(Policy = XPolicies.User)]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public async Task<ActionResult<IEnumerable<XUserNameIdResponse>>> GetNameIds(
|
||||
[FromBody] XUserNameIdRequest model
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
ValidationProvider.NotNull(model);
|
||||
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider.GetUserNameIds(
|
||||
tokens,
|
||||
model
|
||||
);
|
||||
|
||||
//
|
||||
// Return Result
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Profile Object of Specific User
|
||||
/// </summary>
|
||||
/// <param name="userSelectByParam">determine's which user profile must be retrieved</param>
|
||||
/// <returns>an instance of <see>XUserProfileDto</see></returns>
|
||||
[RequireXPowered]
|
||||
[Authorize(Policy = XPolicies.User)]
|
||||
[HttpGet("Profile/{userSelectByParam?}")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public async Task<ActionResult<XUserProfileDto>> GetProfile(
|
||||
[FromRoute] string userSelectByParam = ""
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
if (userSelectByParam.IsNullOrEmpty())
|
||||
{
|
||||
userSelectByParam = User.Identity.Name;
|
||||
}
|
||||
ValidationProvider.NotEmpty(userSelectByParam);
|
||||
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider
|
||||
.GetUserProfile(
|
||||
tokens,
|
||||
userSelectByParam
|
||||
);
|
||||
|
||||
//
|
||||
// Return Result
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Query Users
|
||||
/// for specifiy users role for query user 'role: string' and 'forceRole: boolean' in header
|
||||
/// </summary>
|
||||
/// <param name="query">how to filter results based on <see>XQuery</see> structure</param>
|
||||
/// <param name="role">an string which represent user role</param>
|
||||
/// <param name="forceRole">if it's true the user must has exact role, otherwise top level users also listed</param>
|
||||
/// <returns>an instance of <see>XQueryResult</see> of <see>XUserProfileDto</see></returns>
|
||||
[RequireXPowered]
|
||||
[HttpGet("Profile/Query")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdmin)]
|
||||
[Authorize(Policy = XPolicies.EnabledAgent)]
|
||||
public async Task<ActionResult<XQueryResult<XUserProfileDto>>> QueryProfiles(
|
||||
[FromQuery] XQuery query, [FromHeader] string role, [FromHeader] bool forceRole = false
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = new XQueryResult<XUserProfileDto>();
|
||||
if (role.IsNullOrEmpty())
|
||||
{
|
||||
//
|
||||
result = await identityProvider.QueryUsers(
|
||||
tokens,
|
||||
query
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
result = await identityProvider.QueryInRoleUsers(
|
||||
tokens,
|
||||
role,
|
||||
query,
|
||||
forceRole
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var exception = GetExceptionActionResult(ex);
|
||||
return exception;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Query Specified User's Profile Images
|
||||
/// </summary>
|
||||
/// <param name="userSelectByParam">determine's which user profile must be retrieved</param>
|
||||
/// <param name="query">how to filter results based on <see>XQuery</see> structure</param>
|
||||
/// <returns>an instance of <see>XQueryResult</see> of <see>XProfileImage</see></returns>
|
||||
[RequireXPowered]
|
||||
[Authorize(Policy = XPolicies.User)]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
[Authorize(Policy = XPolicies.EnabledAdmin)]
|
||||
[HttpGet("Profile/Avatars/Query/{userSelectByParam?}")]
|
||||
public async Task<ActionResult<XQueryResult<XProfileImageDto>>> QueryAvatars(
|
||||
[FromQuery] XQuery query, [FromRoute] string userSelectByParam = null
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
if (userSelectByParam.IsNullOrEmpty())
|
||||
{
|
||||
userSelectByParam = User.Identity.Name;
|
||||
}
|
||||
ValidationProvider.NotEmpty(userSelectByParam);
|
||||
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider.QueryAvatars(
|
||||
tokens,
|
||||
userSelectByParam,
|
||||
query
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var exception = GetExceptionActionResult(ex);
|
||||
return exception;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Update Actions ...
|
||||
/// <summary>
|
||||
/// Update User Profile based on <see>XProfileUpdateRequest</see> (FirstName/LastName/DateOfBirth)
|
||||
/// </summary>
|
||||
/// <param name="model">user update info, an instance of <see>XProfileUpdateRequest</see></param>
|
||||
/// <param name="userSelectByParam">determine's which user profile must be retrieved</param>
|
||||
/// <returns>an instance of <see>XUserProfileDto</see></returns>
|
||||
[RequireXPowered]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
[HttpPost("Profile/Update/{userSelectByParam?}")]
|
||||
public async Task<ActionResult<XUserProfileDto>> UpdateProfile(
|
||||
[FromBody] XProfileUpdateRequest model, [FromRoute] string userSelectByParam = null
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
if (userSelectByParam.IsNullOrEmpty())
|
||||
{
|
||||
userSelectByParam = User.Identity.Name;
|
||||
}
|
||||
ValidationProvider.NotEmpty(userSelectByParam);
|
||||
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider.ProfileUpdateAsync(
|
||||
tokens,
|
||||
userSelectByParam,
|
||||
model
|
||||
);
|
||||
|
||||
//
|
||||
// Prepare Push Message ...
|
||||
|
||||
//
|
||||
// Return Result
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update a User Profile based on <see>XProfileUpdateRequest</see> Full
|
||||
/// </summary>
|
||||
/// <param name="model">user update info, an instance of <see>XProfileUpdateRequest</see></param>
|
||||
/// <param name="userSelectByParam">determine's which user profile must be retrieved</param>
|
||||
/// <returns>an instance of <see>XUserProfileDto</see></returns>
|
||||
[RequireXPowered]
|
||||
[HttpPost("Profile/{userSelectByParam?}")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public async Task<ActionResult<XUserProfileDto>> FullUpdateProfile(
|
||||
[FromBody] XProfileUpdateRequest model, [FromRoute] string userSelectByParam = null
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
if (userSelectByParam.IsNullOrEmpty())
|
||||
{
|
||||
userSelectByParam = User.Identity.Name;
|
||||
}
|
||||
ValidationProvider.NotEmpty(userSelectByParam);
|
||||
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider.FullProfileUpdateAsync(
|
||||
tokens,
|
||||
userSelectByParam,
|
||||
model
|
||||
);
|
||||
|
||||
//
|
||||
// Prepare Push Message ...
|
||||
|
||||
//
|
||||
// Return Result
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Avatar Actions ...
|
||||
/// <summary>
|
||||
/// Add a New Profile Image
|
||||
/// </summary>
|
||||
/// <param name="file">an specific File to upload, <see>IFormFile</see></param>
|
||||
/// <returns>an instance of <see>XUserProfileDto</see></returns>
|
||||
[RequireXPowered]
|
||||
[HttpPost("Profile/Avatar")]
|
||||
[RequestSizeLimit(966_367_641)]
|
||||
[Authorize(Policy = XPolicies.User)]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public async Task<ActionResult<XUserProfileDto>> AddAvatar(
|
||||
[FromForm] IFormFile file
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
ValidationProvider.NotNull(file);
|
||||
|
||||
//
|
||||
// Get Request ...
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider
|
||||
.AddAvatar(
|
||||
tokens,
|
||||
file
|
||||
);
|
||||
|
||||
//
|
||||
// Prepare Push Message ...
|
||||
|
||||
//
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var exResult = GetExceptionActionResult(ex);
|
||||
return exResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a New Collection of Profile Images
|
||||
/// </summary>
|
||||
/// <param name="files">a collection of Files to upload, <see>IFormFileCollection</see></param>
|
||||
/// <returns>an instance of <see>XUserProfileDto</see></returns>
|
||||
[RequireXPowered]
|
||||
[HttpPost("Profile/Avatars")]
|
||||
[RequestSizeLimit(966_367_641)]
|
||||
[Authorize(Policy = XPolicies.User)]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public async Task<ActionResult<XUserProfileDto>> AddAvatars(
|
||||
[FromForm] IFormFileCollection files
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
ValidationProvider.NotZeroChilds(files);
|
||||
|
||||
//
|
||||
// Get Request ...
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider.AddAvatars(
|
||||
tokens,
|
||||
files
|
||||
);
|
||||
|
||||
//
|
||||
// Prepare Push Message ...
|
||||
|
||||
//
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var exResult = GetExceptionActionResult(ex);
|
||||
return exResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// set Specified Profile Image as Avatar
|
||||
/// </summary>
|
||||
/// <param name="id">an integer which reperesent AvatarId to set as current Avatar</param>
|
||||
/// <returns>an instance of <see>XUserProfileDto</see></returns>
|
||||
[RequireXPowered]
|
||||
[HttpPost("Profile/Avatars/{id:int}/Set")]
|
||||
[Authorize(Policy = XPolicies.User)]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public async Task<ActionResult<XUserProfileDto>> SetAvatar(
|
||||
[FromRoute] int id
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Get Request ...
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider
|
||||
.SetAvatar(
|
||||
tokens,
|
||||
id
|
||||
);
|
||||
|
||||
//
|
||||
// Prepare Push Message ...
|
||||
|
||||
//
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var exception = GetExceptionActionResult(ex);
|
||||
return exception;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove Profile Images
|
||||
/// </summary>
|
||||
/// <param name="ids">a comma seperated list of avatarIds to remove</param>
|
||||
/// <returns>an instance of <see>XUserProfileDto</see></returns>
|
||||
[RequireXPowered]
|
||||
[Authorize(Policy = XPolicies.User)]
|
||||
[HttpDelete("Profile/Avatars/{ids}")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public async Task<ActionResult<XUserProfileDto>> RemoveAvatars(
|
||||
[FromRoute] string ids
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
ValidationProvider.NotEmpty(ids);
|
||||
|
||||
//
|
||||
// Get Request ...
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider
|
||||
.RemoveAvatars(
|
||||
tokens,
|
||||
ids
|
||||
);
|
||||
|
||||
//
|
||||
// Prepare Push Message ...
|
||||
|
||||
//
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using xCommons.Attributes;
|
||||
using xCommons.Extensions;
|
||||
using xIdentityHelper;
|
||||
using xIdentityModels.Dtos;
|
||||
using xModels.Dtos;
|
||||
|
||||
namespace xApi.Controllers
|
||||
{
|
||||
public partial class AccountController
|
||||
{
|
||||
//
|
||||
#region Actions ...
|
||||
/// <summary>
|
||||
/// Query Open To Search Users Profiles ...
|
||||
/// Query all Users Which their Profiles is Open To Search ...
|
||||
/// </summary>
|
||||
/// <param name="query">how to filter results based on <see>XQuery</see> structure</param>
|
||||
/// <returns>an instance of <see>XQueryResult</see> of <see>XUserProfileDto</see></returns>
|
||||
[RequireXPowered]
|
||||
[HttpGet("OpenToSearch/Query")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public async Task<ActionResult<XQueryResult<XUserProfileDto>>> QueryOpenToSearchProfiles(
|
||||
[FromQuery] XQuery query
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do Action ...
|
||||
try
|
||||
{
|
||||
//
|
||||
var tokens = await RetrieveTokensAsXTokenResponse();
|
||||
var result = await identityProvider.QueryOpenToSearchUsers(
|
||||
tokens,
|
||||
query
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var exception = GetExceptionActionResult(ex);
|
||||
return exception;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xCommons.Attributes;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Providers;
|
||||
using xIdentityService.Controllers;
|
||||
using xIdentityService.Interfaces;
|
||||
|
||||
namespace xApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Handle all Account Related Actions ...
|
||||
/// </summary>
|
||||
[AllowAnonymous]
|
||||
[RequireXPowered(true)]
|
||||
public partial class AccountController : XIBaseController
|
||||
{
|
||||
//
|
||||
#region Props ...
|
||||
private readonly IXIdentityProvider identityProvider;
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Constructor ...
|
||||
public AccountController(
|
||||
ILogger<AccountController> logger,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider
|
||||
) : base(
|
||||
logger,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider
|
||||
)
|
||||
{
|
||||
//
|
||||
this.identityProvider = identityProvider;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Controllers;
|
||||
using xCommons.Providers;
|
||||
|
||||
namespace xApi.Controllers {
|
||||
/// <summary>
|
||||
/// Runing when application start ...
|
||||
/// </summary>
|
||||
[Route ("")]
|
||||
[AllowAnonymous]
|
||||
public class StartupController : XBaseController {
|
||||
|
||||
public StartupController (
|
||||
ILogger<StartupController> logger,
|
||||
XAppConfiguration appConfiguration,
|
||||
XValidationProvider validationProvider
|
||||
) : base (
|
||||
logger,
|
||||
appConfiguration,
|
||||
validationProvider
|
||||
) { }
|
||||
|
||||
/// <summary>
|
||||
/// Show Configured Welcome Message
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet ("")]
|
||||
[AllowAnonymous]
|
||||
public virtual ActionResult<string> Index () {
|
||||
//
|
||||
var controllerName = GetControllerName ();
|
||||
var message = $"{AppConfiguration.WelcomeMessage}";
|
||||
|
||||
//
|
||||
return Ok (message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xCommons.Attributes;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Providers;
|
||||
using xIdentityHelper;
|
||||
using xIdentityService.Controllers;
|
||||
using xIdentityService.Interfaces;
|
||||
|
||||
namespace xApi.Controllers {
|
||||
/// <summary>
|
||||
/// Test all Authentication Policies ...
|
||||
/// </summary>
|
||||
[RequireXPowered (false)]
|
||||
public class TestIdentity : XIBaseController {
|
||||
public TestIdentity (
|
||||
ILogger<TestIdentity> logger,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider
|
||||
) : base (
|
||||
logger,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider
|
||||
) { }
|
||||
|
||||
//
|
||||
#region Test Actions ...
|
||||
/// <summary>
|
||||
/// API Read Scope
|
||||
/// </summary>
|
||||
/// <returns>string message</returns>
|
||||
[HttpGet ("PassReadAccess")]
|
||||
[Authorize (Policy = XPolicies.ReadAccess)]
|
||||
public ActionResult<string> PassReadAccess () {
|
||||
return Ok ("Read Access Passed ...");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// API Write Scope
|
||||
/// </summary>
|
||||
/// <returns>string message</returns>
|
||||
[HttpGet ("PassWriteAccess")]
|
||||
[Authorize (Policy = XPolicies.WriteAccess)]
|
||||
public ActionResult<string> PassWriteAccess () {
|
||||
return Ok ("Write Access Passed ...");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// API Admin Scope
|
||||
/// </summary>
|
||||
/// <returns>string message</returns>
|
||||
[HttpGet ("PassAdminAccess")]
|
||||
[Authorize (Policy = XPolicies.AdminAccess)]
|
||||
public ActionResult<string> PassAdminAccess () {
|
||||
return Ok ("Admin Access Passed ...");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// API Manage Scop
|
||||
/// </summary>
|
||||
/// <returns>string message</returns>
|
||||
[HttpGet ("PassManageAccess")]
|
||||
[Authorize (Policy = XPolicies.ManageAccess)]
|
||||
public ActionResult<string> PassManageAccess () {
|
||||
return Ok ("Manage Access Passed ...");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// a simple Action which returns a List of Authenticated User Claims
|
||||
/// </summary>
|
||||
/// <returns>string message which represent current user's claims</returns>
|
||||
[HttpGet ("HiClaims")]
|
||||
[Authorize (Policy = XPolicies.User)]
|
||||
public ActionResult<string> HiClaims () {
|
||||
//
|
||||
var result = new {
|
||||
name = User.Identity.Name,
|
||||
claims = User.Claims.Select (c => new {
|
||||
c.Type, c.Value
|
||||
})
|
||||
};
|
||||
|
||||
//
|
||||
return Ok (result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// a simple Hello User for Checking Authentication and Policy
|
||||
/// </summary>
|
||||
/// <returns>string message which contains authenticated user name</returns>
|
||||
[HttpGet ("HiUser")]
|
||||
[Authorize (Policy = XPolicies.User)]
|
||||
public ActionResult<string> HiUser () {
|
||||
//
|
||||
var result = $"Hi User: {User.Identity.Name} ...";
|
||||
|
||||
//
|
||||
return Ok (result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// a simple Hello User for Checking Authentication and Policy
|
||||
/// </summary>
|
||||
/// <returns>string message which contains authenticated user name</returns>
|
||||
[HttpGet ("HiEnabledUser")]
|
||||
[Authorize (Policy = XPolicies.EnabledUser)]
|
||||
public ActionResult<string> HiEnabledUser () {
|
||||
//
|
||||
var result = $"Hi User: {User.Identity.Name} is Enabled ...";
|
||||
|
||||
//
|
||||
return Ok (result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// a simple Hello User for Checking Authentication and Policy
|
||||
/// </summary>
|
||||
/// <returns>string message which contains authenticated user name</returns>
|
||||
[HttpGet ("HiAgent")]
|
||||
[Authorize (Policy = XPolicies.Agent)]
|
||||
public ActionResult<string> HiAgent () {
|
||||
//
|
||||
var result = $"Hi Admin: {User.Identity.Name} ...";
|
||||
|
||||
//
|
||||
return Ok (result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// a simple Hello User for Checking Authentication and Policy
|
||||
/// </summary>
|
||||
/// <returns>string message which contains authenticated user name</returns>
|
||||
[HttpGet ("HiEnabledAgent")]
|
||||
[Authorize (Policy = XPolicies.EnabledAgent)]
|
||||
public ActionResult<string> HiEnabledAgent () {
|
||||
//
|
||||
var result = $"Hi Admin: {User.Identity.Name} is Enabled ...";
|
||||
|
||||
//
|
||||
return Ok (result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// a simple Hello User for Checking Authentication and Policy
|
||||
/// </summary>
|
||||
/// <returns>string message which contains authenticated user name</returns>
|
||||
[HttpGet ("HiAdmin")]
|
||||
[Authorize (Policy = XPolicies.Admin)]
|
||||
public ActionResult<string> HiAdmin () {
|
||||
//
|
||||
var result = $"Hi Admin: {User.Identity.Name} ...";
|
||||
|
||||
//
|
||||
return Ok (result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// a simple Hello User for Checking Authentication and Policy
|
||||
/// </summary>
|
||||
/// <returns>string message which contains authenticated user name</returns>
|
||||
[HttpGet ("HiEnabledAdmin")]
|
||||
[Authorize (Policy = XPolicies.EnabledAdmin)]
|
||||
public ActionResult<string> HiEnabledAdmin () {
|
||||
//
|
||||
var result = $"Hi Admin: {User.Identity.Name} is Enabled ...";
|
||||
|
||||
//
|
||||
return Ok (result);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using xCommons.Extensions;
|
||||
using xIdentityHelper;
|
||||
using xServices.TermsConditions.Interfaces;
|
||||
|
||||
namespace xApi.Controllers.V1
|
||||
{
|
||||
/// <summary>
|
||||
/// Implementing Terms and Conditions Action Provider ...
|
||||
/// </summary>
|
||||
public partial class ConfigurationsController : IXTermsConditionsControllerActions
|
||||
{
|
||||
//
|
||||
#region Actions ...
|
||||
/// <summary>
|
||||
/// Retrieved all Exists Languages Terms and Conditions ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Terms/Languages")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public async Task<ActionResult<IEnumerable<string>>> TermsLanguages()
|
||||
{
|
||||
//
|
||||
// Do ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Retrieve User Info ...
|
||||
var userInfo = await GetUserInfo();
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await TermsProvider.TermsLanguages();
|
||||
|
||||
//
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check Has Terms and Conditions based on Specified Language ...
|
||||
/// </summary>
|
||||
/// <param name="language">if null, used Default Language ...</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Terms/{language}/Has")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public async Task<ActionResult<bool>> HasTerms(
|
||||
[FromRoute] string language = null
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Retrieve User Info ...
|
||||
var userInfo = await GetUserInfo();
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await TermsProvider.HasTerms(
|
||||
language: language
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Terms and Conditions for Specified Language ...
|
||||
/// </summary>
|
||||
/// <param name="language">if null, used Default Language ...</param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("Terms/{language}")]
|
||||
public async Task<ActionResult<string>> GetTerms(
|
||||
[FromRoute] string language = null
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Retrieve User Info ...
|
||||
var userInfo = await GetUserInfo();
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await TermsProvider.GetTerms(
|
||||
language: language
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Terms and Conditions for Specified Language ...
|
||||
/// </summary>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="terms"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Terms/{language}")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdmin)]
|
||||
public async Task<ActionResult<string>> AddTerms(
|
||||
[FromRoute] string language,
|
||||
[FromQuery] string terms
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Retrieve User Info ...
|
||||
var userInfo = await GetUserInfo();
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await TermsProvider.AddTerms(
|
||||
terms: terms,
|
||||
language: language,
|
||||
userInfo: userInfo,
|
||||
connectionId: connectionId
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove Terms and Conditions of Specified Language ...
|
||||
/// </summary>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("Terms/{language}")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdmin)]
|
||||
public async Task<ActionResult<bool>> RemoveTerms(
|
||||
[FromRoute] string language
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Retrieve User Info ...
|
||||
var userInfo = await GetUserInfo();
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await TermsProvider.RemoveTerms(
|
||||
language: language,
|
||||
userInfo: userInfo,
|
||||
connectionId: connectionId
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update Terms and Conditions of Specified Language ...
|
||||
/// </summary>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="terms"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("Terms/{language}")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdmin)]
|
||||
public async Task<ActionResult<bool>> UpdateTerms(
|
||||
[FromRoute] string language,
|
||||
[FromQuery] string terms
|
||||
)
|
||||
{
|
||||
//
|
||||
// Do ...
|
||||
try
|
||||
{
|
||||
//
|
||||
// Retrieve User Info ...
|
||||
var userInfo = await GetUserInfo();
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var result = await TermsProvider.UpdateTerms(
|
||||
terms: terms,
|
||||
language: language,
|
||||
userInfo: userInfo,
|
||||
connectionId: connectionId
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xApi.Base;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Providers;
|
||||
using xIdentityService.Interfaces;
|
||||
using xServices.TermsConditions.Interfaces;
|
||||
|
||||
namespace xApi.Controllers.V1
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides all Configuration related Actions such as String resources and Terms and Configurations ...
|
||||
/// </summary>
|
||||
public partial class ConfigurationsController : XIBaseV1Controller
|
||||
{
|
||||
//
|
||||
#region Properties ...
|
||||
public IXTermsComditionsProvider TermsProvider { get; }
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Constructor ...
|
||||
public ConfigurationsController(
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider,
|
||||
IXTermsComditionsProvider termsProvider,
|
||||
ILogger<ConfigurationsController> logger
|
||||
) : base(
|
||||
logger,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider
|
||||
)
|
||||
{
|
||||
//
|
||||
TermsProvider = termsProvider;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,324 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xApi.Base;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Extensions;
|
||||
using xCommons.Providers;
|
||||
using xDataService.Interfaces;
|
||||
using xFileService.Interfaces.Entities;
|
||||
using xFileService.Models.Entities;
|
||||
using xIdentityHelper;
|
||||
using xIdentityService.Interfaces;
|
||||
using xModels.Base;
|
||||
using xModels.Dtos;
|
||||
using xPushService.Base;
|
||||
using xPushService.Constants;
|
||||
|
||||
namespace xApi.Controllers.V1.Entities
|
||||
{
|
||||
public class FilesController : XIBaseV1EntityHubController<XFile, Guid>
|
||||
{
|
||||
//
|
||||
#region Constructor ...
|
||||
public FilesController(
|
||||
ILogger<FilesController> logger,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider,
|
||||
IXFileRepository repository,
|
||||
IHubContext<XBaseEntityHub<XFile, Guid>> hub = null
|
||||
) : base(
|
||||
logger,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider,
|
||||
repository,
|
||||
hub
|
||||
)
|
||||
{ }
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Interface Implementations ...
|
||||
//
|
||||
#region Retrieve ...
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XFile>> Get(
|
||||
[FromRoute] Guid id, [FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool containsDetail = false
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.Get(
|
||||
id: id,
|
||||
containsDetail: containsDetail,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<IEnumerable<XFile>>> GetAll(
|
||||
[FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool containsDetail = false
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.GetAll(
|
||||
containsDetail: containsDetail,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
|
||||
[HttpGet("FindOne/{query}")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XFile>> FindOne(
|
||||
[FromRoute] string query, [FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool containsDetail = false
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.FindOne(
|
||||
query: query,
|
||||
containsDetail: containsDetail,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
|
||||
[HttpGet("FindMany/{query}")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<IEnumerable<XFile>>> FindMany(
|
||||
[FromRoute] string query, [FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool containsDetail = false
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.FindMany(
|
||||
query: query,
|
||||
containsDetail: containsDetail,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
|
||||
[HttpGet("Query")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XQueryResult<XFile>>> Query(
|
||||
[FromQuery] XQuery query, [FromQuery] bool ignoreSoftDeleteds = true
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.Query(
|
||||
query: query,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Add ...
|
||||
[HttpPost]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XFile>> Add(
|
||||
[FromBody] XFile item
|
||||
)
|
||||
{
|
||||
//
|
||||
var entity = await base
|
||||
.Add(item);
|
||||
|
||||
//
|
||||
if (!entity.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.Add.GetStringValue(),
|
||||
payLoad: entity.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return entity;
|
||||
}
|
||||
|
||||
[HttpPost("AddOrUpdate")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XFile>> AddOrUpdate(
|
||||
[FromBody] XFile item
|
||||
)
|
||||
{
|
||||
//
|
||||
var entity = await base
|
||||
.AddOrUpdate(item);
|
||||
|
||||
//
|
||||
if (!entity.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.AddOrUpdate.GetStringValue(),
|
||||
payLoad: entity.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return entity;
|
||||
}
|
||||
|
||||
[HttpPost("AddMany")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult> AddMany(
|
||||
[FromBody] XBaseRangeRequest<XFile> request
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await base
|
||||
.AddMany(request);
|
||||
|
||||
//
|
||||
if (!(result as OkObjectResult).IsNull())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.AddMany.GetStringValue(),
|
||||
payLoad: request.Items.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Update ...
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XFile>> Update(
|
||||
[FromRoute] Guid id, [FromBody] XFile item
|
||||
)
|
||||
{
|
||||
//
|
||||
var entity = await base
|
||||
.Update(
|
||||
id,
|
||||
item
|
||||
);
|
||||
|
||||
//
|
||||
if (!entity.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.Update.GetStringValue(),
|
||||
payLoad: entity.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return entity;
|
||||
}
|
||||
|
||||
[HttpPost("UpdateMany")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<bool>> UpdateMany(
|
||||
[FromBody] XBaseRangeRequest<XFile> request
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await base
|
||||
.UpdateMany(request);
|
||||
|
||||
//
|
||||
var resultObject = (result.Result as OkObjectResult).Value;
|
||||
if (!resultObject.IsNull() && (bool)resultObject)
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.UpdateMany.GetStringValue(),
|
||||
payLoad: request.Items.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Exists ...
|
||||
[HttpGet("{id}/IsExists")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<bool>> IsExists(
|
||||
[FromRoute] Guid id, [FromQuery] bool ignoreSoftDeleteds = true
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.IsExists(
|
||||
id: id,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Remove ...
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XFile>> Remove(
|
||||
[FromRoute] Guid id, bool softDelete = true
|
||||
)
|
||||
{
|
||||
//
|
||||
var entity = await base
|
||||
.Remove(
|
||||
id: id,
|
||||
softDelete: softDelete
|
||||
);
|
||||
|
||||
//
|
||||
if (!entity.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.Delete.GetStringValue(),
|
||||
payLoad: entity.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return entity;
|
||||
}
|
||||
|
||||
[HttpPost("RemoveMany")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult> RemoveMany(
|
||||
[FromBody] XBaseRangeRequest<XFile> request, bool softDelete = true
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await base
|
||||
.RemoveMany(
|
||||
request: request,
|
||||
softDelete: softDelete
|
||||
);
|
||||
|
||||
//
|
||||
if (!(result as OkObjectResult).IsNull())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.DeleteMany.GetStringValue(),
|
||||
payLoad: request.Items.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,326 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xApi.Base;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Extensions;
|
||||
using xCommons.Providers;
|
||||
using xIdentityHelper;
|
||||
using xIdentityService.Interfaces;
|
||||
using xModels.Base;
|
||||
using xModels.Dtos;
|
||||
using xPushService.Base;
|
||||
using xPushService.Constants;
|
||||
using xStringService.Interfaces.Entities;
|
||||
using xStringService.Models.Entities;
|
||||
|
||||
namespace xApi.Controllers.V1.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Simple XString Entity Controller ...
|
||||
/// </summary>
|
||||
public class StringsController : XIBaseV1EntityHubController<XString, int>
|
||||
{
|
||||
//
|
||||
#region Constructor ...
|
||||
public StringsController(
|
||||
ILogger<StringsController> logger,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider,
|
||||
IXStringRepository repository,
|
||||
IHubContext<XBaseEntityHub<XString, int>> hub = null
|
||||
) : base(
|
||||
logger,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider,
|
||||
repository,
|
||||
hub
|
||||
)
|
||||
{ }
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Interface Implementations ...
|
||||
//
|
||||
#region Retrieve ...
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XString>> Get(
|
||||
[FromRoute] int id, [FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool containsDetail = false
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.Get(
|
||||
id: id,
|
||||
containsDetail: containsDetail,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<IEnumerable<XString>>> GetAll(
|
||||
[FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool containsDetail = false
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.GetAll(
|
||||
containsDetail: containsDetail,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
|
||||
[HttpGet("FindOne/{query}")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XString>> FindOne(
|
||||
[FromRoute] string query, [FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool containsDetail = false
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.FindOne(
|
||||
query: query,
|
||||
containsDetail: containsDetail,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
|
||||
[HttpGet("FindMany/{query}")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<IEnumerable<XString>>> FindMany(
|
||||
[FromRoute] string query, [FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool containsDetail = false
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.FindMany(
|
||||
query: query,
|
||||
containsDetail: containsDetail,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
|
||||
[HttpGet("Query")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XQueryResult<XString>>> Query(
|
||||
[FromQuery] XQuery query, [FromQuery] bool ignoreSoftDeleteds = true
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.Query(
|
||||
query: query,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Add ...
|
||||
[HttpPost]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XString>> Add(
|
||||
[FromBody] XString item
|
||||
)
|
||||
{
|
||||
//
|
||||
var entity = await base
|
||||
.Add(item);
|
||||
|
||||
//
|
||||
// Handle Sending Push Notification ...
|
||||
if (!entity.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.Add.GetStringValue(),
|
||||
payLoad: entity.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return entity;
|
||||
}
|
||||
|
||||
[HttpPost("AddOrUpdate")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XString>> AddOrUpdate(
|
||||
[FromBody] XString item
|
||||
)
|
||||
{
|
||||
//
|
||||
var entity = await base
|
||||
.AddOrUpdate(item);
|
||||
|
||||
//
|
||||
// Handle Sending Push Notification ...
|
||||
if (!entity.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.AddOrUpdate.GetStringValue(),
|
||||
payLoad: entity.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return entity;
|
||||
}
|
||||
|
||||
[HttpPost("AddMany")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult> AddMany(
|
||||
[FromBody] XBaseRangeRequest<XString> request
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await base
|
||||
.AddMany(request);
|
||||
|
||||
//
|
||||
if (!(result as OkObjectResult).IsNull())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.AddMany.GetStringValue(),
|
||||
payLoad: request.Items.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Update ...
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XString>> Update(
|
||||
[FromRoute] int id, [FromBody] XString item
|
||||
)
|
||||
{
|
||||
//
|
||||
var entity = await base
|
||||
.Update(
|
||||
id,
|
||||
item
|
||||
);
|
||||
|
||||
//
|
||||
if (!entity.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.Update.GetStringValue(),
|
||||
payLoad: entity.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return entity;
|
||||
}
|
||||
|
||||
[HttpPost("UpdateMany")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<bool>> UpdateMany(
|
||||
[FromBody] XBaseRangeRequest<XString> request
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await base
|
||||
.UpdateMany(request);
|
||||
|
||||
//
|
||||
var resultObject = (result.Result as OkObjectResult).Value;
|
||||
if (!resultObject.IsNull() && (bool)resultObject)
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.UpdateMany.GetStringValue(),
|
||||
payLoad: request.Items.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Exists ...
|
||||
[HttpGet("{id}/IsExists")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<bool>> IsExists(
|
||||
[FromRoute] int id, [FromQuery] bool ignoreSoftDeleteds = true
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.IsExists(
|
||||
id: id,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Remove ...
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XString>> Remove(
|
||||
[FromRoute] int id, bool softDelete = true
|
||||
)
|
||||
{
|
||||
//
|
||||
var entity = await base
|
||||
.Remove(
|
||||
id: id,
|
||||
softDelete: softDelete
|
||||
);
|
||||
|
||||
//
|
||||
if (!entity.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.Delete.GetStringValue(),
|
||||
payLoad: entity.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return entity;
|
||||
}
|
||||
|
||||
[HttpPost("RemoveMany")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult> RemoveMany(
|
||||
[FromBody] XBaseRangeRequest<XString> request, bool softDelete = true
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await base
|
||||
.RemoveMany(
|
||||
request: request,
|
||||
softDelete: softDelete
|
||||
);
|
||||
|
||||
//
|
||||
if (!(result as OkObjectResult).IsNull())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.DeleteMany.GetStringValue(),
|
||||
payLoad: request.Items.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,321 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xApi.Base;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Extensions;
|
||||
using xCommons.Providers;
|
||||
using xIdentityHelper;
|
||||
using xIdentityService.Interfaces;
|
||||
using xModels.Base;
|
||||
using xModels.Dtos;
|
||||
using xPushService.Base;
|
||||
using xPushService.Constants;
|
||||
using xTagService.Interfaces.Entities;
|
||||
using xTagService.Models.Entities;
|
||||
|
||||
namespace xApi.Controllers.V1.Entities
|
||||
{
|
||||
public class TagsController : XIBaseV1EntityHubController<XTag, int>
|
||||
{
|
||||
//
|
||||
#region Constructor ...
|
||||
public TagsController(
|
||||
ILogger<TagsController> logger,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider,
|
||||
IXTagRepository repository,
|
||||
IHubContext<XBaseEntityHub<XTag, int>> hub = null
|
||||
) : base(
|
||||
logger,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider,
|
||||
repository,
|
||||
hub
|
||||
)
|
||||
{ }
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Interface Implementations ...
|
||||
//
|
||||
#region Retrieve ...
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XTag>> Get(
|
||||
[FromRoute] int id, [FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool containsDetail = false
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.Get(
|
||||
id: id,
|
||||
containsDetail: containsDetail,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<IEnumerable<XTag>>> GetAll(
|
||||
[FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool containsDetail = false
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.GetAll(
|
||||
containsDetail: containsDetail,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
|
||||
[HttpGet("FindOne/{query}")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XTag>> FindOne(
|
||||
[FromRoute] string query, [FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool containsDetail = false
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.FindOne(
|
||||
query: query,
|
||||
containsDetail: containsDetail,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
|
||||
[HttpGet("FindMany/{query}")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<IEnumerable<XTag>>> FindMany(
|
||||
[FromRoute] string query, [FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool containsDetail = false
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.FindMany(
|
||||
query: query,
|
||||
containsDetail: containsDetail,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
|
||||
[HttpGet("Query")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XQueryResult<XTag>>> Query(
|
||||
[FromQuery] XQuery query, [FromQuery] bool ignoreSoftDeleteds = true
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.Query(
|
||||
query: query,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Add ...
|
||||
[HttpPost]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XTag>> Add(
|
||||
[FromBody] XTag item
|
||||
)
|
||||
{
|
||||
//
|
||||
var entity = await base
|
||||
.Add(item);
|
||||
|
||||
//
|
||||
if (!entity.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.Add.GetStringValue(),
|
||||
payLoad: entity.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return entity;
|
||||
}
|
||||
|
||||
[HttpPost("AddOrUpdate")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XTag>> AddOrUpdate(
|
||||
[FromBody] XTag item
|
||||
)
|
||||
{
|
||||
//
|
||||
var entity = await base
|
||||
.AddOrUpdate(item);
|
||||
|
||||
//
|
||||
if (!entity.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.AddOrUpdate.GetStringValue(),
|
||||
payLoad: entity.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return entity;
|
||||
}
|
||||
|
||||
[HttpPost("AddMany")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult> AddMany(
|
||||
[FromBody] XBaseRangeRequest<XTag> request
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await base
|
||||
.AddMany(request);
|
||||
|
||||
//
|
||||
if (!(result as OkObjectResult).IsNull())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.AddMany.GetStringValue(),
|
||||
payLoad: request.Items.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Update ...
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XTag>> Update(
|
||||
[FromRoute] int id, [FromBody] XTag item
|
||||
)
|
||||
{
|
||||
//
|
||||
var entity = await base
|
||||
.Update(
|
||||
id,
|
||||
item
|
||||
);
|
||||
|
||||
//
|
||||
if (!entity.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.Update.GetStringValue(),
|
||||
payLoad: entity.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return entity;
|
||||
}
|
||||
|
||||
[HttpPost("UpdateMany")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<bool>> UpdateMany(
|
||||
[FromBody] XBaseRangeRequest<XTag> request
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await base
|
||||
.UpdateMany(request);
|
||||
|
||||
//
|
||||
var resultObject = (result.Result as OkObjectResult).Value;
|
||||
if (!resultObject.IsNull() && (bool)resultObject)
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.UpdateMany.GetStringValue(),
|
||||
payLoad: request.Items.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Exists ...
|
||||
[HttpGet("{id}/IsExists")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<bool>> IsExists(
|
||||
[FromRoute] int id, [FromQuery] bool ignoreSoftDeleteds = true
|
||||
)
|
||||
{
|
||||
return await base
|
||||
.IsExists(
|
||||
id: id,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Remove ...
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XTag>> Remove(
|
||||
[FromRoute] int id, bool softDelete = true
|
||||
)
|
||||
{
|
||||
//
|
||||
var entity = await base
|
||||
.Remove(
|
||||
id: id,
|
||||
softDelete: softDelete
|
||||
);
|
||||
|
||||
//
|
||||
if (!entity.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.Delete.GetStringValue(),
|
||||
payLoad: entity.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return entity;
|
||||
}
|
||||
|
||||
[HttpPost("RemoveMany")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult> RemoveMany(
|
||||
[FromBody] XBaseRangeRequest<XTag> request, bool softDelete = true
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await base
|
||||
.RemoveMany(
|
||||
request: request,
|
||||
softDelete: softDelete
|
||||
);
|
||||
|
||||
//
|
||||
if (!(result as OkObjectResult).IsNull())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.DeleteMany.GetStringValue(),
|
||||
payLoad: request.Items.ToJSON()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,309 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xCommons.Attributes;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Providers;
|
||||
using xFileService.Controllers;
|
||||
using xFileService.Interfaces;
|
||||
using xIdentityHelper;
|
||||
using xIdentityService.Interfaces;
|
||||
using xModels.Dtos;
|
||||
using XFileDto = xFileService.Models.Dtos.XFileDto;
|
||||
|
||||
namespace xApi.Controllers.V1.Services
|
||||
{
|
||||
[ApiController]
|
||||
[ApiVersion("1.0")]
|
||||
[RequireXPowered(true)]
|
||||
[Route("api/v{version:apiVersion}/services/[controller]")]
|
||||
public class FilesController : XFileServiceControllerBase, IXFileServiceControllerActions
|
||||
{
|
||||
//
|
||||
#region Constructor ...
|
||||
public FilesController(
|
||||
ILogger<FilesController> logger,
|
||||
IXFileProvider fileProvider,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider
|
||||
) : base(
|
||||
logger,
|
||||
fileProvider,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider
|
||||
)
|
||||
{ }
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Tools ...
|
||||
/// <summary>
|
||||
/// Stream Specified File ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}/Stream/ById")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult> Stream(
|
||||
[FromRoute] Guid id
|
||||
)
|
||||
{
|
||||
return await base.Stream(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stream Specified File ...
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{name}/Stream/ByName")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult> Stream(
|
||||
[FromRoute] string name
|
||||
)
|
||||
{
|
||||
return await base.Stream(name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Download Specified File ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}/Download/ById")]
|
||||
public override async Task<ActionResult> Download(
|
||||
[FromRoute] Guid id
|
||||
)
|
||||
{
|
||||
return await base.Download(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Download Specified File ...
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{name}/Download/ByName")]
|
||||
public override async Task<ActionResult> Download(
|
||||
[FromRoute] string name
|
||||
)
|
||||
{
|
||||
return await base.Download(name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Upload Files ...
|
||||
/// </summary>
|
||||
/// <param name="files"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("")]
|
||||
[RequestSizeLimit(966_367_641)]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<IEnumerable<XFileDto>>> Upload(
|
||||
[FromForm] IFormFileCollection files
|
||||
)
|
||||
{
|
||||
return await base.Upload(files);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove Specified Files ...
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
/// [HttpDelete("Remove")]
|
||||
[HttpDelete("")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<IEnumerable<Guid>>> Remove(
|
||||
[FromQuery] string ids
|
||||
)
|
||||
{
|
||||
return await base.Remove(ids);
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Model ...
|
||||
/// <summary>
|
||||
/// Get Specified File Model ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XFileDto>> Get(
|
||||
[FromRoute] Guid id
|
||||
)
|
||||
{
|
||||
return await base.Get(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get All Exists File Models ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("All")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<IEnumerable<XFileDto>>> GetAll()
|
||||
{
|
||||
return await base.GetAll();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// retrieve Entities based on XQuery Pagination structure ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Query")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XQueryResult<XFileDto>>> Query(
|
||||
[FromQuery] XQuery query
|
||||
)
|
||||
{
|
||||
return await base.Query(query);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// retrieve Owned Entities based on XQuery Pagination structure ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Query/Owned")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XQueryResult<XFileDto>>> QueryOwned(
|
||||
[FromQuery] XQuery query
|
||||
)
|
||||
{
|
||||
return await base.QueryOwned(query);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// count all exists Entities ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Count")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<int>> Count()
|
||||
{
|
||||
return await base.Count();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check an Entity exists or not ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}/IsExists")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<bool>> IsExists(
|
||||
[FromRoute] Guid id
|
||||
)
|
||||
{
|
||||
return await base.IsExists(id);
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Tags ...
|
||||
/// <summary>
|
||||
/// Attach Tag to Specified Model ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="tag"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("{id}/Tags/Attach")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult> AttachTag(
|
||||
[FromRoute] Guid id,
|
||||
[FromQuery] string tag
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base.AttachTag(
|
||||
id: id,
|
||||
tag: tag
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detach Tag From Specified Model ...
|
||||
/// </summary>
|
||||
/// <param name="tag"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{id}/Tags/Detach")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult> DetachTag(
|
||||
[FromRoute] Guid id,
|
||||
[FromQuery] string tag
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base.DetachTag(
|
||||
id: id,
|
||||
tag: tag
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attach Tags to Specified Model ...
|
||||
/// </summary>
|
||||
/// <param name="tags"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("{id}/Tags/AttachMany")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult> AttachTags(
|
||||
[FromRoute] Guid id,
|
||||
[FromQuery] string tags
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base.AttachTags(
|
||||
id: id,
|
||||
tags: tags
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detach Tags From Specified Model ...
|
||||
/// </summary>
|
||||
/// <param name="tags"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{id}/Tags/DetachMany")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult> DetachTags(
|
||||
[FromRoute] Guid id,
|
||||
[FromQuery] string tags
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base.DetachTags(
|
||||
id: id,
|
||||
tags: tags
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Tags of Specified File ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}/Tags")]
|
||||
public override async Task<ActionResult<IEnumerable<string>>> GetTags(
|
||||
[FromRoute] Guid id
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base.GetTags(id);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,468 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xCommons.Attributes;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Providers;
|
||||
using xIdentityHelper;
|
||||
using xIdentityService.Interfaces;
|
||||
using xModels.Dtos;
|
||||
using xStringService.Controllers;
|
||||
using xStringService.Interfaces;
|
||||
using xStringService.Models.Dtos;
|
||||
|
||||
namespace xApi.Controllers.V1.Services
|
||||
{
|
||||
[ApiController]
|
||||
[ApiVersion("1.0")]
|
||||
[RequireXPowered(true)]
|
||||
[Route("api/v{version:apiVersion}/services/[controller]")]
|
||||
public class StringsController : XStringServiceControllerBase, IXStringServiceControllerActions
|
||||
{
|
||||
//
|
||||
#region Constructor ...
|
||||
public StringsController(
|
||||
ILogger<StringsController> logger,
|
||||
IXStringProvider stringProvider,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider
|
||||
) : base(
|
||||
logger,
|
||||
stringProvider,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider
|
||||
)
|
||||
{ }
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Implementing Actions ...
|
||||
//
|
||||
#region Retrievers ...
|
||||
/// <summary>
|
||||
/// Retrieve all Exists Languages ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("Languages")]
|
||||
public override async Task<ActionResult<IEnumerable<string>>> GetLanguages()
|
||||
{
|
||||
return await base.GetLanguages();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check Specified Resource Exists or not ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("IsResourceExists")]
|
||||
public override async Task<ActionResult<bool>> IsResourceExists(
|
||||
[FromQuery] string resource,
|
||||
[FromQuery] string language = null
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.IsResourceExists(
|
||||
resource: resource,
|
||||
language: language
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Specified Resource ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("")]
|
||||
[AllowAnonymous]
|
||||
public override async Task<ActionResult<XStringDto>> Get(
|
||||
[FromQuery] string resource,
|
||||
[FromQuery] string language = null
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.Get(
|
||||
resource: resource,
|
||||
language: language
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Specified Translation of Specified Resource ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("ResourceValue")]
|
||||
public override async Task<ActionResult<string>> GetResourceValue(
|
||||
[FromQuery] string resource,
|
||||
[FromQuery] string language = null
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.GetResourceValue(
|
||||
resource: resource,
|
||||
language: language
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve an Specified Resource Items ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("Resources")]
|
||||
public override async Task<ActionResult<IEnumerable<XStringDto>>> GetResources(
|
||||
[FromQuery] string resource
|
||||
)
|
||||
{
|
||||
return await base.GetResources(resource);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Specified Resource Items as XResourceDto Presentation ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("AsResource")]
|
||||
public override async Task<ActionResult<XResourceDto>> GetResource(
|
||||
[FromQuery] string resource
|
||||
)
|
||||
{
|
||||
return await base.GetResource(resource);
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Query ...
|
||||
/// <summary>
|
||||
/// Query Resource IDs ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("QueryResourceIds")]
|
||||
public override ActionResult<XQueryResult<string>> QueryResourceIds(
|
||||
[FromQuery] XQuery query
|
||||
)
|
||||
{
|
||||
return base.QueryResourceIds(query);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Query Specified Language Resources ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("QueryLanguageResources")]
|
||||
public override async Task<ActionResult<XQueryResult<XStringDto>>> QueryLanguageResources(
|
||||
[FromQuery] XQuery query,
|
||||
[FromQuery] string language = null //
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.QueryLanguageResources(
|
||||
query: query,
|
||||
language: language
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Query Locale Resources ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("QueryLocaleResources")]
|
||||
public override async Task<ActionResult<XQueryResult<XLocaleResourceDto>>> QueryLocaleResources(
|
||||
[FromQuery] XQuery query,
|
||||
[FromQuery] string language = null //
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.QueryLocaleResources(
|
||||
query: query,
|
||||
language: language
|
||||
);
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Add/Update Actions ...
|
||||
/// <summary>
|
||||
/// Add Specified Resource ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Add")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<bool>> Add(
|
||||
[FromQuery] string resource,
|
||||
[FromQuery] string value,
|
||||
[FromQuery] string language = null
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.Add(
|
||||
value: value,
|
||||
resource: resource,
|
||||
language: language
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update Resource ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("Update")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<bool>> Update(
|
||||
[FromQuery] string resource,
|
||||
[FromQuery] string value,
|
||||
[FromQuery] string language = null
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.Update(
|
||||
value: value,
|
||||
resource: resource,
|
||||
language: language
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Or Update Resource ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("AddOrUpdate")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<bool>> AddOrUpdate(
|
||||
[FromQuery] string resource,
|
||||
[FromQuery] string value,
|
||||
[FromQuery] string language = null
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.AddOrUpdate(
|
||||
value: value,
|
||||
resource: resource,
|
||||
language: language
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Specified Resource ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("AddModel")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XStringDto>> AddEntity(
|
||||
[FromBody] XStringDto item
|
||||
)
|
||||
{
|
||||
return await base.AddEntity(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update Specified Entity ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("UpdateModel")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XStringDto>> UpdateEntity(
|
||||
[FromBody] XStringDto item
|
||||
)
|
||||
{
|
||||
return await base.UpdateEntity(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Or Update Specified Entitiy ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("AddOrUpdateModel")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XStringDto>> AddOrUpdateEntity(
|
||||
[FromBody] XStringDto item
|
||||
)
|
||||
{
|
||||
return await base.AddOrUpdateEntity(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Specified Locale Resource ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="resource"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("AddLocale")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XStringDto>> AddByLocaleResource(
|
||||
[FromBody] XLocaleResourceDto item,
|
||||
[FromQuery] string resource
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.AddByLocaleResource(
|
||||
item: item,
|
||||
resource: resource
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update Specified Locale Resource ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="resource"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("UpdateLocale")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XStringDto>> UpdateByLocaleResource(
|
||||
[FromBody] XLocaleResourceDto item,
|
||||
[FromQuery] string resource
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.UpdateByLocaleResource(
|
||||
item: item,
|
||||
resource: resource
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Or Update Resource By Locale ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="resource"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("AddOrUpdateLocale")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XStringDto>> AddOrUpdateByLocaleResource(
|
||||
[FromBody] XLocaleResourceDto item,
|
||||
[FromQuery] string resource
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.AddOrUpdateByLocaleResource(
|
||||
item: item,
|
||||
resource: resource
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Or Update all XResourceDto(s) Locales ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("AddResource")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<IEnumerable<XStringDto>>> AddByResource(
|
||||
[FromBody] XResourceDto item
|
||||
)
|
||||
{
|
||||
return await base.AddByResource(item);
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Remove Actions ...
|
||||
/// <summary>
|
||||
/// Remove all Specified Language's Resources ...
|
||||
/// </summary>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("RemoveLanguage")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult> RemoveLanguageResources(
|
||||
[FromQuery] string language
|
||||
)
|
||||
{
|
||||
return await base.RemoveLanguageResources(language);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all Specified Resource Ids instances ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("RemoveLocales")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<IEnumerable<XStringDto>>> RemoveResource(
|
||||
[FromQuery] string resource
|
||||
)
|
||||
{
|
||||
return await base.RemoveResource(resource);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove Specified Resource ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("Remove")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<bool>> Remove(
|
||||
[FromQuery] string resource,
|
||||
[FromQuery] string language = null
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.Remove(
|
||||
resource: resource,
|
||||
language: language
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all Resource of Specified XResourceDto ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("RemoveResource")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult> RemoveByResource(
|
||||
[FromBody] XResourceDto item
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base.RemoveByResource(item);
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xCommons.Attributes;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Providers;
|
||||
using xIdentityHelper;
|
||||
using xIdentityService.Interfaces;
|
||||
using xModels.Dtos;
|
||||
using xTagService.Controllers;
|
||||
using xTagService.Interfaces;
|
||||
using xTagService.Models.Dtos;
|
||||
|
||||
namespace xApi.Controllers.V1.Services
|
||||
{
|
||||
[ApiController]
|
||||
[ApiVersion("1.0")]
|
||||
[RequireXPowered(true)]
|
||||
[Route("api/v{version:apiVersion}/services/[controller]")]
|
||||
public class TagsController : XTagServiceControllerBase
|
||||
{
|
||||
//
|
||||
#region Constructor ...
|
||||
public TagsController(
|
||||
ILogger<TagsController> logger,
|
||||
IXTagProvider tagProvider,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider
|
||||
) : base(
|
||||
logger,
|
||||
tagProvider,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider
|
||||
)
|
||||
{ }
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Actions ...
|
||||
/// <summary>
|
||||
/// Add Tag by Providing Dto ...
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XTagDto>> Add(
|
||||
[FromBody] XTagDto model
|
||||
)
|
||||
{
|
||||
return await base.Add(model);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update Specified Tag ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XTagDto>> Update(
|
||||
[FromRoute] int id,
|
||||
[FromBody] XTagDto model
|
||||
)
|
||||
{
|
||||
return await base.Update(id, model);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove Specified Tag by ID ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XTagDto>> Remove(
|
||||
[FromRoute] int id
|
||||
)
|
||||
{
|
||||
return await base.Remove(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Specified Tag Dto by ID ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}")]
|
||||
public override async Task<ActionResult<XTagDto>> Get(
|
||||
[FromRoute] int id
|
||||
)
|
||||
{
|
||||
return await base.Get(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Specified Tag Dto by it's Label ...
|
||||
/// </summary>
|
||||
/// <param name="tag"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("GetTag")]
|
||||
public override async Task<ActionResult<XTagDto>> GetTag(
|
||||
[FromQuery] string tag
|
||||
)
|
||||
{
|
||||
return await base.GetTag(tag);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve All Exists Tags ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("All")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<IEnumerable<XTagDto>>> GetAll()
|
||||
{
|
||||
return await base.GetAll();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Search For Specified Tag by Providing a query on Label ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("FindOne")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XTagDto>> FindOne(
|
||||
[FromQuery] string query
|
||||
)
|
||||
{
|
||||
return await base.FindOne(query);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Search For Specified Tags By Providing Query on Labels ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("FindMany")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<IEnumerable<XTagDto>>> FindMany(
|
||||
[FromQuery] string query
|
||||
)
|
||||
{
|
||||
return await base.FindMany(query);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Tags based on Query Model ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Query")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XQueryResult<XTagDto>>> Query(
|
||||
[FromQuery] XQuery query
|
||||
)
|
||||
{
|
||||
return await base.Query(query);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Count Exists Tags ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Count")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<int>> Count()
|
||||
{
|
||||
return await base.Count();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check Tag Exists by ID ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}/IsExists")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<bool>> IsExists(
|
||||
[FromRoute] int id
|
||||
)
|
||||
{
|
||||
return await base.IsExists(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check Tag Exists by Providing Label ...
|
||||
/// </summary>
|
||||
/// <param name="tag"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("IsTagExists")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<bool>> IsTagExists(
|
||||
[FromQuery] string tag
|
||||
)
|
||||
{
|
||||
return await base.IsTagExists(tag);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using xIdentityHelper;
|
||||
using xCommons.Authorization;
|
||||
using xCommons.Extensions;
|
||||
|
||||
namespace xApi.Extensions {
|
||||
public static class XStartupExtensions {
|
||||
/// <summary>
|
||||
/// Register Authorization Policies
|
||||
/// </summary>
|
||||
/// <param name="services"></param>
|
||||
/// <param name="policies"></param>
|
||||
public static void AddXAuthorization (
|
||||
this IServiceCollection services,
|
||||
IDictionary<string, AuthorizationPolicy> policies = null
|
||||
) {
|
||||
//
|
||||
services.AddAuthorization (options => {
|
||||
//
|
||||
if (!policies.IsNull ()) {
|
||||
//
|
||||
// Fill Policies ...
|
||||
using (var policiesEnumerator = policies.GetEnumerator ()) {
|
||||
while (policiesEnumerator.MoveNext ()) {
|
||||
var policyDescriptor = policiesEnumerator.Current;
|
||||
options.AddPolicy (policyDescriptor.Key, policyDescriptor.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
var xPolicies = XAuthorizationHelper.GetXAuthorizationPolicies ();
|
||||
if (!xPolicies.IsNull ()) {
|
||||
//
|
||||
// Fill Policies ...
|
||||
using (var policiesEnumerator = xPolicies.GetEnumerator ()) {
|
||||
while (policiesEnumerator.MoveNext ()) {
|
||||
var policyDescriptor = policiesEnumerator.Current;
|
||||
options.AddPolicy (policyDescriptor.Key, policyDescriptor.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//
|
||||
services.AddSingleton<IAuthorizationHandler, RequiredRolesHandler> ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use Forward Headers Options for resolving behind a proxy issues ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static void UseXForwardOptions (this IApplicationBuilder source) {
|
||||
//
|
||||
var forwardOptions = new ForwardedHeadersOptions {
|
||||
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto,
|
||||
RequireHeaderSymmetry = false
|
||||
};
|
||||
|
||||
//
|
||||
forwardOptions.KnownNetworks.Clear ();
|
||||
forwardOptions.KnownProxies.Clear ();
|
||||
|
||||
//
|
||||
// ref: https://github.com/aspnet/Docs/issues/2384
|
||||
source.UseForwardedHeaders (forwardOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using xCommons.Extensions;
|
||||
using xIdentityModels.Constants;
|
||||
using xIdentityModels.Models;
|
||||
|
||||
namespace xApi.Extensions {
|
||||
public static class XUserClaimsInfoDtoExtensions {
|
||||
public static string GetUserSelectByParam (
|
||||
this XUserClaimsInfoDto source,
|
||||
XUserSelectBy userSelectBy = XUserSelectBy.Username
|
||||
) {
|
||||
//
|
||||
var result = "";
|
||||
|
||||
//
|
||||
switch (userSelectBy) {
|
||||
//
|
||||
case XUserSelectBy.ID:
|
||||
result = source.UserId;
|
||||
break;
|
||||
|
||||
//
|
||||
case XUserSelectBy.Username:
|
||||
result = source.UserName;
|
||||
break;
|
||||
|
||||
//
|
||||
case XUserSelectBy.Email:
|
||||
result = source.Email;
|
||||
break;
|
||||
|
||||
//
|
||||
case XUserSelectBy.MobileNumber:
|
||||
result = source.PhoneNumber;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
if (result.IsNullOrEmpty ()) {
|
||||
//
|
||||
if (!source.UserId.IsNullOrEmpty ()) {
|
||||
result = source.UserId;
|
||||
} else if (!source.UserName.IsNullOrEmpty ()) {
|
||||
result = source.UserName;
|
||||
} else if (!source.Email.IsNullOrEmpty ()) {
|
||||
result = source.Email;
|
||||
} else if (!source.PhoneNumber.IsNullOrEmpty ()) {
|
||||
result = source.PhoneNumber;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace xApi
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
CreateHostBuilder(args).Build().Run();
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
webBuilder.UseStartup<Startup>();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:34556",
|
||||
"sslPort": 44393
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "startup",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"xApiWithData": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "startup",
|
||||
"applicationUrl": "https://localhost:5001;http://localhost:5000;https://0.0.0.0:5001;",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
# xSaherElmAI.xApi
|
||||
|
||||
a WebAPI Project which contains all Business Logic of xSaherElm AI Project.
|
||||
|
||||
## Maintainer
|
||||
|
||||
Hadi Khazaee asl
|
||||
|
||||
[https://www.saherelm.ir](https://www.saherelm.ir)
|
||||
|
||||
[hadi_khazaee_asl@yahoo.com](mailto:hadi_khazaee_asl@yahoo.com)
|
||||
+276
@@ -0,0 +1,276 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using IdentityModel.AspNetCore.OAuth2Introspection;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using xApi.Extensions;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Extensions;
|
||||
using xDataHelper;
|
||||
using xDataHelper.DbSeeder;
|
||||
using xDataHelper.Helpers;
|
||||
using xDataService.Configuration;
|
||||
using xDataService.Constants;
|
||||
using xDataService.DI;
|
||||
using xDataService.Interfaces;
|
||||
using xFileService.Hubs;
|
||||
using xHttpService.DI;
|
||||
using xIdentityService.DI;
|
||||
using xPushHelper.DI;
|
||||
using xPushService.DI;
|
||||
using xPushService.Helpers;
|
||||
using xServices.DI;
|
||||
using xServices.TermsConditions.Push;
|
||||
using xStringService.Hubs;
|
||||
using xTagService.Hubs;
|
||||
|
||||
namespace xApi
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
//
|
||||
// Register Validation Provider and all XCommons Module Services ...
|
||||
services.AddXCommons();
|
||||
|
||||
//
|
||||
// Register App Configuration ...
|
||||
services.AddXAppConfiguration(Configuration);
|
||||
var appConfiguration = services.GetRegisteredService<XAppConfiguration>();
|
||||
|
||||
//
|
||||
// Register Allowed Origins ...
|
||||
services.AddXCors(appConfiguration.AllowedOrigins);
|
||||
|
||||
//
|
||||
// Register Swagger ...
|
||||
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
||||
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
|
||||
services.AddXSwagger(Configuration, xmlFilePath: xmlPath);
|
||||
|
||||
//
|
||||
// Register HttpService ...
|
||||
services.AddXHttpService(Configuration);
|
||||
|
||||
//
|
||||
// Register Api Versioning ...
|
||||
services.AddApiVersioning(opt =>
|
||||
{
|
||||
//
|
||||
// Set Default Api Version ...
|
||||
opt.DefaultApiVersion = new ApiVersion(1, 0);
|
||||
|
||||
//
|
||||
// Set Routing to Default API Version, if Version unspecified ...
|
||||
opt.AssumeDefaultVersionWhenUnspecified = true;
|
||||
|
||||
//
|
||||
// Report All Available Api Versions on Response ...
|
||||
opt.ReportApiVersions = true;
|
||||
});
|
||||
|
||||
//
|
||||
var lifeTime = ServiceLifetime.Scoped;
|
||||
|
||||
//
|
||||
// OAuthIntrospectin Http Client Handler ...
|
||||
// this is for handling SSLErrors ...
|
||||
services.AddHttpClient(OAuth2IntrospectionDefaults.BackChannelHttpClientName)
|
||||
.ConfigurePrimaryHttpMessageHandler(() =>
|
||||
{
|
||||
return new HttpClientHandler
|
||||
{
|
||||
ServerCertificateCustomValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true
|
||||
};
|
||||
});
|
||||
|
||||
//
|
||||
// Register Authorizations ...
|
||||
services.AddXAuthorization();
|
||||
|
||||
//
|
||||
services.AddControllers()
|
||||
.AddNewtonsoftJson(x =>
|
||||
{
|
||||
x.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
|
||||
x.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
|
||||
});
|
||||
|
||||
//
|
||||
// Register XPushService ...
|
||||
services.AddXPushService(Configuration);
|
||||
services.AddXPushHubProvider(lifeTime);
|
||||
|
||||
//
|
||||
// Register XIdentityService ...
|
||||
services.AddXIdentityService(Configuration, lifeTime);
|
||||
|
||||
//
|
||||
// Register DataService here ...
|
||||
#region Register xDataService ...
|
||||
//
|
||||
// Register IXDataServiceHelper ...
|
||||
services.AddSingleton<IXDataServiceHelper, XDataHelperDataProviderHelper>();
|
||||
|
||||
//
|
||||
// Prepare Db Options Builder based on Provider ...
|
||||
var providerType = Configuration.GetXDbProviderType();
|
||||
switch (providerType)
|
||||
{
|
||||
//
|
||||
case XDbProviders.MySQL:
|
||||
case XDbProviders.SQLite:
|
||||
case XDbProviders.SQLServer:
|
||||
Action<dynamic> optionsBuilder = optionsBuilder = b =>
|
||||
{
|
||||
b.MigrationsAssembly(typeof(Startup).GetTypeInfo().Assembly.GetName().Name);
|
||||
};
|
||||
|
||||
//
|
||||
// Register xDataService on DI ...
|
||||
services.AddXDataService<XDataHelperDbContext, XDataHelperDbSeeder>(
|
||||
Configuration,
|
||||
lifeTime,
|
||||
XDbProviderConfigurations.DEFAULT_CONNECTION_NAME,
|
||||
optionsBuilder
|
||||
);
|
||||
break;
|
||||
|
||||
//
|
||||
case XDbProviders.MongoDB:
|
||||
//
|
||||
// Register xDataService on DI ...
|
||||
services.AddXDataService<XDataHelperDbSeeder>(
|
||||
Configuration,
|
||||
lifeTime,
|
||||
XDbProviderConfigurations.DEFAULT_CONNECTION_NAME
|
||||
);
|
||||
break;
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
// Register GraphQL here ...
|
||||
#region Register xGraphQL ...
|
||||
//
|
||||
services.Configure<IISServerOptions>(options =>
|
||||
{
|
||||
options.AllowSynchronousIO = true;
|
||||
});
|
||||
|
||||
//
|
||||
services.Configure<KestrelServerOptions>(options =>
|
||||
{
|
||||
options.AllowSynchronousIO = true;
|
||||
});
|
||||
|
||||
//
|
||||
// Register XGraphQL Helper ...
|
||||
services.AddSingleton<IXGraphQLHelper, XDataHelperGraphQLHelper>();
|
||||
|
||||
//
|
||||
services.AddXGraphQL(options =>
|
||||
{
|
||||
//
|
||||
options.EnableMetrics = true;
|
||||
options.UnhandledExceptionDelegate = context =>
|
||||
{
|
||||
Console.WriteLine("XGraphQL Error: " + context.OriginalException.Message);
|
||||
};
|
||||
});
|
||||
#endregion
|
||||
|
||||
//
|
||||
// Register Services Module Providers here ...
|
||||
#region Register xServices ...
|
||||
services.AddXServices(
|
||||
lifeTime: lifeTime,
|
||||
configuration: Configuration
|
||||
);
|
||||
#endregion
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
//
|
||||
var withPlayground = false;
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
//
|
||||
withPlayground = true;
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
//
|
||||
// Use Swagger Middleware ...
|
||||
app.UseXSwagger();
|
||||
|
||||
//
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
//
|
||||
// Using Cors ...
|
||||
app.UseXCors();
|
||||
|
||||
//
|
||||
app.UseRouting();
|
||||
|
||||
//
|
||||
// Use xIdentityService ...
|
||||
app.UseXIdentityService();
|
||||
|
||||
//
|
||||
app.UseAuthorization();
|
||||
|
||||
//
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapControllers();
|
||||
});
|
||||
|
||||
//
|
||||
#region XPushService ...
|
||||
//
|
||||
var helper = new XPushServiceHelper();
|
||||
|
||||
//
|
||||
helper.AddHub<XTermsHub>("termsHub");
|
||||
helper.AddHub<XTagEntityHub>("tagEntityHub");
|
||||
helper.AddHub<XFileEntityHub>("fileEntityHub");
|
||||
helper.AddHub<XStringEntityHub>("stringEntityHub");
|
||||
|
||||
//
|
||||
app.UseXPushService(helper);
|
||||
#endregion
|
||||
|
||||
//
|
||||
// Use xDataService Middleware ...
|
||||
app.UseXDataService();
|
||||
|
||||
//
|
||||
// Using Services ...
|
||||
app.UseXServices();
|
||||
|
||||
//
|
||||
// Use xGraphQL Middleware ...
|
||||
app.UseXGraphQL(withPlayground: withPlayground);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"AllowedOrigins": [
|
||||
"http://localhost:4200",
|
||||
"https://localhost:4200",
|
||||
"http://saherelm.ir",
|
||||
"https://saherelm.ir",
|
||||
"http://saherelmhub.ir",
|
||||
"https://saherelmhub.ir",
|
||||
"https://192.168.1.15:4200",
|
||||
"https://192.168.1.110:4200"
|
||||
],
|
||||
"IdentityServiceConfiguration": {
|
||||
"Authority": "https://localhost:4001",
|
||||
"ApiName": "xSaherElmAPI",
|
||||
"ApiSecret": "s@H@1694056",
|
||||
"ClientId": "xSaherElmAPIClient",
|
||||
"ClientSecret": "s@H@1694056",
|
||||
"XPoweredValue": "SaherElmITCenter",
|
||||
"XRevisionSecretKey": "SaherElmITCenter@1694056",
|
||||
"DefaultClientTimeout": -1
|
||||
},
|
||||
"StorageConfiguration": {
|
||||
"Authority": "https://localhost:5001",
|
||||
"IdentityAuthority": "https://localhost:5001",
|
||||
"Storage": "Storage",
|
||||
"Temp": "Temp",
|
||||
"Thumb": "Thumb",
|
||||
"Uploads": "Uploads",
|
||||
"Widgets": "Widgets",
|
||||
"Image": "Image",
|
||||
"Audio": "Audio",
|
||||
"Video": "Video",
|
||||
"Document": "Document",
|
||||
"FilePrefix": "xSaherElm_",
|
||||
"ThumbPrefix": "Thumb_",
|
||||
"ThumbSize": 512,
|
||||
"ThumbQuality": 72,
|
||||
"MaxFileSize": 41943040
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
{
|
||||
"Version": "0.1",
|
||||
"Name": "xApi",
|
||||
"DefaultLanguage": "fa-IR",
|
||||
"XPoweredValue": "SaherElmITCenter",
|
||||
"WelcomeMessage": "Welcome to xSaherElm Project's API",
|
||||
"AllowedOrigins": [
|
||||
"http://saherelm.ir",
|
||||
"https://saherelm.ir"
|
||||
],
|
||||
"SwaggerConfiguration": {
|
||||
"Version": "v1.0",
|
||||
"Title": "xSaherElm API",
|
||||
"Description": "Complete API Documentation",
|
||||
"Contact": {
|
||||
"Name": "Hadi Khazaee Asl",
|
||||
"Email": "hadi_khazaee_asl@yahoo.com",
|
||||
"Url": "https://www.saherelm.ir"
|
||||
}
|
||||
},
|
||||
"XDbProvider": "SQLITE",
|
||||
"ConnectionStrings": {
|
||||
"DataConnection": "Filename=./Db/XApi.db"
|
||||
},
|
||||
"MessageConfiguration": {
|
||||
"MailConfigurations": {
|
||||
"gmail": {
|
||||
"Title": "SaherElm Dashboard",
|
||||
"Host": "smtp.gmail.com",
|
||||
"Port": 587,
|
||||
"EnableSsl": true,
|
||||
"Username": "saherelm@gmail.com",
|
||||
"Password": "vzuz gtrk tndb ctbc"
|
||||
}
|
||||
},
|
||||
"SmsConfigurations": {
|
||||
"yoursms": {
|
||||
"ServiceUrl": "http://sms.yourprovider.ir",
|
||||
"Username": "user",
|
||||
"Password": "psw",
|
||||
"LineNumber": "linenumber",
|
||||
"UserApiKey": "",
|
||||
"SecretKey": ""
|
||||
}
|
||||
}
|
||||
},
|
||||
"MessageResourceTitles": {
|
||||
"Terms": "terms",
|
||||
"Invite": "user_invite_msg",
|
||||
"RegistrationApprove": "registration_approve_msg",
|
||||
"Registered": "registered_msg",
|
||||
"VerificationCode": "verification_code_msg",
|
||||
"ChangePassword": "change_password_msg",
|
||||
"PasswordChanged": "password_changed_msg",
|
||||
"NewDeviceLoggedIn": "new_device_logged_in_msg"
|
||||
},
|
||||
"DataServiceConfiguration": {
|
||||
"EnableTracking": true,
|
||||
"EnableSoftDelete": false,
|
||||
"EnableDetailedErrors": false,
|
||||
"EnableSensitiveDataLogging": true,
|
||||
"PagingConfiguration": {
|
||||
"DefaultPageSize": 20,
|
||||
"MaxAvailablePageSize": 400,
|
||||
"MinAvailablePageSize": 5
|
||||
},
|
||||
"GraphQLBasePath": "/graphs"
|
||||
},
|
||||
"DbSeeder": {
|
||||
"UpdateExists": false,
|
||||
"Strings": [],
|
||||
"Terms": [
|
||||
{
|
||||
"Language": "fa-IR",
|
||||
"ResourceTitle": "terms",
|
||||
"TranslatedValue": "توافقنامه استفاده از خدمات و شرایط و ضوابط عضویت"
|
||||
},
|
||||
{
|
||||
"Language": "en-US",
|
||||
"ResourceTitle": "terms",
|
||||
"TranslatedValue": "Terms and Conditions of Using Yuze Services"
|
||||
}
|
||||
]
|
||||
},
|
||||
"HttpServiceConfiguration": {
|
||||
"DisableSSLCheck": true,
|
||||
"DefaultClientTimeout": -1
|
||||
},
|
||||
"IdentityServiceConfiguration": {
|
||||
"Authority": "https://172.18.0.151",
|
||||
"ApiName": "xSaherElmAPI",
|
||||
"ApiSecret": "s@H@1694056",
|
||||
"ClientId": "xSaherElmAPIClient",
|
||||
"ClientSecret": "s@H@1694056",
|
||||
"XPoweredValue": "SaherElmITCenter",
|
||||
"XRevisionSecretKey": "SaherElmITCenter@1694056",
|
||||
"DefaultClientTimeout": -1
|
||||
},
|
||||
"PushServiceConfiguration": {
|
||||
"BaseRoute": "hubs",
|
||||
"AddSupportMessageProtocol": true
|
||||
},
|
||||
"StorageConfiguration": {
|
||||
"Authority": "https://api.saherelm.ir",
|
||||
"IdentityAuthority": "https://ids.saherelm.ir",
|
||||
"Storage": "Storage",
|
||||
"Temp": "Temp",
|
||||
"Thumb": "Thumb",
|
||||
"Uploads": "Uploads",
|
||||
"Widgets": "Widgets",
|
||||
"Image": "Image",
|
||||
"Audio": "Audio",
|
||||
"Video": "Video",
|
||||
"Document": "Document",
|
||||
"FilePrefix": "xSaherElm_",
|
||||
"ThumbPrefix": "Thumb_",
|
||||
"ThumbSize": 512,
|
||||
"ThumbQuality": 72,
|
||||
"MaxFileSize": 41943040
|
||||
},
|
||||
"ServicesConfiguration": {
|
||||
"SummaryEndsWdith": " ...",
|
||||
"ContentSummaryMaxLength": 255
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="nuget" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
||||
<add key="baget" value="https://nuget.saherelmhub.ir/v3/index.json" protocolVersion="3" />
|
||||
</packageSources>
|
||||
</configuration>
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<!-- Runtime Definition -->
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<PackageId>xSaherElmAI.xApi</PackageId>
|
||||
<Version>1.0.0</Version>
|
||||
<Authors>Hadi Khazaee Asl</Authors>
|
||||
<Company>SaherElm IT Center</Company>
|
||||
<Description>
|
||||
a WebAPI Project which contains all Business Logic of xSaherElm AI Project.
|
||||
</Description>
|
||||
|
||||
<!-- Fix Duplicate TargetFramework Issue -->
|
||||
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Local Dependencies -->
|
||||
|
||||
<!-- Local Projects -->
|
||||
<ItemGroup>
|
||||
<!-- All Modules Has Dependencies in xService -->
|
||||
<ProjectReference Include="..\Modules\xServices\xServices.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Dependencies -->
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.11" />
|
||||
<PackageReference Include="IdentityModel.AspNetCore.OAuth2Introspection" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- For XML Documentation Support -->
|
||||
<PropertyGroup>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Ef Core -->
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.5">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Create Required Folders -->
|
||||
<Target Name="CreateRequiredFolder" AfterTargets="AfterPublish">
|
||||
<MakeDir Directories="$(PublishDir)wwwroot" Condition="!Exists('$(PublishDir)wwwroot')" />
|
||||
</Target>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user