### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\xApi\Program.cs 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(); }); } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\xApi\Startup.cs using System; using System.Collections.Generic; 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.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 xDataService.Models; using xHttpService.DI; using xIdentityService.DI; using xServices.Databases; using xServices.DI; namespace xApi { public class Startup { // public IConfiguration Configuration { get; } private readonly XApiDatabaseDescriptor apiDatabaseDescriptor; public Startup(IConfiguration configuration) { // Configuration = configuration; // // Create an Api Descriptor Class Instance ... apiDatabaseDescriptor = new XApiDatabaseDescriptor(); } 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(); // // 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); // // Add Api V1 Versioning ... services.AddXApiV1Versioning(); // // 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(); }); // // Custom ... // services.Configure(options => { options.AllowSynchronousIO = true; }); // services.Configure(options => { options.AllowSynchronousIO = true; }); // // Register Services ... services.AddXServices( configuration: Configuration, databases: new List { apiDatabaseDescriptor }, lifeTime: ServiceLifetime.Scoped ); } public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { // if (env.IsDevelopment()) { 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(); }); // // Use xDataService Middleware ... app.UseXServices( databases: new List { apiDatabaseDescriptor }, isDevelopmentEnvironment: env.IsDevelopment() ); } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\xApi\Controllers\AccountController.cs 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 { /// /// Handle all Account Related Actions ... /// [AllowAnonymous] [RequireXPowered(true)] public partial class AccountController : XBaseIdentityController { // #region Props ... private readonly IXIdentityProvider identityProvider; #endregion // #region Constructor ... public AccountController( ILogger logger, XAppConfiguration appConfiguration, IXIdentityProvider identityProvider, XValidationProvider validationProvider ) : base( logger, appConfiguration, identityProvider, validationProvider ) { // this.identityProvider = identityProvider; } #endregion } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\xApi\Controllers\StartupController.cs using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using xCommons.Configurations; using xCommons.Controllers; using xCommons.Providers; namespace xApi.Controllers { /// /// Runing when application start ... /// [Route ("")] [AllowAnonymous] public class StartupController : XBaseController { public StartupController ( ILogger logger, XAppConfiguration appConfiguration, XValidationProvider validationProvider ) : base ( logger, appConfiguration, validationProvider ) { } /// /// Show Configured Welcome Message /// /// [HttpGet ("")] [AllowAnonymous] public virtual ActionResult Index () { // var controllerName = GetControllerName (); var message = $"{AppConfiguration.WelcomeMessage}"; // return Ok (message); } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\xApi\Controllers\TestFeaturesController.cs using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using xCategoryService.Interfaces; using xCommons.Configurations; using xCommons.Controllers; using xCommons.Providers; namespace xApi.Controllers { [AllowAnonymous] public class TestFeaturesController : XBaseApiController { private readonly IXSubCategoryTitleResourceProvider subCategoryTitleResourceProvider; public TestFeaturesController( ILogger logger, XAppConfiguration appConfiguration, XValidationProvider validationProvider, IXSubCategoryTitleResourceProvider subCategoryTitleResourceProvider ) : base( logger, appConfiguration, validationProvider ) { this.subCategoryTitleResourceProvider = subCategoryTitleResourceProvider; } [HttpGet] public async Task TestFeature() { // var result = await subCategoryTitleResourceProvider.GetLanguages( identifier: "SSSSAAALLLAAAM" ); // return Ok(result); } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\xApi\Controllers\TestIdentity.cs 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 { /// /// Test all Authentication Policies ... /// [RequireXPowered (false)] public class TestIdentity : XBaseIdentityController { public TestIdentity ( ILogger logger, XAppConfiguration appConfiguration, IXIdentityProvider identityProvider, XValidationProvider validationProvider ) : base ( logger, appConfiguration, identityProvider, validationProvider ) { } // #region Test Actions ... /// /// API Read Scope /// /// string message [HttpGet ("PassReadAccess")] [Authorize (Policy = XPolicies.ReadAccess)] public ActionResult PassReadAccess () { return Ok ("Read Access Passed ..."); } /// /// API Write Scope /// /// string message [HttpGet ("PassWriteAccess")] [Authorize (Policy = XPolicies.WriteAccess)] public ActionResult PassWriteAccess () { return Ok ("Write Access Passed ..."); } /// /// API Admin Scope /// /// string message [HttpGet ("PassAdminAccess")] [Authorize (Policy = XPolicies.AdminAccess)] public ActionResult PassAdminAccess () { return Ok ("Admin Access Passed ..."); } /// /// API Manage Scop /// /// string message [HttpGet ("PassManageAccess")] [Authorize (Policy = XPolicies.ManageAccess)] public ActionResult PassManageAccess () { return Ok ("Manage Access Passed ..."); } /// /// a simple Action which returns a List of Authenticated User Claims /// /// string message which represent current user's claims [HttpGet ("HiClaims")] [Authorize (Policy = XPolicies.User)] public ActionResult HiClaims () { // var result = new { name = User.Identity.Name, claims = User.Claims.Select (c => new { c.Type, c.Value }) }; // return Ok (result); } /// /// a simple Hello User for Checking Authentication and Policy /// /// string message which contains authenticated user name [HttpGet ("HiUser")] [Authorize (Policy = XPolicies.User)] public ActionResult HiUser () { // var result = $"Hi User: {User.Identity.Name} ..."; // return Ok (result); } /// /// a simple Hello User for Checking Authentication and Policy /// /// string message which contains authenticated user name [HttpGet ("HiEnabledUser")] [Authorize (Policy = XPolicies.EnabledUser)] public ActionResult HiEnabledUser () { // var result = $"Hi User: {User.Identity.Name} is Enabled ..."; // return Ok (result); } /// /// a simple Hello User for Checking Authentication and Policy /// /// string message which contains authenticated user name [HttpGet ("HiAgent")] [Authorize (Policy = XPolicies.Agent)] public ActionResult HiAgent () { // var result = $"Hi Agent: {User.Identity.Name} ..."; // return Ok (result); } /// /// a simple Hello User for Checking Authentication and Policy /// /// string message which contains authenticated user name [HttpGet ("HiEnabledAgent")] [Authorize (Policy = XPolicies.EnabledAgent)] public ActionResult HiEnabledAgent () { // var result = $"Hi Agent: {User.Identity.Name} is Enabled ..."; // return Ok (result); } /// /// a simple Hello User for Checking Authentication and Policy /// /// string message which contains authenticated user name [HttpGet ("HiAdmin")] [Authorize (Policy = XPolicies.Admin)] public ActionResult HiAdmin () { // var result = $"Hi Admin: {User.Identity.Name} ..."; // return Ok (result); } /// /// a simple Hello User for Checking Authentication and Policy /// /// string message which contains authenticated user name [HttpGet ("HiEnabledAdmin")] [Authorize (Policy = XPolicies.EnabledAdmin)] public ActionResult HiEnabledAdmin () { // var result = $"Hi Admin: {User.Identity.Name} is Enabled ..."; // return Ok (result); } #endregion } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\xApi\Controllers\Account\AccountController+Admin.cs 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 ... /// /// Ban Specific Users /// /// an instance of XUserNameIdRequest which represents user identifier list to Ban /// a list of banned users identifiers [RequireXPowered] [HttpPost ("Ban")] [Authorize (Policy = XPolicies.EnabledAdmin)] public async Task>> 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; } } /// /// UnBann Specific Users /// /// an instance of XUserNameIdRequest which represents user identifier list to Ban /// a list of unbanned users identifiers [RequireXPowered] [HttpPost ("UnBan")] [Authorize (Policy = XPolicies.EnabledAdmin)] public async Task>> 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; } } /// /// Check Specific User is Banned or not /// /// specified user's identifier /// a boolean value which represent user banned or not [RequireXPowered] [HttpGet ("IsBanned/{userSelectByParam?}")] [Authorize (Policy = XPolicies.EnabledAdmin)] [Authorize (Policy = XPolicies.EnabledAgent)] public async Task> 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 } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\xApi\Controllers\Account\AccountController+Authentication.cs 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 ... /// /// Retrieve OAuth Discovery Document /// /// an instance of DiscoveryDocumentResponse [AllowAnonymous] [RequireXPowered] [HttpGet ("DiscoveryDocument")] public async Task> 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; } } /// /// Request AccessToken for Specific XApiScope /// /// a member of XApiScope /// an instance of XTokenResponse [AllowAnonymous] [RequireXPowered] [HttpPost ("RequestScopeAccessToken")] public async Task> 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; } } /// /// Authenticate User /// /// /// Sample request: /// /// { /// "password": "", /// "userSelectBy": "", /// } /// /// /// User Login Required Info, an instance of XLoginRequest /// an instance of XTokenResponse [AllowAnonymous] [RequireXPowered] [HttpPost ("Authenticate")] public async Task> 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; } } /// /// Authenticate User /// /// /// 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" /// } /// } /// /// /// User Login Required Info, an instance of XLoginRequest /// an instance of XLoginResponse [AllowAnonymous] [RequireXPowered] [HttpPost ("Login")] public async Task> 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; } } /// /// Logout User /// [RequireXPowered] [HttpPost ("Logout")] [Authorize (Policy = XPolicies.User)] public async Task Logout () { try { // var tokens = await RetrieveTokensAsXTokenResponse (); await identityProvider .Logout (tokens); // return Ok (); } catch (Exception ex) { // var result = GetExceptionActionResult (ex); return result; } } /// /// Refresh Expired Tokens /// /// /// in addition to AccessToken, you had to pass RefreshToken due to Headers /// /// an instance of XTokenResponse [AllowAnonymous] [RequireXPowered] [HttpPost ("RefreshTokens")] public async Task> 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; } } /// /// Validate a Revision Checksum /// /// /// [HttpPost ("Validate")] [Authorize (Policy = XPolicies.EnabledUser)] public async Task> 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 ... /// /// Change a User's Password ... /// /// /// 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" /// } /// } /// /// /// an instance of XActionRequest class which provider requirement for action /// [RequireXPowered] [HttpPost ("ChangePassword")] [Authorize (Policy = XPolicies.User)] [Authorize (Policy = XPolicies.EnabledUser)] public async Task 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 } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\xApi\Controllers\Account\AccountController+Friendship.cs 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 ... /// /// Follow a User /// /// a user identifier which represent destination user /// an instance of XFriendshipFollowing [RequireXPowered] [HttpPost("Friendship/{destUser}/Follow")] [Authorize(Policy = XPolicies.EnabledUser)] public async Task> 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; } } /// /// Cancel Following Request /// /// a user identifier which represent destination user /// a boolean value [Authorize(Policy = XPolicies.EnabledUser)] [HttpPost("Friendship/{destUser}/Cancel")] public async Task> 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; } } /// /// Unfollow a Follower /// /// a user identifier which represent destination user /// [Authorize(Policy = XPolicies.EnabledUser)] [HttpPost("Friendship/{destUser}/UnFollowFollower")] public async Task 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; } } /// /// Unfollow Following /// /// a user identifier which represent destination user /// [Authorize(Policy = XPolicies.EnabledUser)] [HttpPost("Friendship/{destUser}/UnFollowFollowing")] public async Task 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; } } /// /// Block a Follower /// /// a user identifier which represent destination user /// an instance of XFriendshipFollowing [HttpPost("Friendship/{destUser}/Block")] [Authorize(Policy = XPolicies.EnabledUser)] public async Task> 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; } } /// /// Unblock a Blocked User /// /// a user identifier which represent destination user /// an instance of XFriendshipFollowing [HttpPost("Friendship/{destUser}/UnBlock")] [Authorize(Policy = XPolicies.EnabledUser)] public async Task> 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; } } /// /// Accept a Following Request /// /// a user identifier which represent destination user /// an instance of XFriendshipFollower [Authorize(Policy = XPolicies.EnabledUser)] [HttpPost("Friendship/{destUser}/AcceptRequest")] public async Task> 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; } } /// /// Reject a Following Request /// /// a user identifier which represent destination user /// an instance of XFriendshipFollower [Authorize(Policy = XPolicies.EnabledUser)] [HttpPost("Friendship/{destUser}/RejectRequest")] public async Task> 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 ... /// /// Get Friendship Info Model between Specific User and Current User /// /// a user identifier which represent destination user /// an instance of XFriendshipInfoDto [Authorize(Policy = XPolicies.EnabledUser)] [HttpGet("Friendship/{destUser}/FriendshipInfo")] public async Task> 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; } } /// /// Check a User IsFollower of Requested User /// /// a user identifier which represent destination user /// a boolean value [Authorize(Policy = XPolicies.EnabledUser)] [HttpGet("Friendship/{destUser}/IsFollower")] public async Task> 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; } } /// /// Get Follower State of a User /// /// a user identifier which represent destination user /// an instance of XFriendshipState [Authorize(Policy = XPolicies.EnabledUser)] [HttpGet("Friendship/{destUser}/FollowerState")] public async Task> 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; } } /// /// Get Specific Follower /// /// a user identifier which represent destination user /// an instance of XFriendshipFollower [Authorize(Policy = XPolicies.EnabledUser)] [HttpGet("Friendship/{destUser}/Follower")] public async Task> 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; } } /// /// Get Followers List Of Current User /// /// a collection of XFriendshipFollower [HttpGet("Friendship/Followers")] [Authorize(Policy = XPolicies.EnabledUser)] public async Task>> 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; } } /// /// Get All Followers List Includes Blocked, Requested and etc /// of Current User /// /// a collection of XFriendshipFollower [HttpGet("Friendship/AllFollowers")] [Authorize(Policy = XPolicies.EnabledUser)] public async Task>> 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; } } /// /// Get All Followers List Includes Blocked, Requested and etc /// of Current User based On Query Model ... /// /// a Query Result of XFriendDto [HttpGet("Friendship/QueryFollowers")] [Authorize(Policy = XPolicies.EnabledUser)] public async Task>> 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; } } /// /// Check a User is in Followings of Current User /// /// a user identifier which represent destination user /// a boolean value [Authorize(Policy = XPolicies.EnabledUser)] [HttpGet("Friendship/{destUser}/IsFollowing")] public async Task> 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; } } /// /// Get Following State Relation between Specific User /// and Current User /// /// a user identifier which represent destination user /// an instance of XFriendshipState [Authorize(Policy = XPolicies.EnabledUser)] [HttpGet("Friendship/{destUser}/FollowingState")] public async Task> 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; } } /// /// Get Specific Following Model /// /// a user identifier which represent destination user /// an instance of XFriendshipFollowing [Authorize(Policy = XPolicies.EnabledUser)] [HttpGet("Friendship/{destUser}/Following")] public async Task> 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; } } /// /// Get Followings of Current User /// /// a collection of XFriendshipFollowing [HttpGet("Friendship/Followings")] [Authorize(Policy = XPolicies.EnabledUser)] public async Task>> 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; } } /// /// Get All Following List Includes Blocked, Requested and etc /// of Current User /// /// a collection of XFriendshipFollowing [HttpGet("Friendship/AllFollowings")] [Authorize(Policy = XPolicies.EnabledUser)] public async Task>> 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; } } /// /// Return Following UserName's List of Current User /// /// a collection of UserNames [HttpGet("Friendship/FollowingsList")] [Authorize(Policy = XPolicies.EnabledUser)] public async Task>> 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; } } /// /// Return Followers UserName's List of Current User /// /// a collection of UserNames [HttpGet("Friendship/FollowersList")] [Authorize(Policy = XPolicies.EnabledUser)] public async Task>> 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; } } /// /// Get All Followings List Includes Blocked, Requested and etc /// of Current User based On Query Model ... /// /// a Query Result of XFriendDto [HttpGet("Friendship/QueryFollowings")] [Authorize(Policy = XPolicies.EnabledUser)] public async Task>> 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 } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\xApi\Controllers\Account\AccountController+Open.cs 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> 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> 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 } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\xApi\Controllers\Account\AccountController+Profile.cs 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 ... /// /// Retrieve User Names based on UserIds /// /// a comma seperated list of UserIds /// a collection of UserNames [RequireXPowered] [HttpGet("Profile/{ids}/GetNames")] [Authorize(Policy = XPolicies.User)] [Authorize(Policy = XPolicies.EnabledUser)] public async Task>> 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; } } /// /// get user ids and retrieve corresponding user names /// /// an instance of XUserNameIdRequest which represent required UserIds collection /// a collection of XUserNameIdResponse instance [RequireXPowered] [HttpPost("Profile/GetNameIds")] [Authorize(Policy = XPolicies.User)] [Authorize(Policy = XPolicies.EnabledUser)] public async Task>> 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; } } /// /// Get Profile Object of Specific User /// /// determine's which user profile must be retrieved /// an instance of XUserProfileDto [RequireXPowered] [Authorize(Policy = XPolicies.User)] [HttpGet("Profile/{userSelectByParam?}")] [Authorize(Policy = XPolicies.EnabledUser)] public async Task> 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; } } /// /// Query Users /// for specifiy users role for query user 'role: string' and 'forceRole: boolean' in header /// /// how to filter results based on XQuery structure /// an string which represent user role /// if it's true the user must has exact role, otherwise top level users also listed /// an instance of XQueryResult of XUserProfileDto [RequireXPowered] [HttpGet("Profile/Query")] [Authorize(Policy = XPolicies.EnabledAdmin)] [Authorize(Policy = XPolicies.EnabledAgent)] public async Task>> QueryProfiles( [FromQuery] XQuery query, [FromHeader] string role, [FromHeader] bool forceRole = false ) { // // Do Action ... try { // var tokens = await RetrieveTokensAsXTokenResponse(); var result = new XQueryResult(); 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; } } /// /// Query Specified User's Profile Images /// /// determine's which user profile must be retrieved /// how to filter results based on XQuery structure /// an instance of XQueryResult of XProfileImage [RequireXPowered] [Authorize(Policy = XPolicies.User)] [Authorize(Policy = XPolicies.EnabledUser)] [Authorize(Policy = XPolicies.EnabledAdmin)] [HttpGet("Profile/Avatars/Query/{userSelectByParam?}")] public async Task>> 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 ... /// /// Update User Profile based on XProfileUpdateRequest (FirstName/LastName/DateOfBirth) /// /// user update info, an instance of XProfileUpdateRequest /// determine's which user profile must be retrieved /// an instance of XUserProfileDto [RequireXPowered] [Authorize(Policy = XPolicies.EnabledUser)] [HttpPost("Profile/Update/{userSelectByParam?}")] public async Task> 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; } } /// /// Update a User Profile based on XProfileUpdateRequest Full /// /// user update info, an instance of XProfileUpdateRequest /// determine's which user profile must be retrieved /// an instance of XUserProfileDto [RequireXPowered] [HttpPost("Profile/{userSelectByParam?}")] [Authorize(Policy = XPolicies.EnabledAdminOrAgent)] public async Task> 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 ... /// /// Add a New Profile Image /// /// an specific File to upload, IFormFile /// an instance of XUserProfileDto [RequireXPowered] [HttpPost("Profile/Avatar")] [RequestSizeLimit(966_367_641)] [Authorize(Policy = XPolicies.User)] [Authorize(Policy = XPolicies.EnabledUser)] public async Task> 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; } } /// /// Add a New Collection of Profile Images /// /// a collection of Files to upload, IFormFileCollection /// an instance of XUserProfileDto [RequireXPowered] [HttpPost("Profile/Avatars")] [RequestSizeLimit(966_367_641)] [Authorize(Policy = XPolicies.User)] [Authorize(Policy = XPolicies.EnabledUser)] public async Task> 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; } } /// /// set Specified Profile Image as Avatar /// /// an integer which reperesent AvatarId to set as current Avatar /// an instance of XUserProfileDto [RequireXPowered] [HttpPost("Profile/Avatars/{id:int}/Set")] [Authorize(Policy = XPolicies.User)] [Authorize(Policy = XPolicies.EnabledUser)] public async Task> 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; } } /// /// Remove Profile Images /// /// a comma seperated list of avatarIds to remove /// an instance of XUserProfileDto [RequireXPowered] [Authorize(Policy = XPolicies.User)] [HttpDelete("Profile/Avatars/{ids}")] [Authorize(Policy = XPolicies.EnabledUser)] public async Task> 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: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\xApi\Controllers\Account\AccountController+Registration.cs 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 xExceptions.Constants; using xIdentityModels.Constants; using xIdentityModels.Extensions; using xIdentityModels.Models; namespace xApi.Controllers { public partial class AccountController { // #region Registration ... /// /// Check a UserName is Available For Registration or not /// /// an string value which represent desired username /// a boolean value [AllowAnonymous] [RequireXPowered] [HttpGet ("CanRegisterUserName/{userName?}")] public async Task> CanRegisterUserName ( [FromRoute] string userName ) { // // Do Action ... try { // // Validate Args ... ValidationProvider.NotEmpty (userName); // // Validate Type ... var type = userName.GetUserSelectByType (); if (type != XUserSelectBy.Username) { XException.InvalidArgs.Throw (); } // var result = await identityProvider .CanRegister (userName); // // Return Result return Ok (result); } catch (Exception ex) { // var result = GetExceptionActionResult (ex); // return result; } } /// /// Check a Mobile Number is Available For Registration or not /// /// an string value which represent desired mobile number /// a boolean value [AllowAnonymous] [RequireXPowered] [HttpGet ("CanRegisterMobileNumber/{mobileNumber?}")] public async Task> CanRegisterMobileNumber ( [FromRoute] string mobileNumber ) { // // Do Action ... try { // // Validate Args ... ValidationProvider.NotEmpty (mobileNumber); // // Validate Type ... var type = mobileNumber.GetUserSelectByType (); if (type != XUserSelectBy.MobileNumber) { XException.InvalidArgs.Throw (); } // var result = await identityProvider .CanRegister (mobileNumber); // // Return Result return Ok (result); } catch (Exception ex) { // var result = GetExceptionActionResult (ex); // return result; } } /// /// Check a Email Address is Available For Registration or not /// /// an string value which represent desired email address /// a boolean value [AllowAnonymous] [RequireXPowered] [HttpGet ("CanRegisterEmail/{email?}")] public async Task> CanRegisterEmail ( [FromRoute] string email ) { // // Do Action ... try { // // Validate Args ... ValidationProvider.NotEmpty (email); // // Validate Type ... var type = email.GetUserSelectByType (); if (type != XUserSelectBy.Email) { XException.InvalidArgs.Throw (); } // var result = await identityProvider .CanRegister (email); // // Return Result return Ok (result); } catch (Exception ex) { // var result = GetExceptionActionResult (ex); // return result; } } /// /// Invite a User to Register on Dashboard /// /// /// for this action you have to provide: /// - Lang: client device currently used locale, such as: en-US. /// - Email: which email address is going to invite. /// - Device: user's client device which is an instance of XDevice. /// - ReturnUrl: client application Registration URL. /// notice in this step you had to provide all this informations as FormData /// /// Sample request: /// /// { /// "lang": "fa-IR", /// "email": "", /// "returnUrl": "", /// "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" /// } /// } /// /// /// an instance of XActionRequest class which provider requirement for action /// an instance of XActionResponse [RequireXPowered] [HttpPost ("InviteUser")] [Authorize (Policy = XPolicies.EnabledAdmin)] [Authorize (Policy = XPolicies.EnabledAgent)] public async Task> InviteUser ( [FromBody] XActionRequest model ) { // // Do Action ... try { // // Validate Args ... if (!ModelState.IsValid) { XException.InvalidArgs.Throw (); } // await ValidationProvider .GroupValidationBuilder () .AddNotEmpty ( model.Lang, model.Email, model.ReturnUrl) .AddEmailAddress (model.Email) .AddNotNull (model.Device) .ValidateGroupAsync (); // // Get Request ... var tokens = await RetrieveTokensAsXTokenResponse (); var result = await identityProvider .InviteUser ( tokens, model ); // return Ok (result .ToDynamicObject ()); } catch (Exception ex) { // var result = GetExceptionActionResult (ex); return result; } } /// /// Recieve some Basic Informations and Start Registration Proccess /// if they Valid /// /// Registration Proccess Starts with Invoking this Action /// /// /// for this action you have to provide: /// - Lang: client device currently used locale, such as: en-US. /// - FirstName: user's FirstName. /// - LastName: user's LastName. /// - DateOfBirth: user's dob date. /// - MobileNumber: user's MobileNumber optional. /// - Email: user's Email optional. /// - ActionToken: user's requested action token for this action (if user invited). /// - Device: user's client device which is an instance of XDevice. /// /// Sample request: /// /// { /// "lang": "fa-IR", /// "firstName": "", /// "lastName": "", /// "dateOfBirth": "", /// "email": "", /// "mobileNumber": "", /// "actionToken": "", /// "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" /// } /// } /// /// /// an instance of XActionRequest class which provider requirement for action /// an instance of XActionResponse [AllowAnonymous] [RequireXPowered] [HttpPost ("RequestRegistration")] public async Task> RequestRegistration ( [FromBody] XActionRequest model ) { // // Do Action ... try { // // Validate Args ... if (!ModelState.IsValid) { XException.InvalidArgs.Throw (); } await ValidationProvider .GroupValidationBuilder () .AddNotEmpty ( model.Lang, model.FirstName, model.LastName) .AddNotNull ( model.Device, model.DateOfBirth) .ValidateGroupAsync (); // // Get Request ... var result = await identityProvider .RequestRegistration ( model ); // return Ok (result .ToDynamicObject ()); } catch (Exception ex) { // var exResult = GetExceptionActionResult (ex); // return exResult; } } /// /// Add User Account Informations /// /// /// for this action you have to provide: /// - Lang: client device currently used locale, such as: en-US. /// - ActionToken: user's requested action token for this action. /// - UserName: user name. /// - Password: assigne password. /// - Device: user's client device which is an instance of XDevice. /// /// Sample request: /// /// { /// "lang": "fa-IR", /// "userName": "", /// "password": "", /// "actionToken": "", /// "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" /// } /// } /// /// /// an instance of XActionRequest class which provider requirement for action /// an instance of XActionResponse [AllowAnonymous] [RequireXPowered] [HttpPost ("AddAccountInfo")] public async Task> AddAccountInfo ( [FromBody] XActionRequest model ) { // // Do Action ... try { // // Validate Args ... if (!ModelState.IsValid) { XException.InvalidArgs.Throw (); } await ValidationProvider .GroupValidationBuilder () .AddNotEmpty ( model.Lang, model.ActionToken, model.UserName, model.Password) .AddNotNull (model.Device) .ValidateGroupAsync (); // // Get Request ... var result = await identityProvider .AddAccountInfo ( model ); // return Ok (result .ToDynamicObject ()); } catch (Exception ex) { // var exResult = GetExceptionActionResult (ex); return exResult; } } /// /// Upload and Attach a Profile Image for User. this is an Optional Step /// /// user's requested action token /// an instance of IFormFile for user's Avatar /// an instance of XActionResponse [AllowAnonymous] [RequireXPowered] [HttpPost ("AttachProfileImage")] public async Task> AttachProfileImage ( [FromForm] string actionToken, [FromForm] IFormFile file ) { // // Do Action ... try { // // Validate Args ... await ValidationProvider .GroupValidationBuilder () .AddNotEmpty (actionToken) .AddNotNull (file) .ValidateGroupAsync (); // var result = await identityProvider .AttachProfileImage ( actionToken, file ); // return Ok (result .ToDynamicObject ()); } catch (Exception ex) { // var exResult = GetExceptionActionResult (ex); return exResult; } } /// /// Finish Registrationn Proccess /// /// /// for this action you have to provide: /// - a proper User Identifier such as: (UserId, UserName, Email or MobileNumber). /// - Lang: client device currently used locale, such as: en-US. /// - ActionToken: user's requested action token for this action. /// - Password: assigne password. /// - Device: user's client device which is an instance of XDevice. /// - ReturnUrl: client application Login URL. /// /// Sample request: /// /// { /// "lang": "fa-IR", /// "userName": "", /// "password": "", /// "returnUrl": "", /// "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" /// } /// } /// /// /// an instance of XActionRequest class which provider requirement for action /// [AllowAnonymous] [RequireXPowered] [HttpPost ("FinishRegistration")] public async Task FinishRegistration ( [FromBody] XActionRequest model ) { // // Do Action ... try { // // Validate Args ... if (!ModelState.IsValid) { XException.InvalidArgs.Throw (); } await ValidationProvider .GroupValidationBuilder () .AddNotEmpty ( model.Lang, model.Password, model.ReturnUrl) .AddNotNull (model.Device) .AddUrl (model.ReturnUrl) .ValidateGroupAsync (); // var userSelectByParam = identityProvider .GetUserSelectByParam (model); ValidationProvider .NotEmpty (userSelectByParam); // // Get Request ... await identityProvider .FinishRegistration (model); // return Ok (); } catch (Exception ex) { // var exResult = GetExceptionActionResult (ex); // return exResult; } } /// /// Check User is Confirmed Email or not /// /// a boolean value [RequireXPowered] [HttpGet ("IsConfirmedEmail")] [Authorize (Policy = XPolicies.User)] public async Task> IsConfirmedEmail () { // // Do Action ... try { // // Get Result ... var tokens = await RetrieveTokensAsXTokenResponse (); var result = await identityProvider .IsConfirmedEmail ( tokens, User.Identity.Name ); // // Return Result return Ok (result); } catch (Exception ex) { // var result = GetExceptionActionResult (ex); // return result; } } /// /// Check User is Confirmed Mobile or not /// /// a boolean value [RequireXPowered] [HttpGet ("IsConfirmedMobile")] [Authorize (Policy = XPolicies.User)] public async Task> IsConfirmedMobile () { // // Do Action ... try { // // Get Result ... var tokens = await RetrieveTokensAsXTokenResponse (); var result = await identityProvider .IsConfirmedMobile ( tokens, User.Identity.Name ); // // Return Result return Ok (result); } catch (Exception ex) { // var result = GetExceptionActionResult (ex); // return result; } } /// /// Request Registration Confirm /// /// /// for this action you have to provide: /// - a UserSelectedBy identifier which represet User. /// - Lang: client device currently used locale, such as: en-US. /// - Password: user's current active password. /// - Device: user's client device which is an instance of XDevice. /// - ReturnUrl: client application Confirm Registration URL. /// /// Sample request: /// /// { /// "lang": "fa-IR", /// "userId": "" /// "password": "", /// "returnUrl": "http://localhost/confirm", /// "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" /// } /// } /// /// /// an instance of XActionRequest class which provider requirement for action /// [AllowAnonymous] [RequireXPowered] [HttpPost ("RequestConfirmRegistration")] public async Task RequestConfirmRegistration ( [FromBody] XActionRequest model ) { // // Do Action ... try { // // Validate Args ... if (!ModelState.IsValid) { XException.InvalidArgs.Throw (); } await ValidationProvider .GroupValidationBuilder () .AddNotEmpty ( model.Lang, model.Password, model.ReturnUrl) .AddNotNull (model.Device) .AddUrl (model.ReturnUrl) .ValidateGroupAsync (); // // Get UserSelect By Param ... var userSelectByParam = model.GetUserSelectByParam (); ValidationProvider.NotEmpty (userSelectByParam); // await identityProvider .RequestConfirmRegistration (model); // return Ok (); } catch (Exception ex) { // var exResult = GetExceptionActionResult (ex); return exResult; } } /// /// Confirm Registration /// /// /// for this action you have to provide: /// - Lang: client device currently used locale, such as: en-US. /// - ActionToken: user's requested action token for this action. /// - Device: user's client device which is an instance of XDevice. /// - ReturnUrl: client application Login URL. /// /// Sample request: /// /// { /// "lang": "fa-IR", /// "actionToken": "" /// "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" /// } /// } /// /// /// an instance of XActionRequest class which provider requirement for action /// [AllowAnonymous] [RequireXPowered] [HttpPost ("ConfirmRegistration")] public async Task ConfirmRegistration ( [FromBody] XActionRequest model ) { // // Do Action ... try { // // Validate Args ... if (!ModelState.IsValid) { XException.InvalidArgs.Throw (); } await ValidationProvider .GroupValidationBuilder () .AddNotEmpty ( model.Lang, model.ActionToken, model.ReturnUrl ) .AddNotNull (model.Device) .ValidateGroupAsync (); // // Get Request ... await identityProvider .ConfirmRegistration (model); // return Ok (); } catch (Exception ex) { // var exResult = GetExceptionActionResult (ex); return exResult; } } /// /// Request For Mobile Number Change/Confirm /// /// /// for this action you have to provide: /// - Lang: client device currently used locale, such as: en-US. /// - Password: user's current active password. /// - MobileNumber: which phone number is going to confirm. /// - Device: user's client device which is an instance of XDevice. /// /// Sample request: /// /// { /// "lang": "fa-IR", /// "password": "", /// "mobileNumber": "", /// "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" /// } /// } /// /// /// an instance of XActionRequest class which provider requirement for action /// an instance of XActionResponse [AllowAnonymous] [RequireXPowered] [HttpPost ("RequestConfirmMobile")] public async Task> RequestConfirmMobile ( [FromBody] XActionRequest model ) { // // Do Action ... try { // // Validate Args ... if (!ModelState.IsValid) { XException.InvalidArgs.Throw (); } await ValidationProvider .GroupValidationBuilder () .AddNotEmpty ( model.Lang, model.Password, model.MobileNumber) .AddNotNull (model.Device) .AddMobileNumber (model.MobileNumber) .ValidateGroupAsync (); // // Get UserSelect By Param ... var userSelectByParam = GetUserSelectByParam ( model, excludes : new List { XUserSelectBy.Email, XUserSelectBy.MobileNumber }); // // Get Request ... var result = await identityProvider .RequestConfirmMobile (model); // return Ok (result .ToDynamicObject ()); } catch (Exception ex) { // var exResult = GetExceptionActionResult (ex); return exResult; } } /// /// Confirm Requested Mobile Number /// /// /// for this action you have to provide: /// - Lang: client device currently used locale, such as: en-US. /// - ActionToken: user's requested action token for this action. /// - Device: user's client device which is an instance of XDevice. /// - MobileVerificationCode: a verification code which produced due Request Action. /// /// Sample request: /// /// { /// "lang": "fa-IR", /// "actionToken": "" /// "mobileVerificationCode": "", /// "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" /// } /// } /// /// /// an instance of XActionRequest class which provider requirement for action /// an instance of XActionResponse [AllowAnonymous] [RequireXPowered] [HttpPost ("ConfirmMobileNumber")] public async Task> ConfirmMobileNumber ( [FromBody] XActionRequest model ) { // // Do Action ... try { // // Validate Args ... if (!ModelState.IsValid) { XException.InvalidArgs.Throw (); } await ValidationProvider .GroupValidationBuilder () .AddNotEmpty ( model.Lang, model.MobileVerificationCode, model.ActionToken ) .AddNotNull (model.Device) .ValidateGroupAsync (); // // Get Request ... var result = await identityProvider .ConfirmMobileNumber (model); // return Ok (result .ToDynamicObject ()); } catch (Exception ex) { // var exResult = GetExceptionActionResult (ex); return exResult; } } /// /// Request For Email Address Change/Confirm /// /// /// for this action you have to provide: /// - Lang: client device currently used locale, such as: en-US. /// - Password: user's current active password. /// - Email: which email address is going to confirm. /// - Device: user's client device which is an instance of XDevice. /// /// Sample request: /// /// { /// "lang": "fa-IR", /// "password": "", /// "email": "", /// "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" /// } /// } /// /// /// an instance of XActionRequest class which provider requirement for action /// an instance of XActionResponse [AllowAnonymous] [RequireXPowered] [HttpPost ("RequestConfirmEmail")] public async Task> RequestConfirmEmail ( [FromBody] XActionRequest model ) { // // Do Action ... try { // // Validate Args ... if (!ModelState.IsValid) { XException.InvalidArgs.Throw (); } await ValidationProvider .GroupValidationBuilder () .AddNotEmpty ( model.Lang, model.Email, model.Password) .AddNotNull (model.Device) .AddEmailAddress (model.Email) .ValidateGroupAsync (); // // Get UserSelect By Param ... var userSelectByParam = GetUserSelectByParam ( model, excludes : new List { XUserSelectBy.Email, XUserSelectBy.MobileNumber }); // // Get Request ... var result = await identityProvider .RequestConfirmEmail (model); // return Ok (result .ToDynamicObject ()); } catch (Exception ex) { // var exResult = GetExceptionActionResult (ex); return exResult; } } /// /// Confirm Requested Email Address /// /// /// for this action you have to provide: /// - Lang: client device currently used locale, such as: en-US. /// - ActionToken: user's requested action token for this action. /// - Device: user's client device which is an instance of XDevice. /// - EmailVerificationCode: a verification code which produced due Request Action. /// /// Sample request: /// /// { /// "lang": "fa-IR", /// "actionToken": "" /// "emailVerificationCode": "", /// "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" /// } /// } /// /// /// an instance of XActionRequest class which provider requirement for action /// an instance of XActionResponse [AllowAnonymous] [RequireXPowered] [HttpPost ("ConfirmEmailAddress")] public async Task> ConfirmEmailAddress ( [FromBody] XActionRequest model ) { // // Do Action ... try { // // Validate Args ... if (!ModelState.IsValid) { XException.InvalidArgs.Throw (); } await ValidationProvider .GroupValidationBuilder () .AddNotEmpty ( model.Lang, model.EmailVerificationCode, model.ActionToken ) .AddNotNull (model.Device) .ValidateGroupAsync (); // // Get Request ... var result = await identityProvider .ConfirmEmailAddress (model); // return Ok (result .ToDynamicObject ()); } catch (Exception ex) { // var exResult = GetExceptionActionResult (ex); return exResult; } } /// /// Request Reset Password Action /// /// /// for this action you have to provide: /// - Lang: client device currently used locale, such as: en-US. /// - Device: user's client device which is an instance of XDevice. /// - ReturnUrl: client application ResetPassword URL. /// /// Sample request: /// /// { /// "lang": "fa-IR", /// "returnUrl": "http://localhost/reset-password", /// "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" /// } /// } /// /// /// an instance of XActionRequest class which provider requirement for action /// an instance of XActionResponse [AllowAnonymous] [RequireXPowered] [HttpPost ("RequestResetPassword")] public async Task> RequestResetPassword ( [FromBody] XActionRequest model ) { // // Do Action ... try { // // Validate Args ... if (!ModelState.IsValid) { XException.InvalidArgs.Throw (); } await ValidationProvider .GroupValidationBuilder () .AddNotEmpty ( model.Lang, model.ReturnUrl) .AddNotNull (model.Device) .AddUrl (model.ReturnUrl) .ValidateGroupAsync (); // // Get UserSelect By Param ... var userSelectByParam = GetUserSelectByParam ( model, excludes : new List { XUserSelectBy.Email, XUserSelectBy.MobileNumber }); // // Get Request ... var result = await identityProvider .RequestResetPassword (model); // return Ok (result .ToDynamicObject ()); } catch (Exception ex) { // var exResult = GetExceptionActionResult (ex); return exResult; } } /// /// Reset a User's Password /// /// /// for this action you have to provide: /// - Lang: client device currently used locale, such as: en-US. /// - ActionToken: user's requested action token for this action. /// - 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", /// "actionToken": "", /// "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" /// } /// } /// /// /// an instance of XActionRequest class which provider requirement for action /// [AllowAnonymous] [RequireXPowered] [HttpPost ("ResetPassword")] public async Task ResetPassword ( [FromBody] XActionRequest model ) { // // Do Action ... try { // // Validate Args ... if (!ModelState.IsValid) { XException.InvalidArgs.Throw (); } await ValidationProvider .GroupValidationBuilder () .AddNotEmpty ( model.Lang, model.ActionToken, model.NewPassword, model.ReturnUrl) .AddNotNull (model.Device) .ValidateGroupAsync (); // // Get Request ... await identityProvider .ResetPassword (model); // return Ok (); } catch (Exception ex) { // var exResult = GetExceptionActionResult (ex); return exResult; } } #endregion } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\xApi\Controllers\Account\AccountController+Search.cs 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 ... /// /// Query Open To Search Users Profiles ... /// Query all Users Which their Profiles is Open To Search ... /// /// how to filter results based on XQuery structure /// an instance of XQueryResult of XUserProfileDto [RequireXPowered] [HttpGet("OpenToSearch/Query")] [Authorize(Policy = XPolicies.EnabledUser)] public async Task>> 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 } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\xApi\Extensions\XStartupExtensions.cs 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 { /// /// Register Authorization Policies /// /// /// public static void AddXAuthorization ( this IServiceCollection services, IDictionary 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 (); } /// /// Use Forward Headers Options for resolving behind a proxy issues ... /// /// /// 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); } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\xApi\Extensions\XUserClaimsInfoDtoExtensions.cs 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; } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\xApi\Migrations\20260906032546_InitialMigration.cs using System; using Microsoft.EntityFrameworkCore.Migrations; namespace xApi.Migrations { public partial class InitialMigration : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Categories", columns: table => new { Id = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true), Deleted = table.Column(nullable: false), Title = table.Column(nullable: true), Description = table.Column(nullable: true), References = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Categories", x => x.Id); }); migrationBuilder.CreateTable( name: "Contents", columns: table => new { Id = table.Column(nullable: false), Deleted = table.Column(nullable: false), OwnerId = table.Column(maxLength: 255, nullable: false), Title = table.Column(maxLength: 255, nullable: false), Description = table.Column(maxLength: 255, nullable: true), CreatedOn = table.Column(nullable: false), UpdatedAt = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Contents", x => x.Id); }); migrationBuilder.CreateTable( name: "Files", columns: table => new { Id = table.Column(nullable: false), Deleted = table.Column(nullable: false), Type = table.Column(nullable: false), OwnerId = table.Column(maxLength: 255, nullable: false), Name = table.Column(maxLength: 255, nullable: false), Path = table.Column(nullable: false), Thumb = table.Column(nullable: true), ThumbPath = table.Column(nullable: true), UploadedOn = table.Column(nullable: false), FileName = table.Column(nullable: true), References = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Files", x => x.Id); }); migrationBuilder.CreateTable( name: "Strings", columns: table => new { Id = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true), Deleted = table.Column(nullable: false), Language = table.Column(maxLength: 10, nullable: false), ResourceTitle = table.Column(maxLength: 255, nullable: false), TranslatedValue = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Strings", x => x.Id); }); migrationBuilder.CreateTable( name: "SubCategories", columns: table => new { Id = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true), Deleted = table.Column(nullable: false), Title = table.Column(nullable: true), Description = table.Column(nullable: true), References = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_SubCategories", x => x.Id); }); migrationBuilder.CreateTable( name: "Tags", columns: table => new { Id = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true), Deleted = table.Column(nullable: false), Tag = table.Column(maxLength: 255, nullable: false), References = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Tags", x => x.Id); }); migrationBuilder.CreateTable( name: "Tests", columns: table => new { Id = table.Column(nullable: false), Deleted = table.Column(nullable: false), Firstname = table.Column(nullable: true), Lastname = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Tests", x => x.Id); }); migrationBuilder.CreateTable( name: "Webinars", columns: table => new { Id = table.Column(nullable: false), Deleted = table.Column(nullable: false), Title = table.Column(maxLength: 255, nullable: false), Description = table.Column(maxLength: 255, nullable: false), OwnerId = table.Column(nullable: false), Type = table.Column(nullable: false), CreatedOn = table.Column(nullable: false), Enabled = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Webinars", x => x.Id); }); migrationBuilder.CreateTable( name: "WebinarSubscribers", columns: table => new { Id = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true), Deleted = table.Column(nullable: false), SubscriberId = table.Column(nullable: false), WebinarId = table.Column(nullable: false), SubscribedOn = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_WebinarSubscribers", x => x.Id); }); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Categories"); migrationBuilder.DropTable( name: "Contents"); migrationBuilder.DropTable( name: "Files"); migrationBuilder.DropTable( name: "Strings"); migrationBuilder.DropTable( name: "SubCategories"); migrationBuilder.DropTable( name: "Tags"); migrationBuilder.DropTable( name: "Tests"); migrationBuilder.DropTable( name: "Webinars"); migrationBuilder.DropTable( name: "WebinarSubscribers"); } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\xApi\Migrations\20260906032546_InitialMigration.Designer.cs // using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using xServices.Databases; namespace xApi.Migrations { [DbContext(typeof(XApiDbContext))] [Migration("20260906032546_InitialMigration")] partial class InitialMigration { protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder .HasAnnotation("ProductVersion", "3.1.14"); modelBuilder.Entity("xCategoryService.Models.Entities.XCategory", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); b.Property("Deleted") .HasColumnType("INTEGER"); b.Property("Description") .HasColumnType("TEXT"); b.Property("References") .HasColumnType("TEXT"); b.Property("Title") .HasColumnType("TEXT"); b.HasKey("Id"); b.ToTable("Categories"); }); modelBuilder.Entity("xCategoryService.Models.Entities.XSubCategory", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); b.Property("Deleted") .HasColumnType("INTEGER"); b.Property("Description") .HasColumnType("TEXT"); b.Property("References") .HasColumnType("TEXT"); b.Property("Title") .HasColumnType("TEXT"); b.HasKey("Id"); b.ToTable("SubCategories"); }); modelBuilder.Entity("xContentService.Models.Entities.XContent", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("TEXT"); b.Property("CreatedOn") .HasColumnType("TEXT"); b.Property("Deleted") .HasColumnType("INTEGER"); b.Property("Description") .HasColumnType("TEXT") .HasMaxLength(255); b.Property("OwnerId") .IsRequired() .HasColumnType("TEXT") .HasMaxLength(255); b.Property("Title") .IsRequired() .HasColumnType("TEXT") .HasMaxLength(255); b.Property("UpdatedAt") .HasColumnType("TEXT"); b.HasKey("Id"); b.ToTable("Contents"); }); modelBuilder.Entity("xFileService.Models.Entities.XFile", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("TEXT"); b.Property("Deleted") .HasColumnType("INTEGER"); b.Property("FileName") .HasColumnType("TEXT"); b.Property("Name") .IsRequired() .HasColumnType("TEXT") .HasMaxLength(255); b.Property("OwnerId") .IsRequired() .HasColumnType("TEXT") .HasMaxLength(255); b.Property("Path") .IsRequired() .HasColumnType("TEXT"); b.Property("References") .HasColumnType("TEXT"); b.Property("Thumb") .HasColumnType("TEXT"); b.Property("ThumbPath") .HasColumnType("TEXT"); b.Property("Type") .HasColumnType("INTEGER"); b.Property("UploadedOn") .HasColumnType("TEXT"); b.HasKey("Id"); b.ToTable("Files"); }); modelBuilder.Entity("xServices.Models.Entities.XTest", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("TEXT"); b.Property("Deleted") .HasColumnType("INTEGER"); b.Property("Firstname") .HasColumnType("TEXT"); b.Property("Lastname") .HasColumnType("TEXT"); b.HasKey("Id"); b.ToTable("Tests"); }); modelBuilder.Entity("xStringService.Models.Entities.XString", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); b.Property("Deleted") .HasColumnType("INTEGER"); b.Property("Language") .IsRequired() .HasColumnType("TEXT") .HasMaxLength(10); b.Property("ResourceTitle") .IsRequired() .HasColumnType("TEXT") .HasMaxLength(255); b.Property("TranslatedValue") .IsRequired() .HasColumnType("TEXT"); b.HasKey("Id"); b.ToTable("Strings"); }); modelBuilder.Entity("xTagService.Models.Entities.XTag", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); b.Property("Deleted") .HasColumnType("INTEGER"); b.Property("References") .HasColumnType("TEXT"); b.Property("Tag") .IsRequired() .HasColumnType("TEXT") .HasMaxLength(255); b.HasKey("Id"); b.ToTable("Tags"); }); modelBuilder.Entity("xWebinarService.Models.Entities.XWebinar", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("TEXT"); b.Property("CreatedOn") .HasColumnType("TEXT"); b.Property("Deleted") .HasColumnType("INTEGER"); b.Property("Description") .IsRequired() .HasColumnType("TEXT") .HasMaxLength(255); b.Property("Enabled") .HasColumnType("INTEGER"); b.Property("OwnerId") .IsRequired() .HasColumnType("TEXT"); b.Property("Title") .IsRequired() .HasColumnType("TEXT") .HasMaxLength(255); b.Property("Type") .HasColumnType("INTEGER"); b.HasKey("Id"); b.ToTable("Webinars"); }); modelBuilder.Entity("xWebinarService.Models.Entities.XWebinarSubscriber", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); b.Property("Deleted") .HasColumnType("INTEGER"); b.Property("SubscribedOn") .HasColumnType("TEXT"); b.Property("SubscriberId") .IsRequired() .HasColumnType("TEXT"); b.Property("WebinarId") .HasColumnType("TEXT"); b.HasKey("Id"); b.ToTable("WebinarSubscribers"); }); #pragma warning restore 612, 618 } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\xApi\Migrations\XApiDbContextModelSnapshot.cs // using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using xServices.Databases; namespace xApi.Migrations { [DbContext(typeof(XApiDbContext))] partial class XApiDbContextModelSnapshot : ModelSnapshot { protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder .HasAnnotation("ProductVersion", "3.1.14"); modelBuilder.Entity("xCategoryService.Models.Entities.XCategory", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); b.Property("Deleted") .HasColumnType("INTEGER"); b.Property("Description") .HasColumnType("TEXT"); b.Property("References") .HasColumnType("TEXT"); b.Property("Title") .HasColumnType("TEXT"); b.HasKey("Id"); b.ToTable("Categories"); }); modelBuilder.Entity("xCategoryService.Models.Entities.XSubCategory", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); b.Property("Deleted") .HasColumnType("INTEGER"); b.Property("Description") .HasColumnType("TEXT"); b.Property("References") .HasColumnType("TEXT"); b.Property("Title") .HasColumnType("TEXT"); b.HasKey("Id"); b.ToTable("SubCategories"); }); modelBuilder.Entity("xContentService.Models.Entities.XContent", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("TEXT"); b.Property("CreatedOn") .HasColumnType("TEXT"); b.Property("Deleted") .HasColumnType("INTEGER"); b.Property("Description") .HasColumnType("TEXT") .HasMaxLength(255); b.Property("OwnerId") .IsRequired() .HasColumnType("TEXT") .HasMaxLength(255); b.Property("Title") .IsRequired() .HasColumnType("TEXT") .HasMaxLength(255); b.Property("UpdatedAt") .HasColumnType("TEXT"); b.HasKey("Id"); b.ToTable("Contents"); }); modelBuilder.Entity("xFileService.Models.Entities.XFile", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("TEXT"); b.Property("Deleted") .HasColumnType("INTEGER"); b.Property("FileName") .HasColumnType("TEXT"); b.Property("Name") .IsRequired() .HasColumnType("TEXT") .HasMaxLength(255); b.Property("OwnerId") .IsRequired() .HasColumnType("TEXT") .HasMaxLength(255); b.Property("Path") .IsRequired() .HasColumnType("TEXT"); b.Property("References") .HasColumnType("TEXT"); b.Property("Thumb") .HasColumnType("TEXT"); b.Property("ThumbPath") .HasColumnType("TEXT"); b.Property("Type") .HasColumnType("INTEGER"); b.Property("UploadedOn") .HasColumnType("TEXT"); b.HasKey("Id"); b.ToTable("Files"); }); modelBuilder.Entity("xServices.Models.Entities.XTest", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("TEXT"); b.Property("Deleted") .HasColumnType("INTEGER"); b.Property("Firstname") .HasColumnType("TEXT"); b.Property("Lastname") .HasColumnType("TEXT"); b.HasKey("Id"); b.ToTable("Tests"); }); modelBuilder.Entity("xStringService.Models.Entities.XString", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); b.Property("Deleted") .HasColumnType("INTEGER"); b.Property("Language") .IsRequired() .HasColumnType("TEXT") .HasMaxLength(10); b.Property("ResourceTitle") .IsRequired() .HasColumnType("TEXT") .HasMaxLength(255); b.Property("TranslatedValue") .IsRequired() .HasColumnType("TEXT"); b.HasKey("Id"); b.ToTable("Strings"); }); modelBuilder.Entity("xTagService.Models.Entities.XTag", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); b.Property("Deleted") .HasColumnType("INTEGER"); b.Property("References") .HasColumnType("TEXT"); b.Property("Tag") .IsRequired() .HasColumnType("TEXT") .HasMaxLength(255); b.HasKey("Id"); b.ToTable("Tags"); }); modelBuilder.Entity("xWebinarService.Models.Entities.XWebinar", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("TEXT"); b.Property("CreatedOn") .HasColumnType("TEXT"); b.Property("Deleted") .HasColumnType("INTEGER"); b.Property("Description") .IsRequired() .HasColumnType("TEXT") .HasMaxLength(255); b.Property("Enabled") .HasColumnType("INTEGER"); b.Property("OwnerId") .IsRequired() .HasColumnType("TEXT"); b.Property("Title") .IsRequired() .HasColumnType("TEXT") .HasMaxLength(255); b.Property("Type") .HasColumnType("INTEGER"); b.HasKey("Id"); b.ToTable("Webinars"); }); modelBuilder.Entity("xWebinarService.Models.Entities.XWebinarSubscriber", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); b.Property("Deleted") .HasColumnType("INTEGER"); b.Property("SubscribedOn") .HasColumnType("TEXT"); b.Property("SubscriberId") .IsRequired() .HasColumnType("TEXT"); b.Property("WebinarId") .HasColumnType("TEXT"); b.HasKey("Id"); b.ToTable("WebinarSubscribers"); }); #pragma warning restore 612, 618 } } }