Scale down project

This commit is contained in:
code liturgy 2022-11-18 00:15:53 +00:00
parent e3a74ff18d
commit bd24e655ca
92 changed files with 165 additions and 536 deletions

View File

@ -29,14 +29,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "README", "README", "{E9E3CE
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlueWest.EfMethods", "include\BlueWest.EfMethods\src\BlueWest.EfMethods\BlueWest.EfMethods.csproj", "{BBF5E860-A880-450B-B6C9-EF92F6421B3D}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlueWest.EfMethods", "include\BlueWest.EfMethods\src\BlueWest.EfMethods\BlueWest.EfMethods.csproj", "{BBF5E860-A880-450B-B6C9-EF92F6421B3D}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeLiturgy.Data.Application", "CodeLiturgy.Data.Application\CodeLiturgy.Data.Application.csproj", "{F0F4A1F3-E279-4374-B146-1E1D82011574}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeLiturgy.Views", "CodeLiturgy.Views\CodeLiturgy.Views.csproj", "{59714691-B930-416E-9B93-D91BAE37318F}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeLiturgy.Views", "CodeLiturgy.Views\CodeLiturgy.Views.csproj", "{59714691-B930-416E-9B93-D91BAE37318F}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeLiturgy.Domain", "CodeLiturgy.Domain\CodeLiturgy.Domain.csproj", "{1085FF6E-E568-441E-9A2D-23F50AB613AF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeLiturgy.Data.Auth", "CodeLiturgy.Data.Auth\CodeLiturgy.Data.Auth.csproj", "{2998FE17-18AD-4888-A696-7F6340F8A543}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sharp.Augeas", "include\Sharp.Augeas\Sharp.Augeas\Sharp.Augeas.csproj", "{F12DB2F1-2F2C-4A4C-BBAA-944AF5FB0E59}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sharp.Augeas", "include\Sharp.Augeas\Sharp.Augeas\Sharp.Augeas.csproj", "{F12DB2F1-2F2C-4A4C-BBAA-944AF5FB0E59}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sharp.Augeas.Test", "include\Sharp.Augeas\Sharp.Augeas.Test\Sharp.Augeas.Test.csproj", "{03308684-19AC-454B-8CD3-AB1C26B8BBBF}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sharp.Augeas.Test", "include\Sharp.Augeas\Sharp.Augeas.Test\Sharp.Augeas.Test.csproj", "{03308684-19AC-454B-8CD3-AB1C26B8BBBF}"
@ -75,22 +69,10 @@ Global
{BBF5E860-A880-450B-B6C9-EF92F6421B3D}.Debug|Any CPU.Build.0 = Debug|Any CPU {BBF5E860-A880-450B-B6C9-EF92F6421B3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BBF5E860-A880-450B-B6C9-EF92F6421B3D}.Release|Any CPU.ActiveCfg = Release|Any CPU {BBF5E860-A880-450B-B6C9-EF92F6421B3D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BBF5E860-A880-450B-B6C9-EF92F6421B3D}.Release|Any CPU.Build.0 = Release|Any CPU {BBF5E860-A880-450B-B6C9-EF92F6421B3D}.Release|Any CPU.Build.0 = Release|Any CPU
{F0F4A1F3-E279-4374-B146-1E1D82011574}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F0F4A1F3-E279-4374-B146-1E1D82011574}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F0F4A1F3-E279-4374-B146-1E1D82011574}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F0F4A1F3-E279-4374-B146-1E1D82011574}.Release|Any CPU.Build.0 = Release|Any CPU
{59714691-B930-416E-9B93-D91BAE37318F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {59714691-B930-416E-9B93-D91BAE37318F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{59714691-B930-416E-9B93-D91BAE37318F}.Debug|Any CPU.Build.0 = Debug|Any CPU {59714691-B930-416E-9B93-D91BAE37318F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{59714691-B930-416E-9B93-D91BAE37318F}.Release|Any CPU.ActiveCfg = Release|Any CPU {59714691-B930-416E-9B93-D91BAE37318F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{59714691-B930-416E-9B93-D91BAE37318F}.Release|Any CPU.Build.0 = Release|Any CPU {59714691-B930-416E-9B93-D91BAE37318F}.Release|Any CPU.Build.0 = Release|Any CPU
{1085FF6E-E568-441E-9A2D-23F50AB613AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1085FF6E-E568-441E-9A2D-23F50AB613AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1085FF6E-E568-441E-9A2D-23F50AB613AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1085FF6E-E568-441E-9A2D-23F50AB613AF}.Release|Any CPU.Build.0 = Release|Any CPU
{2998FE17-18AD-4888-A696-7F6340F8A543}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2998FE17-18AD-4888-A696-7F6340F8A543}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2998FE17-18AD-4888-A696-7F6340F8A543}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2998FE17-18AD-4888-A696-7F6340F8A543}.Release|Any CPU.Build.0 = Release|Any CPU
{F12DB2F1-2F2C-4A4C-BBAA-944AF5FB0E59}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F12DB2F1-2F2C-4A4C-BBAA-944AF5FB0E59}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F12DB2F1-2F2C-4A4C-BBAA-944AF5FB0E59}.Debug|Any CPU.Build.0 = Debug|Any CPU {F12DB2F1-2F2C-4A4C-BBAA-944AF5FB0E59}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F12DB2F1-2F2C-4A4C-BBAA-944AF5FB0E59}.Release|Any CPU.ActiveCfg = Release|Any CPU {F12DB2F1-2F2C-4A4C-BBAA-944AF5FB0E59}.Release|Any CPU.ActiveCfg = Release|Any CPU

