1427 lines
47 KiB
Plaintext
1427 lines
47 KiB
Plaintext
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\xApi\Program.cs
|
|
|
|
using xLoggingService.DI;
|
|
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)
|
|
{
|
|
//
|
|
var result = Host.CreateDefaultBuilder(args)
|
|
.ConfigureLogging(logging =>
|
|
logging.AddXTelemetryLogger())
|
|
.ConfigureWebHostDefaults(webBuilder =>
|
|
{
|
|
webBuilder.UseStartup<Startup>();
|
|
})
|
|
.AddXTelemetry();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\xApi\Startup.cs
|
|
|
|
using System;
|
|
using System.IO;
|
|
using xServices.DI;
|
|
using System.Net.Http;
|
|
using Newtonsoft.Json;
|
|
using xApi.Extensions;
|
|
using xHttpService.DI;
|
|
using System.Reflection;
|
|
using xLoggingService.DI;
|
|
using xCommons.Extensions;
|
|
using xDataService.Models;
|
|
using xIdentityService.DI;
|
|
using xServices.Databases;
|
|
using xCommons.Configurations;
|
|
using System.Collections.Generic;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Newtonsoft.Json.Serialization;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using IdentityModel.AspNetCore.OAuth2Introspection;
|
|
|
|
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(Configuration);
|
|
|
|
//
|
|
// Register App Configuration ...
|
|
services.AddXAppConfiguration(Configuration);
|
|
var appConfiguration = services.GetRegisteredService<XAppConfiguration>();
|
|
|
|
//
|
|
// Register Logging Service ...
|
|
services.AddXLoggingService(Configuration);
|
|
|
|
//
|
|
// 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<IISServerOptions>(options =>
|
|
{
|
|
options.AllowSynchronousIO = true;
|
|
});
|
|
|
|
//
|
|
services.Configure<KestrelServerOptions>(options =>
|
|
{
|
|
options.AllowSynchronousIO = true;
|
|
});
|
|
|
|
//
|
|
// Register Services ...
|
|
services.AddXServices(
|
|
configuration: Configuration,
|
|
databases: new List<XDatabaseDescriptor>
|
|
{
|
|
apiDatabaseDescriptor
|
|
},
|
|
lifeTime: ServiceLifetime.Scoped
|
|
);
|
|
}
|
|
|
|
public void Configure(
|
|
IApplicationBuilder app,
|
|
IWebHostEnvironment env
|
|
)
|
|
{
|
|
//
|
|
var isDevelopmentEnvironment = env.IsDevelopment();
|
|
if (isDevelopmentEnvironment)
|
|
{
|
|
app.UseDeveloperExceptionPage();
|
|
}
|
|
|
|
//
|
|
// Setting Environment in App Confiuration ...
|
|
app.AddEnvironmentToXAppConfiguration(env.EnvironmentName);
|
|
|
|
//
|
|
// Use Swagger Middleware ...
|
|
app.UseXSwagger();
|
|
|
|
//
|
|
app.UseHttpsRedirection();
|
|
|
|
//
|
|
// Using Cors ...
|
|
app.UseXCors();
|
|
|
|
//
|
|
app.UseRouting();
|
|
|
|
//
|
|
// Using Request Logging ...
|
|
if (!isDevelopmentEnvironment)
|
|
{
|
|
app.UseXRequestLogger();
|
|
}
|
|
|
|
//
|
|
// Enable Api Key Usage Logs ...
|
|
// app.UseXApiKeyUsage();
|
|
|
|
//
|
|
// Use xIdentityService ...
|
|
app.UseXIdentityService();
|
|
|
|
//
|
|
app.UseAuthorization();
|
|
|
|
//
|
|
app.UseEndpoints(endpoints =>
|
|
{
|
|
endpoints.MapControllers();
|
|
});
|
|
|
|
//
|
|
// Use xDataService Middleware ...
|
|
app.UseXServices(
|
|
databases: new List<XDatabaseDescriptor>
|
|
{
|
|
apiDatabaseDescriptor
|
|
},
|
|
isDevelopmentEnvironment: env.IsDevelopment()
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\xApi\Controllers\AccountController.cs
|
|
|
|
using xCommons.Providers;
|
|
using xCommons.Configurations;
|
|
using xIdentityHelper.Controllers;
|
|
using xIdentityService.Interfaces;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace xApi.Controllers
|
|
{
|
|
public partial class AccountController : XAccountControllerBase
|
|
{
|
|
//
|
|
#region Constructor ...
|
|
public AccountController(
|
|
ILogger<AccountController> logger,
|
|
XAppConfiguration appConfiguration,
|
|
IXIdentityProvider identityProvider,
|
|
XValidationProvider validationProvider
|
|
) : base(
|
|
logger,
|
|
appConfiguration,
|
|
identityProvider,
|
|
validationProvider
|
|
)
|
|
{ }
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\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 {
|
|
/// <summary>
|
|
/// Runing when application start ...
|
|
/// </summary>
|
|
[Route ("")]
|
|
[AllowAnonymous]
|
|
public class StartupController : XBaseController {
|
|
|
|
public StartupController (
|
|
ILogger<StartupController> logger,
|
|
XAppConfiguration appConfiguration,
|
|
XValidationProvider validationProvider
|
|
) : base (
|
|
logger,
|
|
appConfiguration,
|
|
validationProvider
|
|
) { }
|
|
|
|
/// <summary>
|
|
/// Show Configured Welcome Message
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet ("")]
|
|
[AllowAnonymous]
|
|
public virtual ActionResult<string> Index () {
|
|
//
|
|
var controllerName = GetControllerName ();
|
|
var message = $"{AppConfiguration.WelcomeMessage}";
|
|
|
|
//
|
|
return Ok (message);
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\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<TestFeaturesController> logger,
|
|
XAppConfiguration appConfiguration,
|
|
XValidationProvider validationProvider,
|
|
IXSubCategoryTitleResourceProvider subCategoryTitleResourceProvider
|
|
) : base(
|
|
logger,
|
|
appConfiguration,
|
|
validationProvider
|
|
)
|
|
{
|
|
this.subCategoryTitleResourceProvider = subCategoryTitleResourceProvider;
|
|
}
|
|
|
|
[HttpGet]
|
|
public async Task<ActionResult> TestFeature()
|
|
{
|
|
//
|
|
var result = await subCategoryTitleResourceProvider.GetLanguages(
|
|
identifier: "SSSSAAALLLAAAM"
|
|
);
|
|
|
|
//
|
|
return Ok(result);
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\xApi\Controllers\TestIdentity.cs
|
|
|
|
using xCommons.Providers;
|
|
using xCommons.Configurations;
|
|
using xIdentityService.Interfaces;
|
|
using xIdentityHelper.Controllers;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace xApi.Controllers {
|
|
/// <summary>
|
|
/// Test all Authentication Policies ...
|
|
/// </summary>
|
|
public class TestIdentity : XTestIdentityControllerBase {
|
|
public TestIdentity (
|
|
ILogger<TestIdentity> logger,
|
|
XAppConfiguration appConfiguration,
|
|
IXIdentityProvider identityProvider,
|
|
XValidationProvider validationProvider
|
|
) : base (
|
|
logger,
|
|
appConfiguration,
|
|
identityProvider,
|
|
validationProvider
|
|
) { }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\xApi\Extensions\XStartupExtensions.cs
|
|
|
|
using System.Linq;
|
|
using xIdentityHelper;
|
|
using xCommons.Extensions;
|
|
using xCommons.Authorization;
|
|
using System.Collections.Generic;
|
|
using xIdentityService.Interfaces;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.HttpOverrides;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace xApi.Extensions {
|
|
public static class XStartupExtensions {
|
|
public static void AddXAuthorization(
|
|
this IServiceCollection services,
|
|
IDictionary<string, AuthorizationPolicy> policies = null
|
|
)
|
|
{
|
|
//
|
|
var policyHandler = services.GetRegisteredService<IXPolicyHandler>();
|
|
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);
|
|
|
|
//
|
|
// Add Policy to Policy Handler ...
|
|
if (!policyHandler.IsNull())
|
|
{
|
|
//
|
|
// Check Policy is RequiredRole Policy ...
|
|
var roleRequirements = policyDescriptor.Value.Requirements
|
|
.OfType<RequiredRolesRequirement>()
|
|
.FirstOrDefault();
|
|
if (!roleRequirements.IsNull() &&
|
|
roleRequirements.Roles.HasChild())
|
|
{
|
|
//
|
|
policyHandler.AddPolicy(
|
|
policy: policyDescriptor.Key.ToNormalString(),
|
|
requiredRoles: roleRequirements.Roles.Select(r => r.ToNormalString())
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
var xPolicies = XAuthorizationHelper.GetXAuthorizationPolicies();
|
|
if (!xPolicies.IsNull())
|
|
{
|
|
//
|
|
// Fill Policies ...
|
|
using (var policiesEnumerator = xPolicies.GetEnumerator())
|
|
{
|
|
while (policiesEnumerator.MoveNext())
|
|
{
|
|
//
|
|
var policyDescriptor = policiesEnumerator.Current;
|
|
|
|
//
|
|
// Add Policy to Authorization ...
|
|
options.AddPolicy(policyDescriptor.Key, policyDescriptor.Value);
|
|
|
|
//
|
|
// Add Policy to Policy Handler ...
|
|
if (!policyHandler.IsNull())
|
|
{
|
|
//
|
|
// Check Policy is RequiredRole Policy ...
|
|
var roleRequirements = policyDescriptor.Value.Requirements
|
|
.OfType<RequiredRolesRequirement>()
|
|
.FirstOrDefault();
|
|
if (!roleRequirements.IsNull() &&
|
|
roleRequirements.Roles.HasChild())
|
|
{
|
|
//
|
|
policyHandler.AddPolicy(
|
|
policy: policyDescriptor.Key.ToNormalString(),
|
|
requiredRoles: roleRequirements.Roles.Select(r => r.ToNormalString())
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
//
|
|
services.AddSingleton<IAuthorizationHandler, RequiredRolesHandler>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Use Forward Headers Options for resolving behind a proxy issues ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static void UseXForwardOptions (this IApplicationBuilder source) {
|
|
//
|
|
var forwardOptions = new ForwardedHeadersOptions {
|
|
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto,
|
|
RequireHeaderSymmetry = false
|
|
};
|
|
|
|
//
|
|
forwardOptions.KnownNetworks.Clear ();
|
|
forwardOptions.KnownProxies.Clear ();
|
|
|
|
//
|
|
// ref: https://github.com/aspnet/Docs/issues/2384
|
|
source.UseForwardedHeaders (forwardOptions);
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\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\saherelm\Documents\Projects\xSaherelmWorkspace\xApi\Migrations\20261113144654_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: "BotUsers",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
Deleted = table.Column<bool>(nullable: false),
|
|
UserId = table.Column<string>(nullable: true),
|
|
LastVerificationSent = table.Column<DateTime>(nullable: true),
|
|
ShownVirificationMenu = table.Column<bool>(nullable: false),
|
|
VerificationCode = table.Column<string>(nullable: true),
|
|
VerifiedOn = table.Column<DateTime>(nullable: true),
|
|
BotUserId = table.Column<long>(nullable: false),
|
|
BotUserName = table.Column<string>(nullable: true),
|
|
BotLastname = table.Column<string>(nullable: true),
|
|
BotFirstname = table.Column<string>(nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_BotUsers", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Categories",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
Deleted = table.Column<bool>(nullable: false),
|
|
Title = table.Column<string>(nullable: true),
|
|
Description = table.Column<string>(nullable: true),
|
|
References = table.Column<string>(nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Categories", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Contents",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(nullable: false),
|
|
Deleted = table.Column<bool>(nullable: false),
|
|
OwnerId = table.Column<string>(maxLength: 255, nullable: false),
|
|
Title = table.Column<string>(maxLength: 255, nullable: false),
|
|
Description = table.Column<string>(maxLength: 255, nullable: true),
|
|
CreatedOn = table.Column<DateTime>(nullable: false),
|
|
UpdatedAt = table.Column<DateTime>(nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Contents", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Files",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(nullable: false),
|
|
Deleted = table.Column<bool>(nullable: false),
|
|
Type = table.Column<int>(nullable: false),
|
|
OwnerId = table.Column<string>(maxLength: 255, nullable: false),
|
|
Name = table.Column<string>(maxLength: 255, nullable: false),
|
|
Path = table.Column<string>(nullable: false),
|
|
Thumb = table.Column<string>(nullable: true),
|
|
ThumbPath = table.Column<string>(nullable: true),
|
|
UploadedOn = table.Column<DateTime>(nullable: false),
|
|
FileName = table.Column<string>(nullable: true),
|
|
References = table.Column<string>(nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Files", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Strings",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
Deleted = table.Column<bool>(nullable: false),
|
|
Language = table.Column<string>(maxLength: 10, nullable: false),
|
|
ResourceTitle = table.Column<string>(maxLength: 255, nullable: false),
|
|
TranslatedValue = table.Column<string>(nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Strings", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "SubCategories",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
Deleted = table.Column<bool>(nullable: false),
|
|
Title = table.Column<string>(nullable: true),
|
|
Description = table.Column<string>(nullable: true),
|
|
References = table.Column<string>(nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_SubCategories", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Tags",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
Deleted = table.Column<bool>(nullable: false),
|
|
Tag = table.Column<string>(maxLength: 255, nullable: false),
|
|
References = table.Column<string>(nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Tags", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Tests",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(nullable: false),
|
|
Deleted = table.Column<bool>(nullable: false),
|
|
Firstname = table.Column<string>(nullable: true),
|
|
Lastname = table.Column<string>(nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Tests", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Webinars",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(nullable: false),
|
|
Deleted = table.Column<bool>(nullable: false),
|
|
Title = table.Column<string>(maxLength: 255, nullable: false),
|
|
Description = table.Column<string>(maxLength: 255, nullable: false),
|
|
OwnerId = table.Column<string>(nullable: false),
|
|
Type = table.Column<int>(nullable: false),
|
|
CreatedOn = table.Column<DateTime>(nullable: false),
|
|
Enabled = table.Column<bool>(nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Webinars", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "WebinarSubscribers",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
Deleted = table.Column<bool>(nullable: false),
|
|
SubscriberId = table.Column<string>(nullable: false),
|
|
WebinarId = table.Column<Guid>(nullable: false),
|
|
SubscribedOn = table.Column<DateTime>(nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_WebinarSubscribers", x => x.Id);
|
|
});
|
|
}
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "BotUsers");
|
|
|
|
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\saherelm\Documents\Projects\xSaherelmWorkspace\xApi\Migrations\20261113144654_InitialMigration.Designer.cs
|
|
|
|
// <auto-generated />
|
|
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("20261113144654_InitialMigration")]
|
|
partial class InitialMigration
|
|
{
|
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
{
|
|
#pragma warning disable 612, 618
|
|
modelBuilder
|
|
.HasAnnotation("ProductVersion", "3.1.14");
|
|
|
|
modelBuilder.Entity("xBotService.Models.Entities.XBotUser", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<string>("BotFirstname")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<string>("BotLastname")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<long>("BotUserId")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<string>("BotUserName")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<bool>("Deleted")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<DateTime?>("LastVerificationSent")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<bool>("ShownVirificationMenu")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<string>("UserId")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<string>("VerificationCode")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<DateTime?>("VerifiedOn")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.ToTable("BotUsers");
|
|
});
|
|
|
|
modelBuilder.Entity("xCategoryService.Models.Entities.XCategory", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<bool>("Deleted")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<string>("Description")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<string>("References")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<string>("Title")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.ToTable("Categories");
|
|
});
|
|
|
|
modelBuilder.Entity("xCategoryService.Models.Entities.XSubCategory", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<bool>("Deleted")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<string>("Description")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<string>("References")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<string>("Title")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.ToTable("SubCategories");
|
|
});
|
|
|
|
modelBuilder.Entity("xContentService.Models.Entities.XContent", b =>
|
|
{
|
|
b.Property<Guid>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<DateTime>("CreatedOn")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<bool>("Deleted")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<string>("Description")
|
|
.HasColumnType("TEXT")
|
|
.HasMaxLength(255);
|
|
|
|
b.Property<string>("OwnerId")
|
|
.IsRequired()
|
|
.HasColumnType("TEXT")
|
|
.HasMaxLength(255);
|
|
|
|
b.Property<string>("Title")
|
|
.IsRequired()
|
|
.HasColumnType("TEXT")
|
|
.HasMaxLength(255);
|
|
|
|
b.Property<DateTime>("UpdatedAt")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.ToTable("Contents");
|
|
});
|
|
|
|
modelBuilder.Entity("xFileService.Models.Entities.XFile", b =>
|
|
{
|
|
b.Property<Guid>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<bool>("Deleted")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<string>("FileName")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<string>("Name")
|
|
.IsRequired()
|
|
.HasColumnType("TEXT")
|
|
.HasMaxLength(255);
|
|
|
|
b.Property<string>("OwnerId")
|
|
.IsRequired()
|
|
.HasColumnType("TEXT")
|
|
.HasMaxLength(255);
|
|
|
|
b.Property<string>("Path")
|
|
.IsRequired()
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<string>("References")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<string>("Thumb")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<string>("ThumbPath")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<int>("Type")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<DateTime>("UploadedOn")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.ToTable("Files");
|
|
});
|
|
|
|
modelBuilder.Entity("xServices.Models.Entities.XTest", b =>
|
|
{
|
|
b.Property<Guid>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<bool>("Deleted")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<string>("Firstname")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<string>("Lastname")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.ToTable("Tests");
|
|
});
|
|
|
|
modelBuilder.Entity("xStringService.Models.Entities.XString", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<bool>("Deleted")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<string>("Language")
|
|
.IsRequired()
|
|
.HasColumnType("TEXT")
|
|
.HasMaxLength(10);
|
|
|
|
b.Property<string>("ResourceTitle")
|
|
.IsRequired()
|
|
.HasColumnType("TEXT")
|
|
.HasMaxLength(255);
|
|
|
|
b.Property<string>("TranslatedValue")
|
|
.IsRequired()
|
|
.HasColumnType("TEXT");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.ToTable("Strings");
|
|
});
|
|
|
|
modelBuilder.Entity("xTagService.Models.Entities.XTag", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<bool>("Deleted")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<string>("References")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<string>("Tag")
|
|
.IsRequired()
|
|
.HasColumnType("TEXT")
|
|
.HasMaxLength(255);
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.ToTable("Tags");
|
|
});
|
|
|
|
modelBuilder.Entity("xWebinarService.Models.Entities.XWebinar", b =>
|
|
{
|
|
b.Property<Guid>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<DateTime>("CreatedOn")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<bool>("Deleted")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<string>("Description")
|
|
.IsRequired()
|
|
.HasColumnType("TEXT")
|
|
.HasMaxLength(255);
|
|
|
|
b.Property<bool>("Enabled")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<string>("OwnerId")
|
|
.IsRequired()
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<string>("Title")
|
|
.IsRequired()
|
|
.HasColumnType("TEXT")
|
|
.HasMaxLength(255);
|
|
|
|
b.Property<int>("Type")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.ToTable("Webinars");
|
|
});
|
|
|
|
modelBuilder.Entity("xWebinarService.Models.Entities.XWebinarSubscriber", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<bool>("Deleted")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<DateTime>("SubscribedOn")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<string>("SubscriberId")
|
|
.IsRequired()
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<Guid>("WebinarId")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.ToTable("WebinarSubscribers");
|
|
});
|
|
#pragma warning restore 612, 618
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\xApi\Migrations\XApiDbContextModelSnapshot.cs
|
|
|
|
// <auto-generated />
|
|
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("xBotService.Models.Entities.XBotUser", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<string>("BotFirstname")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<string>("BotLastname")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<long>("BotUserId")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<string>("BotUserName")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<bool>("Deleted")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<DateTime?>("LastVerificationSent")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<bool>("ShownVirificationMenu")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<string>("UserId")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<string>("VerificationCode")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<DateTime?>("VerifiedOn")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.ToTable("BotUsers");
|
|
});
|
|
|
|
modelBuilder.Entity("xCategoryService.Models.Entities.XCategory", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<bool>("Deleted")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<string>("Description")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<string>("References")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<string>("Title")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.ToTable("Categories");
|
|
});
|
|
|
|
modelBuilder.Entity("xCategoryService.Models.Entities.XSubCategory", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<bool>("Deleted")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<string>("Description")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<string>("References")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<string>("Title")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.ToTable("SubCategories");
|
|
});
|
|
|
|
modelBuilder.Entity("xContentService.Models.Entities.XContent", b =>
|
|
{
|
|
b.Property<Guid>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<DateTime>("CreatedOn")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<bool>("Deleted")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<string>("Description")
|
|
.HasColumnType("TEXT")
|
|
.HasMaxLength(255);
|
|
|
|
b.Property<string>("OwnerId")
|
|
.IsRequired()
|
|
.HasColumnType("TEXT")
|
|
.HasMaxLength(255);
|
|
|
|
b.Property<string>("Title")
|
|
.IsRequired()
|
|
.HasColumnType("TEXT")
|
|
.HasMaxLength(255);
|
|
|
|
b.Property<DateTime>("UpdatedAt")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.ToTable("Contents");
|
|
});
|
|
|
|
modelBuilder.Entity("xFileService.Models.Entities.XFile", b =>
|
|
{
|
|
b.Property<Guid>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<bool>("Deleted")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<string>("FileName")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<string>("Name")
|
|
.IsRequired()
|
|
.HasColumnType("TEXT")
|
|
.HasMaxLength(255);
|
|
|
|
b.Property<string>("OwnerId")
|
|
.IsRequired()
|
|
.HasColumnType("TEXT")
|
|
.HasMaxLength(255);
|
|
|
|
b.Property<string>("Path")
|
|
.IsRequired()
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<string>("References")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<string>("Thumb")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<string>("ThumbPath")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<int>("Type")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<DateTime>("UploadedOn")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.ToTable("Files");
|
|
});
|
|
|
|
modelBuilder.Entity("xServices.Models.Entities.XTest", b =>
|
|
{
|
|
b.Property<Guid>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<bool>("Deleted")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<string>("Firstname")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<string>("Lastname")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.ToTable("Tests");
|
|
});
|
|
|
|
modelBuilder.Entity("xStringService.Models.Entities.XString", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<bool>("Deleted")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<string>("Language")
|
|
.IsRequired()
|
|
.HasColumnType("TEXT")
|
|
.HasMaxLength(10);
|
|
|
|
b.Property<string>("ResourceTitle")
|
|
.IsRequired()
|
|
.HasColumnType("TEXT")
|
|
.HasMaxLength(255);
|
|
|
|
b.Property<string>("TranslatedValue")
|
|
.IsRequired()
|
|
.HasColumnType("TEXT");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.ToTable("Strings");
|
|
});
|
|
|
|
modelBuilder.Entity("xTagService.Models.Entities.XTag", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<bool>("Deleted")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<string>("References")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<string>("Tag")
|
|
.IsRequired()
|
|
.HasColumnType("TEXT")
|
|
.HasMaxLength(255);
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.ToTable("Tags");
|
|
});
|
|
|
|
modelBuilder.Entity("xWebinarService.Models.Entities.XWebinar", b =>
|
|
{
|
|
b.Property<Guid>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<DateTime>("CreatedOn")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<bool>("Deleted")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<string>("Description")
|
|
.IsRequired()
|
|
.HasColumnType("TEXT")
|
|
.HasMaxLength(255);
|
|
|
|
b.Property<bool>("Enabled")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<string>("OwnerId")
|
|
.IsRequired()
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<string>("Title")
|
|
.IsRequired()
|
|
.HasColumnType("TEXT")
|
|
.HasMaxLength(255);
|
|
|
|
b.Property<int>("Type")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.ToTable("Webinars");
|
|
});
|
|
|
|
modelBuilder.Entity("xWebinarService.Models.Entities.XWebinarSubscriber", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<bool>("Deleted")
|
|
.HasColumnType("INTEGER");
|
|
|
|
b.Property<DateTime>("SubscribedOn")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<string>("SubscriberId")
|
|
.IsRequired()
|
|
.HasColumnType("TEXT");
|
|
|
|
b.Property<Guid>("WebinarId")
|
|
.HasColumnType("TEXT");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.ToTable("WebinarSubscribers");
|
|
});
|
|
#pragma warning restore 612, 618
|
|
}
|
|
}
|
|
}
|