Чето поменял

This commit is contained in:
2025-03-08 22:00:08 +03:00
parent b4056fa715
commit 8c0ad9bc3e
30 changed files with 584 additions and 566 deletions

View File

@@ -1,5 +1,4 @@
@using BlazorWebAssemblyVisaApiClient.ErrorHandling @using BlazorWebAssemblyVisaApiClient.ErrorHandling
<GlobalErrorHandler > <GlobalErrorHandler >
<Router AppAssembly="@typeof(App).Assembly"> <Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData"> <Found Context="routeData">

View File

@@ -2,7 +2,6 @@
@using BlazorWebAssemblyVisaApiClient.ErrorHandling @using BlazorWebAssemblyVisaApiClient.ErrorHandling
@using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider @using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider
@using VisaApiClient @using VisaApiClient
@code { @code {
public static AuthData? AuthData; public static AuthData? AuthData;

View File

@@ -1,6 +1,5 @@
@using BlazorWebAssemblyVisaApiClient.ErrorHandling @using BlazorWebAssemblyVisaApiClient.ErrorHandling
@using VisaApiClient @using VisaApiClient
@code @code
{ {
[CascadingParameter] protected GlobalErrorHandler ErrorHandler { get; set; } = null!; [CascadingParameter] protected GlobalErrorHandler ErrorHandler { get; set; } = null!;

View File

@@ -1,5 +1,4 @@
@using VisaApiClient @using VisaApiClient
<div> <div>
<div > <div >
<label > <label >

View File

@@ -1,5 +1,4 @@
@using VisaApiClient @using VisaApiClient
<div> <div>
<div > <div >
<label > <label >

View File

@@ -1,5 +1,4 @@
@using VisaApiClient @using VisaApiClient
<div> <div>
<div > <div >
<label> <label>

View File

@@ -1,6 +1,5 @@
@using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.DateTimeProvider @using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.DateTimeProvider
@using VisaApiClient @using VisaApiClient
<div> <div>
<div > <div >
<label> <label>

View File

@@ -1,7 +1,7 @@
@using System.Linq.Expressions @typeparam TItem where TItem : class
@using System.Linq.Expressions
@using System.Reflection @using System.Reflection
@using BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers @using BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers
@typeparam TItem where TItem : class
@typeparam TMember where TMember : struct, Enum @typeparam TMember where TMember : struct, Enum
<InputSelect TValue="TMember" @bind-Value="selected"> <InputSelect TValue="TMember" @bind-Value="selected">

View File

@@ -1,6 +1,5 @@
@using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.DateTimeProvider @using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.DateTimeProvider
@using VisaApiClient @using VisaApiClient
<div> <div>
<label> <label>
Issuer:<br/> Issuer:<br/>

View File

@@ -1,6 +1,5 @@
@using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.DateTimeProvider @using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.DateTimeProvider
@using VisaApiClient @using VisaApiClient
<div> <div>
<label> <label>
Number:<br/> Number:<br/>

View File

@@ -1,7 +1,6 @@
@using System.Net @using System.Net
@using BlazorWebAssemblyVisaApiClient.Common.Exceptions @using BlazorWebAssemblyVisaApiClient.Common.Exceptions
@using VisaApiClient @using VisaApiClient
<CascadingValue Value="this"> <CascadingValue Value="this">
<Modal @ref="modal"> <Modal @ref="modal">
<BodyTemplate> <BodyTemplate>

View File

@@ -1,10 +1,10 @@
@page "/authorities/add" @page "/authorities/add"
@using AutoMapper @using AutoMapper
@using BlazorWebAssemblyVisaApiClient.Validation.Applicants.Models
@using VisaApiClient
@using BlazorWebAssemblyVisaApiClient.Components @using BlazorWebAssemblyVisaApiClient.Components
@using BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers @using BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers
@using BlazorWebAssemblyVisaApiClient.Validation.Applicants.Models
@using FluentValidation @using FluentValidation
@using VisaApiClient
@inherits BlazorWebAssemblyVisaApiClient.Components.Base.VisaClientComponentBase @inherits BlazorWebAssemblyVisaApiClient.Components.Base.VisaClientComponentBase
<EditForm Model="requestModel" class="with-centered-content"> <EditForm Model="requestModel" class="with-centered-content">

View File

@@ -1,8 +1,8 @@
@page "/" @page "/"
@using BlazorWebAssemblyVisaApiClient.Components.Auth
@using VisaApiClient
@using BlazorWebAssemblyVisaApiClient.Components.FormComponents.Applicants
@using BlazorWebAssemblyVisaApiClient.Components @using BlazorWebAssemblyVisaApiClient.Components
@using BlazorWebAssemblyVisaApiClient.Components.Auth
@using BlazorWebAssemblyVisaApiClient.Components.FormComponents.Applicants
@using VisaApiClient
@inherits BlazorWebAssemblyVisaApiClient.Components.Base.VisaClientComponentBase @inherits BlazorWebAssemblyVisaApiClient.Components.Base.VisaClientComponentBase
<PageTitle>Authentication</PageTitle> <PageTitle>Authentication</PageTitle>

View File

@@ -1,11 +1,11 @@
@page "/authorities/{authorityId}/{oldEmail}" @page "/authorities/{authorityId}/{oldEmail}"
@inherits BlazorWebAssemblyVisaApiClient.Components.Base.VisaClientComponentBase
@using BlazorWebAssemblyVisaApiClient.Common.Exceptions @using BlazorWebAssemblyVisaApiClient.Common.Exceptions
@using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider
@using VisaApiClient
@using BlazorWebAssemblyVisaApiClient.Components @using BlazorWebAssemblyVisaApiClient.Components
@using BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers @using BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers
@using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider
@using FluentValidation @using FluentValidation
@using VisaApiClient
@inherits BlazorWebAssemblyVisaApiClient.Components.Base.VisaClientComponentBase
<EditForm Model="model" class="with-centered-content"> <EditForm Model="model" class="with-centered-content">
<div > <div >

View File

@@ -1,17 +1,17 @@
@page "/applications/new" @page "/applications/new"
@using System.Net @using System.Net
@using AutoMapper @using AutoMapper
@using BlazorWebAssemblyVisaApiClient.Validation.VisaApplications.Models
@using VisaApiClient
@using BlazorWebAssemblyVisaApiClient.Components @using BlazorWebAssemblyVisaApiClient.Components
@using BlazorWebAssemblyVisaApiClient.Components.FormComponents
@using BlazorWebAssemblyVisaApiClient.Components.FormComponents.VisaApplications @using BlazorWebAssemblyVisaApiClient.Components.FormComponents.VisaApplications
@using BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers @using BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers
@using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.DateTimeProvider @using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.DateTimeProvider
@using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider @using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider
@using BlazorWebAssemblyVisaApiClient.Validation @using BlazorWebAssemblyVisaApiClient.Validation
@using BlazorWebAssemblyVisaApiClient.Validation.VisaApplications.Models
@using FluentValidation @using FluentValidation
@using Newtonsoft.Json.Linq @using Newtonsoft.Json.Linq
@using BlazorWebAssemblyVisaApiClient.Components.FormComponents @using VisaApiClient
@inherits BlazorWebAssemblyVisaApiClient.Components.Base.VisaClientComponentBase @inherits BlazorWebAssemblyVisaApiClient.Components.Base.VisaClientComponentBase
<PageTitle>New Application</PageTitle> <PageTitle>New Application</PageTitle>

View File

@@ -1,16 +1,16 @@
@page "/register" @page "/register"
@using System.Net @using System.Net
@using AutoMapper @using AutoMapper
@using VisaApiClient
@using BlazorWebAssemblyVisaApiClient.Components.FormComponents.Applicants
@using global::FluentValidation
@using Newtonsoft.Json
@using Newtonsoft.Json.Linq
@using BlazorWebAssemblyVisaApiClient.Components @using BlazorWebAssemblyVisaApiClient.Components
@using BlazorWebAssemblyVisaApiClient.Components.FormComponents
@using BlazorWebAssemblyVisaApiClient.Components.FormComponents.Applicants
@using BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers @using BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers
@using BlazorWebAssemblyVisaApiClient.Validation @using BlazorWebAssemblyVisaApiClient.Validation
@using BlazorWebAssemblyVisaApiClient.Validation.Applicants.Models @using BlazorWebAssemblyVisaApiClient.Validation.Applicants.Models
@using BlazorWebAssemblyVisaApiClient.Components.FormComponents @using FluentValidation
@using Newtonsoft.Json
@using Newtonsoft.Json.Linq
@using VisaApiClient
@inherits BlazorWebAssemblyVisaApiClient.Components.Base.VisaClientComponentBase @inherits BlazorWebAssemblyVisaApiClient.Components.Base.VisaClientComponentBase
<PageTitle>Registration</PageTitle> <PageTitle>Registration</PageTitle>

View File

@@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore;
namespace Infrastructure.Database; namespace Infrastructure.Database;
public class DbContext(DbContextOptions<DbContext> opts) : Microsoft.EntityFrameworkCore.DbContext(opts), IGenericWriter, IGenericReader, IUnitOfWork public class DatabaseContext(DbContextOptions<DatabaseContext> opts) : DbContext(opts), IGenericWriter, IGenericReader, IUnitOfWork
{ {
protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnModelCreating(ModelBuilder modelBuilder)
{ {

View File

@@ -4,6 +4,7 @@ using ApplicationLayer.Services.Applicants.NeededServices;
using ApplicationLayer.Services.AuthServices.NeededServices; using ApplicationLayer.Services.AuthServices.NeededServices;
using ApplicationLayer.Services.VisaApplications.NeededServices; using ApplicationLayer.Services.VisaApplications.NeededServices;
using Infrastructure.Common; using Infrastructure.Common;
using Infrastructure.Database;
using Infrastructure.Database.Applicants.Repositories; using Infrastructure.Database.Applicants.Repositories;
using Infrastructure.Database.Generic; using Infrastructure.Database.Generic;
using Infrastructure.Database.Users.Repositories; using Infrastructure.Database.Users.Repositories;
@@ -12,7 +13,6 @@ using Infrastructure.EntityToExcelTemplateWriter;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using DbContext = Infrastructure.Database.DbContext;
namespace Infrastructure; namespace Infrastructure;
@@ -26,12 +26,12 @@ public static class DependencyInjection
{ {
var databaseName = isDevelopment ? "developmentDB" : "normal'naya database"; var databaseName = isDevelopment ? "developmentDB" : "normal'naya database";
services.AddDbContext<DbContext>(opts => services.AddDbContext<DatabaseContext>(opts =>
opts.UseSqlServer(configurationManager.GetConnectionString(databaseName))); opts.UseNpgsql(configurationManager.GetConnectionString(databaseName)));
services.AddScoped<IGenericReader>(serviceProvider => serviceProvider.GetRequiredService<DbContext>()); services.AddScoped<IGenericReader>(serviceProvider => serviceProvider.GetRequiredService<DatabaseContext>());
services.AddScoped<IGenericWriter>(serviceProvider => serviceProvider.GetRequiredService<DbContext>()); services.AddScoped<IGenericWriter>(serviceProvider => serviceProvider.GetRequiredService<DatabaseContext>());
services.AddScoped<IUnitOfWork>(serviceProvider => serviceProvider.GetRequiredService<DbContext>()); services.AddScoped<IUnitOfWork>(serviceProvider => serviceProvider.GetRequiredService<DatabaseContext>());
services.AddScoped<IApplicantsRepository, ApplicantsRepository>(); services.AddScoped<IApplicantsRepository, ApplicantsRepository>();
services.AddScoped<IVisaApplicationsRepository, VisaApplicationsRepository>(); services.AddScoped<IVisaApplicationsRepository, VisaApplicationsRepository>();

View File

@@ -13,9 +13,17 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="DocumentFormat.OpenXml" Version="3.1.0" /> <PackageReference Include="DocumentFormat.OpenXml" Version="3.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.8" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0-preview.7.24405.3" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.0-preview.7.24405.3" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.2">
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.0-preview.7.24405.3" /> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -8,6 +8,14 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0"/> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0"/>
</ItemGroup> </ItemGroup>

View File

@@ -8,7 +8,7 @@
"AllowedHosts": "*", "AllowedHosts": "*",
"ConnectionStrings": { "ConnectionStrings": {
"developmentDB": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=visadb;Integrated Security=True;", "developmentDB": "Host=localhost;Port=5432;Database=visa;Username=postgres;Password=Qwerty123456!",
"normal'naya db": "" "normal'naya db": ""
}, },

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,5 @@
using System.Text; using System.Text;
// ReSharper disable UnusedParameter.Local // ReSharper disable UnusedParameter.Local
namespace VisaApiClient; namespace VisaApiClient;

View File

@@ -24,7 +24,7 @@ public class RegisterRequestValidatorTests
/// </summary> /// </summary>
/// <param name="context">db context</param> /// <param name="context">db context</param>
/// <returns>RegisterRequest validator</returns> /// <returns>RegisterRequest validator</returns>
private static IValidator<RegisterRequest> GetValidator(DbContext context) private static IValidator<RegisterRequest> GetValidator(DatabaseContext context)
{ {
var repository = new UsersRepository(context, context); var repository = new UsersRepository(context, context);
return new RegisterRequestValidator(repository, authDataValidator); return new RegisterRequestValidator(repository, authDataValidator);

View File

@@ -1,19 +1,19 @@
using Microsoft.EntityFrameworkCore; using Infrastructure.Database;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Diagnostics;
using DbContext = Infrastructure.Database.DbContext;
namespace VisaApi.Tests.Infrastructure.Database; namespace VisaApi.Tests.Infrastructure.Database;
public static class InMemoryContextProvider public static class InMemoryContextProvider
{ {
private static DbContextOptions<DbContext> opts = new DbContextOptionsBuilder<DbContext>() private static DbContextOptions<DatabaseContext> opts = new DbContextOptionsBuilder<DatabaseContext>()
.UseInMemoryDatabase("VisaApiDB") .UseInMemoryDatabase("VisaApiDB")
.ConfigureWarnings(b => b.Ignore(InMemoryEventId.TransactionIgnoredWarning)) .ConfigureWarnings(b => b.Ignore(InMemoryEventId.TransactionIgnoredWarning))
.Options; .Options;
public static DbContext GetDbContext() public static DatabaseContext GetDbContext()
{ {
var result = new DbContext(opts); var result = new DatabaseContext(opts);
result.Database.EnsureDeleted(); result.Database.EnsureDeleted();
result.Database.EnsureCreated(); result.Database.EnsureCreated();

View File

@@ -20,7 +20,7 @@ public class ApplicantsRepositoryTests
/// <summary> Returns <see cref="IApplicantsRepository"/> </summary> /// <summary> Returns <see cref="IApplicantsRepository"/> </summary>
/// <param name="context"> Database context </param> /// <param name="context"> Database context </param>
/// <returns>Repository</returns> /// <returns>Repository</returns>
private static IApplicantsRepository GetRepository(DbContext context) private static IApplicantsRepository GetRepository(DatabaseContext context)
=> new ApplicantsRepository(context, context); => new ApplicantsRepository(context, context);
/// <summary> Returns <see cref="IDateTimeProvider"/> </summary> /// <summary> Returns <see cref="IDateTimeProvider"/> </summary>

View File

@@ -13,7 +13,7 @@ public class GenericRepositoryTests
/// <summary> Returns <see cref="GenericRepository{T}"/> </summary> /// <summary> Returns <see cref="GenericRepository{T}"/> </summary>
/// <param name="context"> Database context </param> /// <param name="context"> Database context </param>
/// <returns>Repository</returns> /// <returns>Repository</returns>
private static GenericRepository<User> GetRepository(DbContext context) => new TestGenericRepository(context, context); private static GenericRepository<User> GetRepository(DatabaseContext context) => new TestGenericRepository(context, context);
/// <summary> Test for <see cref="GenericRepository{T}.GetAllAsync"/> method that should return empty collection if nothing added </summary> /// <summary> Test for <see cref="GenericRepository{T}.GetAllAsync"/> method that should return empty collection if nothing added </summary>
[Fact] [Fact]

View File

@@ -17,7 +17,7 @@ public class UsersRepositoryTests
/// <summary> Returns <see cref="IVisaApplicationsRepository"/> </summary> /// <summary> Returns <see cref="IVisaApplicationsRepository"/> </summary>
/// <param name="context"> Database context </param> /// <param name="context"> Database context </param>
/// <returns>Repository</returns> /// <returns>Repository</returns>
private static IUsersRepository GetRepository(DbContext context) private static IUsersRepository GetRepository(DatabaseContext context)
=> new UsersRepository(context, context); => new UsersRepository(context, context);
/// <summary> /// <summary>

View File

@@ -23,7 +23,7 @@ public class VisaApplicationsRepositoryTests
/// <summary> Returns <see cref="IVisaApplicationsRepository"/> </summary> /// <summary> Returns <see cref="IVisaApplicationsRepository"/> </summary>
/// <param name="context"> Database context </param> /// <param name="context"> Database context </param>
/// <returns>Repository</returns> /// <returns>Repository</returns>
private static IVisaApplicationsRepository GetRepository(DbContext context) private static IVisaApplicationsRepository GetRepository(DatabaseContext context)
=> new VisaApplicationsRepository(context, context); => new VisaApplicationsRepository(context, context);
/// <summary> Returns <see cref="IDateTimeProvider"/> </summary> /// <summary> Returns <see cref="IDateTimeProvider"/> </summary>

View File

@@ -13,7 +13,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Bogus" Version="35.6.1" /> <PackageReference Include="Bogus" Version="35.6.1" />
<PackageReference Include="FluentAssertions" Version="6.12.1" /> <PackageReference Include="FluentAssertions" Version="6.12.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.8" /> <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0"/> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0"/>
<PackageReference Include="xunit" Version="2.4.2"/> <PackageReference Include="xunit" Version="2.4.2"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">