View File

@ -1,30 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>BlueWest.Data.Application</RootNamespace>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\include\BlueWest.MapTo\src\BlueWest.MapTo\BlueWest.MapTo.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\include\Math-Expression-Evaluator\SimpleExpressionEvaluator\SimpleExpressionEvaluator.csproj" />
</ItemGroup>
<ItemGroup>
<Content Include="obj\rider.project.restore.info" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="7.0.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.10.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Application" />
</ItemGroup>
<Import Project="..\include\BlueWest.MapTo\src\BlueWest.MapTo\MapTo.props" />
</Project>

View File

@ -1,12 +0,0 @@
namespace BlueWest.WebApi.Configuration
{
public class ConnectionStringDocker
{
public string MySql { get; set; }
}
public class ConnectionStringNoDocker
{
public string MySql { get; set; }
}
}

View File

@ -1,14 +0,0 @@
using System;
namespace BlueWest.Data.Geography
{
public partial class Coordinate
{
public Guid Key { get; set; }
public double Latitude { get; set; }
public double Longitude { get; set; }
public Country Country { get; set; }
public long CreatedTime { get; set; }
}
}

View File

@ -1,41 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
using BlueWest.Data.Application.Users;
using MapTo;
namespace BlueWest.Data
{
[MapFrom(new []
{
typeof(CountryUpdate),
typeof(CountryCreate),
typeof(CountryUnique)
})]
public partial class Country
{
public int Id { get; set; }
/// <summary>
/// ISO 3166-1 numeric code
/// </summary>
public int Code { get; set; }
public string Name { get; set; }
/// <summary>
/// ISO 3166-1 State Name
/// </summary>
public string StateName { get; set; }
[MaxLength(2)] public string Alpha2Code { get; set; }
public string TLD { get; set; }
public List<ApplicationUser> Users { get; set; }
public DateTime CreationDate { get; set; }
}
}

View File

@ -1,27 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using MapTo;
namespace BlueWest.Data
{
[MapFrom( typeof(Country))]
public partial class CountryCreate
{
// ISO 3166-1 numeric code
public int Code { get; set; }
public string Name { get; set; }
public string StateName { get; set; }
//public List<CurrencyUnique> CurrenciesToCreate { get; set; }
public string Alpha2Code { get; set; }
public string TLD { get; set; }
public DateTime CreateTime { get; } = DateTime.Now;
}
}

View File

@ -1,26 +0,0 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using MapTo;
namespace BlueWest.Data
{
[MapFrom( typeof(Country))]
public partial class CountryUnique
{
// ISO 3166-1 numeric code
public int Id { get; set; }
public int Code { get; set; }
public string Name { get; set; }
public string StateName { get; set; }
[MaxLength(2)] public string Alpha2Code { get; set; }
public string TLD { get; set; }
}
}

View File

@ -1,21 +0,0 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using MapTo;
namespace BlueWest.Data
{
[MapFrom( typeof(Country))]
public partial class CountryUpdate
{
public string Name { get; set; }
public string StateName { get; set; }
public string Alpha2Code { get; set; }
public string TLD { get; set; }
/// <summary>
/// ISO 3166-1 numeric code
/// </summary>
public int Code { get; set; }
}
}

View File

@ -1,45 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<LangVersion>10</LangVersion>
<RootNamespace>BlueWest.WebApi</RootNamespace>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DocumentationFile>bin\$(Configuration)\$(AssemblyName).xml</DocumentationFile>
<PublishDependencyDocumentationFiles>true</PublishDependencyDocumentationFiles>
<AnalysisLevel>preview</AnalysisLevel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.ApiAuthorization.IdentityServer" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authorization.Policy" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="7.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CodeLiturgy.Data.Application\CodeLiturgy.Data.Application.csproj" />
<ProjectReference Include="..\CodeLiturgy.Domain\CodeLiturgy.Domain.csproj" />
</ItemGroup>
</Project>

View File

@ -1,58 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<LangVersion>10</LangVersion>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PublishDependencyDocumentationFiles>true</PublishDependencyDocumentationFiles>
<AnalysisLevel>preview</AnalysisLevel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.ApiAuthorization.IdentityServer" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authorization.Policy" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="7.0.0" />
<PackageReference Include="Npgsql" Version="7.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CodeLiturgy.Data.Application\CodeLiturgy.Data.Application.csproj" />
<ProjectReference Include="..\include\BlueWest.EfMethods\src\BlueWest.EfMethods\BlueWest.EfMethods.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>
<ItemGroup>
<Content Include="obj\rider.project.restore.info" />
</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="Templates\AddToListTemplate.csx" />
<AdditionalFiles Include="Templates\AddToTemplate.csx" />
<AdditionalFiles Include="Templates\GetListTemplate.csx" />
<AdditionalFiles Include="Templates\GetManyTemplate.csx" />
<AdditionalFiles Include="Templates\GetOneByTemplate.csx" />
<AdditionalFiles Include="Templates\GetOneFromListTemplate.csx" />
<AdditionalFiles Include="Templates\GetOneTemplate.csx" />
<AdditionalFiles Include="Templates\UpdateTemplate.csx" />
</ItemGroup>
<Import Project="..\include\BlueWest.EfMethods\src\BlueWest.EfMethods\BlueWest.EfMethods.props" />
</Project>

View File

@ -1,64 +0,0 @@
using BlueWest.Data;
using CodeLiturgy.Domain.Model;
using CodeLiturgy.Domain.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using BlueWest.EfMethods;
namespace CodeLiturgy.Domain
{
/// <summary>
/// Countries and Currencies
/// </summary>
[EfGenerator]
public sealed class CountryDbContext : DbContext
{
#region Countries
/// <summary>
/// Countries
/// </summary>
[EfGetOneBy(nameof(Country.Id), typeof(CountryUnique))]
[EfGetOne(typeof(CountryUnique))]
[EfAddMethods(createType: typeof(CountryCreate), returnType: typeof(CountryUnique))]
[EfUpdateMethods( updateType: typeof(CountryUpdate), returnType: typeof(CountryUnique), keyPropertyMemberName: nameof(Country.Id))]
[EfGetMany(typeof(CountryUnique))]
public DbSet<Country> Countries { get; set; }
#endregion
#region Initialization
/// <summary>
/// App Configuration
/// </summary>
public IConfiguration Configuration;
/// <summary>
/// CountryDbContext Constructor.
/// </summary>
/// <param name="options"></param>
public CountryDbContext(DbContextOptions<CountryDbContext> options) : base(options)
{
Database.EnsureCreated();
}
/// <summary>
/// On model creating.
/// </summary>
/// <param name="modelBuilder"></param>
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.ConfigureCurrentDbModel();
}
#endregion
}
}

View File

@ -1,5 +1,5 @@
namespace BlueWest.Data.Application.Users namespace CodeLiturgy.Data.Application.Users
{ {
public class AccessToken public class AccessToken
{ {

View File

@ -1,7 +1,7 @@
using System.Globalization; using System.Globalization;
using System.Net; using System.Net;
namespace BlueWest.Data.Application namespace CodeLiturgy.Data.Application
{ {
public class ApplicationDevice public class ApplicationDevice
{ {

View File

@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace BlueWest.Data.Application namespace CodeLiturgy.Data.Application
{ {
public class ApplicationDeviceCreate public class ApplicationDeviceCreate

View File

@ -1,4 +1,4 @@
namespace BlueWest.Data.Application namespace CodeLiturgy.Data.Application
{ {
public enum ClientOperatingSystem public enum ClientOperatingSystem
{ {

View File

@ -1,4 +1,4 @@
namespace BlueWest.Data.Application; namespace CodeLiturgy.Data.Application;
public enum ClientPlatformType public enum ClientPlatformType
{ {

View File

@ -1,4 +1,4 @@
namespace BlueWest.Data.Application namespace CodeLiturgy.Data.Application
{ {
public enum OperatingSystemType public enum OperatingSystemType
{ {

View File

@ -1,7 +1,7 @@
using MapTo; using MapTo;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
namespace BlueWest.Data.Application.Users namespace CodeLiturgy.Data.Application.Users
{ {
/// <inheritdoc /> /// <inheritdoc />
[MapFrom(typeof(ApplicationRoleUnique))] [MapFrom(typeof(ApplicationRoleUnique))]

View File

@ -1,6 +1,6 @@
using MapTo; using MapTo;
namespace BlueWest.Data.Application.Users namespace CodeLiturgy.Data.Application.Users
{ {
[MapFrom(typeof(ApplicationRole))] [MapFrom(typeof(ApplicationRole))]
public partial class ApplicationRoleUnique public partial class ApplicationRoleUnique

View File

@ -2,7 +2,7 @@ using System;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using MapTo; using MapTo;
namespace BlueWest.Data.Application.Users namespace CodeLiturgy.Data.Application.Users
{ {
/// <inheritdoc /> /// <inheritdoc />

View File

@ -1,6 +1,6 @@
using MapTo; using MapTo;
namespace BlueWest.Data.Application.Users namespace CodeLiturgy.Data.Application.Users
{ {
[MapFrom(typeof(ApplicationRoleClaim))] [MapFrom(typeof(ApplicationRoleClaim))]
public partial class ApplicationRoleClaimUnique public partial class ApplicationRoleClaimUnique

View File

@ -2,13 +2,13 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using BlueWest.Data; using CodeLiturgy.Data;
using BlueWest.Data.Application; using CodeLiturgy.Data.Application;
using CodeLiturgy.Data.Application; using CodeLiturgy.Data.Application;
using MapTo; using MapTo;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
namespace BlueWest.Data.Application.Users namespace CodeLiturgy.Data.Application.Users
{ {
/// <summary> /// <summary>
/// Application User in the Identity System. /// Application User in the Identity System.

View File

@ -1,7 +1,7 @@
using System; using System;
using MapTo; using MapTo;
namespace BlueWest.Data.Application.Users namespace CodeLiturgy.Data.Application.Users
{ {
[MapFrom(typeof(ApplicationUser))] [MapFrom(typeof(ApplicationUser))]
public partial class ApplicationUserUnique public partial class ApplicationUserUnique

View File

@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using MapTo; using MapTo;
namespace BlueWest.Data.Application.Users namespace CodeLiturgy.Data.Application.Users
{ {
[MapFrom(typeof(ApplicationUserClaimUnique))] [MapFrom(typeof(ApplicationUserClaimUnique))]

View File

@ -1,6 +1,6 @@
using MapTo; using MapTo;
namespace BlueWest.Data.Application.Users namespace CodeLiturgy.Data.Application.Users
{ {
[MapFrom(typeof(ApplicationUserClaim))] [MapFrom(typeof(ApplicationUserClaim))]
public partial class ApplicationUserClaimUnique public partial class ApplicationUserClaimUnique

View File

@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
namespace BlueWest.Data.Application.Users; namespace CodeLiturgy.Data.Application.Users;
/// <inheritdoc /> /// <inheritdoc />
public class ApplicationUserLogin : IdentityUserLogin<string> { } public class ApplicationUserLogin : IdentityUserLogin<string> { }

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using MapTo; using MapTo;
namespace BlueWest.Data.Application.Users namespace CodeLiturgy.Data.Application.Users
{ {
/// <inheritdoc /> /// <inheritdoc />

View File

@ -1,6 +1,6 @@
using MapTo; using MapTo;
namespace BlueWest.Data.Application.Users namespace CodeLiturgy.Data.Application.Users
{ {
[MapFrom(typeof(ApplicationUserRole))] [MapFrom(typeof(ApplicationUserRole))]
public partial class ApplicationUserRoleUnique public partial class ApplicationUserRoleUnique

View File

@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
namespace BlueWest.Data.Application.Users; namespace CodeLiturgy.Data.Application.Users;
/// <inheritdoc /> /// <inheritdoc />
public class ApplicationUserToken : IdentityUserToken<string> public class ApplicationUserToken : IdentityUserToken<string>

View File

@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace BlueWest.Data.Auth.Context.Users namespace CodeLiturgy.Data.Auth.Context.Users
{ {
// from: https://github.com/dotnet/aspnetcore/tree/main/src/Identity/samples/IdentitySample.Mvc/Models/AccountViewModels // from: https://github.com/dotnet/aspnetcore/tree/main/src/Identity/samples/IdentitySample.Mvc/Models/AccountViewModels
/// <summary> /// <summary>

View File

@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using BlueWest.Data.Application.Users; using CodeLiturgy.Data.Application.Users;
namespace BlueWest.Data.Auth.Context.Users; namespace CodeLiturgy.Data.Auth.Context.Users;
/// <summary> /// <summary>
/// ///

View File

@ -1,6 +1,6 @@
using System; using System;
namespace BlueWest.Data.Auth namespace CodeLiturgy.Data.Auth
{ {
public static class SessionConstants public static class SessionConstants
{ {

View File

@ -1,11 +1,11 @@
using BlueWest.Cryptography; using BlueWest.Cryptography;
using BlueWest.Data.Application.Users; using CodeLiturgy.Data.Application.Users;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
namespace BlueWest.Data.Auth.Context.Users; namespace CodeLiturgy.Data.Auth.Context.Users;
/// <summary> /// <summary>
/// User Manager Object /// User Manager Object

View File

@ -1,9 +1,8 @@
using System.Security.Claims; using System.Security.Claims;
using System.Threading.Tasks; using System.Threading.Tasks;
using BlueWest.Data.Application;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
namespace BlueWest.Data.Auth.Context.Users; namespace CodeLiturgy.Data.Auth.Context.Users;
public static class AuthConsts public static class AuthConsts
{ {

View File

@ -1,11 +1,11 @@
using System.Security.Claims; using System.Security.Claims;
using BlueWest.Cryptography; using BlueWest.Cryptography;
using BlueWest.Data.Application.Users; using CodeLiturgy.Data.Application.Users;
using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using static BlueWest.Data.Auth.Context.Users.AuthConsts; using static CodeLiturgy.Data.Auth.Context.Users.AuthConsts;
namespace BlueWest.Data.Auth.Context.Users namespace CodeLiturgy.Data.Auth.Context.Users
{ {
/// <summary> /// <summary>
/// Authentication Manager for the Application Users /// Authentication Manager for the Application Users

View File

@ -1,6 +1,6 @@
using System; using System;
using BlueWest.Data.Application.Users; using CodeLiturgy.Data.Application.Users;
using BlueWest.Data.Auth.Context.Users; using CodeLiturgy.Data.Auth.Context.Users;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;

View File

@ -1,5 +1,5 @@
using BlueWest.Data.Application.Users; using CodeLiturgy.Data.Application.Users;
using BlueWest.Data.Auth.Context.Users; using CodeLiturgy.Data.Auth.Context.Users;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
namespace BlueWest.Cryptography; namespace BlueWest.Cryptography;

View File

@ -1,7 +1,7 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using BlueWest.Data.Application.Users; using CodeLiturgy.Data.Application.Users;
namespace BlueWest.Data.Auth.Context.Users; namespace CodeLiturgy.Data.Auth.Context.Users;
public interface IJwtFactory public interface IJwtFactory
{ {

View File

@ -2,7 +2,7 @@ using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims; using System.Security.Claims;
using Microsoft.IdentityModel.Tokens; using Microsoft.IdentityModel.Tokens;
namespace BlueWest.Data.Auth.Context.Users namespace CodeLiturgy.Data.Auth.Context.Users
{ {
public interface IJwtTokenHandler public interface IJwtTokenHandler
{ {

View File

@ -1,4 +1,4 @@
namespace BlueWest.Data.Auth.Context.Users; namespace CodeLiturgy.Data.Auth.Context.Users;
internal interface ITokenFactory internal interface ITokenFactory
{ {

View File

@ -2,11 +2,11 @@ using System;
using System.IdentityModel.Tokens.Jwt; using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims; using System.Security.Claims;
using System.Security.Principal; using System.Security.Principal;
using BlueWest.Data.Application.Users; using CodeLiturgy.Data.Application.Users;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using static BlueWest.Data.Auth.Context.Users.Constants; using static CodeLiturgy.Data.Auth.Context.Users.Constants;
namespace BlueWest.Data.Auth.Context.Users; namespace CodeLiturgy.Data.Auth.Context.Users;
public class JwtFactory : IJwtFactory public class JwtFactory : IJwtFactory
{ {

View File

@ -2,7 +2,7 @@ using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.IdentityModel.Tokens; using Microsoft.IdentityModel.Tokens;
namespace BlueWest.Data.Auth.Context.Users; namespace CodeLiturgy.Data.Auth.Context.Users;
public class JwtIssuerOptions public class JwtIssuerOptions
{ {

View File

@ -3,7 +3,7 @@ using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims; using System.Security.Claims;
using Microsoft.IdentityModel.Tokens; using Microsoft.IdentityModel.Tokens;
namespace BlueWest.Data.Auth.Context.Users; namespace CodeLiturgy.Data.Auth.Context.Users;
public class JwtTokenHandler : IJwtTokenHandler public class JwtTokenHandler : IJwtTokenHandler
{ {

View File

@ -1,10 +1,10 @@
using System; using System;
using System.Security.Claims; using System.Security.Claims;
using System.Threading.Tasks; using System.Threading.Tasks;
using BlueWest.Data.Application; using CodeLiturgy.Data.Application;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
namespace BlueWest.Data.Auth.Context.Users; namespace CodeLiturgy.Data.Auth.Context.Users;
/// <summary> /// <summary>
/// Auth manager contract interface. /// Auth manager contract interface.

View File

@ -1,12 +1,12 @@
using BlueWest.Data.Application.Users; using CodeLiturgy.Data.Application.Users;
using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
namespace BlueWest.Data.Auth.Context.Users; namespace CodeLiturgy.Data.Auth.Context.Users;
/// <summary> /// <summary>
/// SignInManager /// SignInManager

View File

@ -1,4 +1,4 @@
namespace BlueWest.Data.Auth.Context.Users; namespace CodeLiturgy.Data.Auth.Context.Users;
public static class Constants public static class Constants
{ {

View File

@ -1,9 +1,9 @@
using System.Security.Claims; using System.Security.Claims;
using BlueWest.Data.Application.Users; using CodeLiturgy.Data.Application.Users;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
namespace BlueWest.Data.Auth.Context.Users namespace CodeLiturgy.Data.Auth.Context.Users
{ {
public interface IUserManager public interface IUserManager
{ {

View File

@ -1,10 +1,10 @@
using BlueWest.Data.Application.Users; using CodeLiturgy.Data.Application.Users;
using CodeLiturgy.Domain; using CodeLiturgy.Domain;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace BlueWest.Data.Auth.Context.Users namespace CodeLiturgy.Data.Auth.Context.Users
{ {
/// <summary> /// <summary>
/// Users Repository /// Users Repository

View File

@ -108,12 +108,32 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Extensions" />
<Folder Include="wwwroot\static\profile" /> <Folder Include="wwwroot\static\profile" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CodeLiturgy.Data.Application\CodeLiturgy.Data.Application.csproj" />
<ProjectReference Include="..\include\BlueWest.EfMethods\src\BlueWest.EfMethods\BlueWest.EfMethods.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<AdditionalFiles Include="Templates\AddToListTemplate.csx" />
<AdditionalFiles Include="Templates\AddToTemplate.csx" />
<AdditionalFiles Include="Templates\GetListTemplate.csx" />
<AdditionalFiles Include="Templates\GetManyTemplate.csx" />
<AdditionalFiles Include="Templates\GetOneByTemplate.csx" />
<AdditionalFiles Include="Templates\GetOneFromListTemplate.csx" />
<AdditionalFiles Include="Templates\GetOneTemplate.csx" />
<AdditionalFiles Include="Templates\UpdateTemplate.csx" />
<AdditionalFiles Include="Views\Auth\Account.cshtml" /> <AdditionalFiles Include="Views\Auth\Account.cshtml" />
<AdditionalFiles Include="Views\EnvironmentsPage\Index.cshtml" /> <AdditionalFiles Include="Views\EnvironmentsPage\Index.cshtml" />
</ItemGroup> </ItemGroup>
<Import Project="..\include\BlueWest.EfMethods\src\BlueWest.EfMethods\BlueWest.EfMethods.props" />
<ItemGroup>
<ProjectReference Include="..\include\BlueWest.MapTo\src\BlueWest.MapTo\BlueWest.MapTo.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\include\Math-Expression-Evaluator\SimpleExpressionEvaluator\SimpleExpressionEvaluator.csproj" />
</ItemGroup>
<Import Project="..\include\BlueWest.MapTo\src\BlueWest.MapTo\MapTo.props" />
</Project> </Project>

View File

@ -1,6 +1,6 @@
using System.Diagnostics; using System.Diagnostics;
using System.Web.Mvc; using System.Web.Mvc;
using BlueWest.Data.Auth.Context.Users; using CodeLiturgy.Data.Auth.Context.Users;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using CodeLiturgy.Views.Models; using CodeLiturgy.Views.Models;
using CodeLiturgy.Views.Utils; using CodeLiturgy.Views.Utils;

View File

@ -1,6 +1,6 @@
using System.Security.Claims; using System.Security.Claims;
using BlueWest.Data.Auth; using CodeLiturgy.Data.Auth;
using BlueWest.Data.Auth.Context.Users; using CodeLiturgy.Data.Auth.Context.Users;
using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;

View File

@ -1,4 +1,4 @@
using BlueWest.Data.Auth.Context.Users; using CodeLiturgy.Data.Auth.Context.Users;
using CodeLiturgy.Views.Utils; using CodeLiturgy.Views.Utils;
using Duende.IdentityServer.Extensions; using Duende.IdentityServer.Extensions;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;

View File

@ -1,4 +1,4 @@
using BlueWest.Data.Auth.Context.Users; using CodeLiturgy.Data.Auth.Context.Users;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using CodeLiturgy.Views.Utils; using CodeLiturgy.Views.Utils;
using Duende.IdentityServer.Extensions; using Duende.IdentityServer.Extensions;

View File

@ -1,4 +1,4 @@
using BlueWest.Data.Auth.Context.Users; using CodeLiturgy.Data.Auth.Context.Users;
using CodeLiturgy.Data.Application; using CodeLiturgy.Data.Application;
using CodeLiturgy.Domain; using CodeLiturgy.Domain;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;

View File

@ -1,4 +1,4 @@
using BlueWest.Data.Auth.Context.Users; using CodeLiturgy.Data.Auth.Context.Users;
using CodeLiturgy.Views.Utils; using CodeLiturgy.Views.Utils;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;

View File

@ -1,7 +1,7 @@
using System.Net; using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
using BlueWest.Data.Application.Users; using CodeLiturgy.Data.Application.Users;
using BlueWest.Data.Auth.Context.Users; using CodeLiturgy.Data.Auth.Context.Users;
using CodeLiturgy.Views.Models; using CodeLiturgy.Views.Models;
using CodeLiturgy.Views.Utils; using CodeLiturgy.Views.Utils;
using Duende.IdentityServer.Extensions; using Duende.IdentityServer.Extensions;

View File

@ -1,4 +1,4 @@
using BlueWest.Data.Application.Users; using CodeLiturgy.Data.Application.Users;
using BlueWest.EfMethods; using BlueWest.EfMethods;
using CodeLiturgy.Domain.Model; using CodeLiturgy.Domain.Model;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.AspNetCore.Identity.EntityFrameworkCore;

View File

@ -13,6 +13,8 @@ namespace CodeLiturgy.Domain
public DbSet<Site> Sites { get; set; } public DbSet<Site> Sites { get; set; }
public DbSet<SiteEnvironment> Environments { get; set; }
/// <summary> /// <summary>
/// SiteDbContext Constructor. /// SiteDbContext Constructor.
/// </summary> /// </summary>

View File

@ -1,5 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using BlueWest.Data; using CodeLiturgy.Data;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace CodeLiturgy.Domain.Extensions namespace CodeLiturgy.Domain.Extensions

View File

@ -1,6 +1,7 @@
using BlueWest.Data; using CodeLiturgy.Data;
using BlueWest.Data.Application; using CodeLiturgy.Data.Application;
using BlueWest.Data.Application.Users; using CodeLiturgy.Data.Application.Users;
using CodeLiturgy.Data.Application;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace CodeLiturgy.Domain.Model namespace CodeLiturgy.Domain.Model
@ -22,10 +23,10 @@ namespace CodeLiturgy.Domain.Model
{ {
modelBuilder modelBuilder
.ConfigureDatabaseKeys() .ConfigureDatabaseKeys()
.CurrencyModel() .ConfigureAppContextModel()
.ConfigureUserModel() .ConfigureUserModel()
.ConfigureAppContextModel(); .ConfigureEnvironmentModel();
//.ConfigureIdentityModel(); //.ConfigureIdentityModel();
} }
@ -38,9 +39,8 @@ namespace CodeLiturgy.Domain.Model
/// Configure App context model /// Configure App context model
/// </summary> /// </summary>
/// <param name="modelBuilder"></param> /// <param name="modelBuilder"></param>
private static void ConfigureAppContextModel(this ModelBuilder builder) private static ModelBuilder ConfigureAppContextModel(this ModelBuilder builder)
{ {
builder.Entity<ApplicationUserRole>().ToTable("UserRoles");
builder.Entity<ApplicationUser>(b => builder.Entity<ApplicationUser>(b =>
{ {
b.HasMany<ApplicationUserRole>() b.HasMany<ApplicationUserRole>()
@ -49,7 +49,7 @@ namespace CodeLiturgy.Domain.Model
}); });
builder.Entity<ApplicationUser>().ToTable("ApplicationUser") builder.Entity<ApplicationUser>()
.HasKey(x => x.Id); .HasKey(x => x.Id);
@ -57,7 +57,7 @@ namespace CodeLiturgy.Domain.Model
{ {
b.HasKey(r => r.Id); b.HasKey(r => r.Id);
b.HasIndex(r => r.NormalizedName).HasDatabaseName("RoleNameIndex").IsUnique(); b.HasIndex(r => r.NormalizedName).HasDatabaseName("RoleNameIndex").IsUnique();
b.ToTable("Roles"); b.ToTable("roles");
b.Property(r => r.ConcurrencyStamp).IsConcurrencyToken(); b.Property(r => r.ConcurrencyStamp).IsConcurrencyToken();
b.Property(u => u.Name).HasMaxLength(256); b.Property(u => u.Name).HasMaxLength(256);
@ -75,20 +75,16 @@ namespace CodeLiturgy.Domain.Model
builder.Entity<ApplicationRoleClaim>(b => builder.Entity<ApplicationRoleClaim>(b =>
{ {
b.HasKey(rc => rc.Id); b.HasKey(rc => rc.Id);
b.ToTable("RoleClaims");
}); });
builder.Entity<ApplicationUserRole>(b => builder.Entity<ApplicationUserRole>(b =>
{ {
b.HasKey(r => new {r.UserId, r.RoleId}); b.HasKey(r => new {r.UserId, r.RoleId});
b.ToTable("UserRoles");
}); });
builder.Entity<ApplicationRoleClaim>().ToTable("RoleClaims");
builder.Entity<ApplicationUserRole>().ToTable("UserRole");
return builder;
//.ConfigureIdentityModel(); //.ConfigureIdentityModel();
} }
@ -98,12 +94,23 @@ namespace CodeLiturgy.Domain.Model
private static ModelBuilder ConfigureDatabaseKeys(this ModelBuilder modelBuilder) private static ModelBuilder ConfigureDatabaseKeys(this ModelBuilder modelBuilder)
{ {
// Country
// Site
modelBuilder modelBuilder
.Entity<Country>(builder => builder .Entity<Site>(builder => builder
.HasKey(country => country.Id)) .HasKey(site => site.Id))
.Entity<Country>().Property(country => country.Id) .Entity<Site>().Property(site => site.Id)
.ValueGeneratedOnAdd(); .ValueGeneratedOnAdd();
// Site Environment
modelBuilder
.Entity<SiteEnvironment>(builder => builder
.HasKey(site => site.Id))
.Entity<Site>().Property(site => site.Id)
.ValueGeneratedOnAdd();
// FinanceOp // FinanceOp
return return
@ -115,16 +122,24 @@ namespace CodeLiturgy.Domain.Model
#region Database Models #region Database Models
private static ModelBuilder CurrencyModel(this ModelBuilder modelBuilder)
{
modelBuilder.Entity<Country>().ToTable("Countries");
return modelBuilder;
}
private static ModelBuilder ConfigureUserModel(this ModelBuilder modelBuilder) private static ModelBuilder ConfigureUserModel(this ModelBuilder modelBuilder)
{ {
modelBuilder.Entity<ApplicationUser>()
.HasMany(x => x.Environments)
.WithOne(u => u.User)
.HasForeignKey(x => x.UserId);
return modelBuilder;
}
private static ModelBuilder ConfigureEnvironmentModel(this ModelBuilder modelBuilder)
{
modelBuilder.Entity<SiteEnvironment>().ToTable("site_env");
modelBuilder
.Entity<SiteEnvironment>()
.HasMany(x => x.Sites)
.WithOne(x => x.Environment)
.HasForeignKey(x => x.EnvironmentId);
return modelBuilder; return modelBuilder;
} }

View File

@ -1,5 +1,5 @@
using BlueWest.Data.Application.Users; using CodeLiturgy.Data.Application.Users;
using BlueWest.Data.Auth; using CodeLiturgy.Data.Auth;
using CodeLiturgy.Views.Models; using CodeLiturgy.Views.Models;
using Microsoft.AspNetCore.Mvc.ViewFeatures; using Microsoft.AspNetCore.Mvc.ViewFeatures;

View File

@ -14,12 +14,14 @@ namespace CodeLiturgy.Data.Application
{ {
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public string Id { get; set; } public string Id { get; set; }
public string Name { get; set; } public SiteEnvironment Environment { get; set; }
public string EnvironmentId { get; set; }
public string Domain { get; set; } public string Domain { get; set; }
public string Ip { get; set; } public string UrlAddress { get; set; }
public EnvironmentType EnvironmentType { get; set; } public EnvironmentType EnvironmentType { get; set; }

View File

@ -2,7 +2,7 @@ namespace CodeLiturgy.Data.Application
{ {
public static class SiteDbExtensions public static class SiteDbExtensions
{ {
} }
} }

View File

@ -1,10 +1,16 @@
using System.Collections.Generic; using System.Collections.Generic;
using CodeLiturgy.Data.Application.Users;
namespace CodeLiturgy.Data.Application namespace CodeLiturgy.Data.Application
{ {
public class SiteEnvironment public class SiteEnvironment
{ {
public string Id { get; set; } public string Id { get; set; }
public string Name { get; set; }
public ApplicationUser User { get; set; }
public string UserId { get; set; }
public List<Site> Sites { get; set; } public List<Site> Sites { get; set; }
} }
} }

View File

@ -1,5 +1,5 @@
using System.Globalization; using System.Globalization;
using BlueWest.Data.Auth; using CodeLiturgy.Data.Auth;
using CodeLiturgy.Views.Utils; using CodeLiturgy.Views.Utils;
using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Localization; using Microsoft.AspNetCore.Localization;

View File

@ -1,8 +1,8 @@
using System.Text; using System.Text;
using BlueWest.Cryptography; using BlueWest.Cryptography;
using BlueWest.Data.Application.Users; using CodeLiturgy.Data.Application.Users;
using BlueWest.Data.Auth; using CodeLiturgy.Data.Auth;
using BlueWest.Data.Auth.Context.Users; using CodeLiturgy.Data.Auth.Context.Users;
using CodeLiturgy.Domain; using CodeLiturgy.Domain;
using BlueWest.WebApi.Context.Users; using BlueWest.WebApi.Context.Users;
using CodeLiturgy.Views.Utils; using CodeLiturgy.Views.Utils;
@ -21,27 +21,20 @@ public static class StartupExtensions
new(new Version(major, minor, build)); new(new Version(major, minor, build));
*/ */
private static string GetConnectionString(this IConfiguration configurationRoot, string db) private static string GetDbConnectionString(this IConfiguration configurationRoot, string key)
{ {
var startupMode = configurationRoot["mode"]; var startupMode = configurationRoot["mode"];
if (!string.IsNullOrEmpty(startupMode) && startupMode == "docker") if (!string.IsNullOrEmpty(startupMode))
{ {
var config = configurationRoot.GetSection("ConnectionStringDocker")[db]; var config = configurationRoot.GetSection($"ConnectionString:{startupMode}")[key];
return config; return config;
} }
else return String.Empty;
{
return configurationRoot.GetSection("ConnectionStringNoDocker")[db] ?? string.Empty;
}
} }
private static bool IsDockerMode(this IConfiguration config)
{
var startupMode = config["mode"];
return startupMode == "docker";
}
internal static IServiceCollection AddAuthServerServices(this IServiceCollection services, internal static IServiceCollection AddAuthServerServices(this IServiceCollection services,
IConfiguration configuration, IWebHostEnvironment environment) IConfiguration configuration, IWebHostEnvironment environment)
@ -172,7 +165,7 @@ public static class StartupExtensions
private static DbContextOptionsBuilder UsePsqlConfiguration(this DbContextOptionsBuilder builder, IConfiguration configuration) private static DbContextOptionsBuilder UsePsqlConfiguration(this DbContextOptionsBuilder builder, IConfiguration configuration)
{ {
var connString = configuration.GetConnectionString("database"); var connString = configuration.GetDbConnectionString("db");
builder.UseNpgsql(connString); builder.UseNpgsql(connString);
return builder; return builder;
} }
@ -190,7 +183,6 @@ public static class StartupExtensions
{ {
return serviceCollection return serviceCollection
.AddDbContextPool<SiteDbContext>(options => options.UsePsqlConfiguration(configuration)) .AddDbContextPool<SiteDbContext>(options => options.UsePsqlConfiguration(configuration))
.AddDbContextPool<CountryDbContext>(options => options.UsePsqlConfiguration(configuration))
.AddDbContextPool<ApplicationUserDbContext>(options => .AddDbContextPool<ApplicationUserDbContext>(options =>
options.UsePsqlConfiguration(configuration)); options.UsePsqlConfiguration(configuration));
} }

View File

@ -1,56 +0,0 @@
using System.Diagnostics;
namespace CodeLiturgy.Views
{
public static class SystemExtensions
{
public static void ExecuteCommand(string command)
{
Process proc = new();
proc.StartInfo.FileName = "/bin/bash";
proc.StartInfo.Arguments = "-c \" " + command + " \"";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start ();
while (!proc.StandardOutput.EndOfStream) {
Console.WriteLine (proc.StandardOutput.ReadLine ());
}
}
public static void AddUser(
string username,
bool createHome,
bool useSudo)
{
var sudoStr = useSudo ? "sudo" : "";
var createHomeStr = createHome ? "-m" : "";
var addUser = $"{sudoStr} useradd {createHomeStr} {username}";
var deletePass = $"{sudoStr} passwd -d {username}";
var lockPass = $"{sudoStr} passwd -l {username} ";
ExecuteCommand(addUser);
ExecuteCommand(deletePass);
ExecuteCommand(lockPass);
}
public static void DeleteUser(
string username,
bool deleteHome,
bool useSudo)
{
var sudo = useSudo ? "sudo" : "";
var rmUser = $"{sudo} userdel {username}";
ExecuteCommand(rmUser);
if (deleteHome)
{
var delHome = $"{sudo} rm -rf /home/{username}";
ExecuteCommand(delHome);
}
}
}
}

View File

@ -1,6 +1,6 @@
@using CodeLiturgy.Views.Utils @using CodeLiturgy.Views.Utils
@using Duende.IdentityServer.Extensions @using Duende.IdentityServer.Extensions
@using BlueWest.Data.Auth @using CodeLiturgy.Data.Auth
@{ @{
Layout = null; Layout = null;
var userAuthenticated = User.IsAuthenticated(); var userAuthenticated = User.IsAuthenticated();

View File

@ -1,5 +1,5 @@
@using CodeLiturgy.Views.Utils @using CodeLiturgy.Views.Utils
@using BlueWest.Data.Auth @using CodeLiturgy.Data.Auth
@{ @{
var applicationUser = ViewData.GetUserViewData(); var applicationUser = ViewData.GetUserViewData();
var rootUrl = SessionConstants.CookieDomain; var rootUrl = SessionConstants.CookieDomain;

View File

@ -5,13 +5,18 @@
"Microsoft.AspNetCore": "Warning" "Microsoft.AspNetCore": "Warning"
} }
}, },
"mode": "no-docker", "mode": "local",
"AllowedHosts": "*", "AllowedHosts": "*",
"ConnectionStringDocker": { "ConnectionString": {
"database": "Server=127.0.0.1;User Id=clbdlocal;Password=C79J#MV))!YAiy/SzkCf;Database=cldblocal;" "local": {
}, "db": "Server=127.0.0.1;User Id=clbdlocal;Password=C79J#MV))!YAiy/SzkCf;Database=cldblocal;"
"ConnectionStringNoDocker": { },
"database": "Server=127.0.0.1;User Id=clbdlocal;Password=C79J#MV))!YAiy/SzkCf;Database=cldblocal;" "dev": {
"db": "Server=127.0.0.1;User Id=clbdlocal;Password=C79J#MV))!YAiy/SzkCf;Database=cldblocal;"
},
"staging": {
"db": "Server=127.0.0.1;User Id=clbdlocal;Password=C79J#MV))!YAiy/SzkCf;Database=cldblocal;"
}
}, },
"AuthSettings": { "AuthSettings": {
"SecretKey": "iJWHDmHLpUA283sqsfhqGbMRdRj1PVkH" "SecretKey": "iJWHDmHLpUA283sqsfhqGbMRdRj1PVkH"