еще ошибки

This commit is contained in:
анна 2024-04-29 20:59:06 +04:00
parent 84e7d8438d
commit 3ab1b59569
7 changed files with 11 additions and 34 deletions

View File

@ -22,26 +22,14 @@ builder.Services.AddTransient<IPurchaseStorage, PurchaseStorage>();
builder.Services.AddTransient<IClassStorage, ClassStorage>(); builder.Services.AddTransient<IClassStorage, ClassStorage>();
builder.Services.AddTransient<IPaymentStorage, PaymentStorage>(); builder.Services.AddTransient<IPaymentStorage, PaymentStorage>();
builder.Services.AddLogging(option =>
{
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile(path: "appsettings.json", optional: false, reloadOnChange: true)
.Build();
var logger = new LoggerConfiguration()
.ReadFrom.Configuration(configuration)
.CreateLogger();
option.AddSerilog(logger);
});
var app = builder.Build(); var app = builder.Build();
// Configure the HTTP request pipeline. // Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment()) if (!app.Environment.IsDevelopment())
{ {
app.UseExceptionHandler("/Error"); app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. // The default HSTS value is 30 days. You may want to change this for production scenarios
app.UseHsts(); app.UseHsts();
} }

View File

@ -20,6 +20,8 @@
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Serilog" Version="3.1.1" /> <PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="System.Text.Json" Version="6.0.0" /> <PackageReference Include="System.Text.Json" Version="6.0.0" />
</ItemGroup> </ItemGroup>

View File

@ -24,6 +24,8 @@ namespace UiversityDatabaseImplement.Implements
using var context = new UniversityDB(); using var context = new UniversityDB();
return context.Clients.FirstOrDefault(x => x.PhoneNumber.Equals(model.PhoneNumber) && (string.IsNullOrEmpty(model.Password) || x.Password.Equals(model.Password)))?.GetViewModel; return context.Clients.FirstOrDefault(x => x.PhoneNumber.Equals(model.PhoneNumber) && (string.IsNullOrEmpty(model.Password) || x.Password.Equals(model.Password)))?.GetViewModel;
} }
public ClientViewModel? Insert(ClientBindingModel model) public ClientViewModel? Insert(ClientBindingModel model)
{ {

View File

@ -13,9 +13,9 @@ namespace UniversityDatabaseImplement.Models
{ {
public int ClientId { get; private set; } public int ClientId { get; private set; }
public DateOnly DatePurchase { get; private set; } public DateOnly DatePurchase { get; private set; }
private Dictionary<int, ClassByPurchaseModel>? _cachedOperations; private Dictionary<int, ClassByPurchaseModel>? _cachedClasses;
[NotMapped] [NotMapped]
public Dictionary<int, ClassByPurchaseModel> ClassModel => _cachedOperations ??= Operations.Select (x => (ClassByPurchaseModel)x).ToDictionary(x => x.ClassId, x => x); public Dictionary<int, ClassByPurchaseModel> ClassModel => _cachedClasses ??= Class.Select(x => (ClassByPurchaseModel)x).ToDictionary(x => x.ClassId, x => x);
[NotMapped] [NotMapped]
public List<CostByPurchaseModel>? CostsModel => null; public List<CostByPurchaseModel>? CostsModel => null;
public int Id { get; private set; } public int Id { get; private set; }
@ -90,7 +90,7 @@ namespace UniversityDatabaseImplement.Models
.Select(x => x.Value).ToList() .Select(x => x.Value).ToList()
.ForEach(x => x.CountClass = newOperations[x.ClassId].CountClass); .ForEach(x => x.CountClass = newOperations[x.ClassId].CountClass);
context.SaveChanges(); context.SaveChanges();
_cachedOperations = null; _cachedClasses = null;
} }
} }
} }

View File

@ -11,12 +11,7 @@ namespace UniversityDatabaseImplement
{ {
if (optionsBuilder.IsConfigured == false) if (optionsBuilder.IsConfigured == false)
{ {
optionsBuilder.UseNpgsql(@" optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=FishFactoryDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"
Host=localhost;
Port=5432;
Database=BankFullNew;
Username=postgres;
Password=55256636a;");
} }
base.OnConfiguring(optionsBuilder); base.OnConfiguring(optionsBuilder);
} }

View File

@ -23,19 +23,7 @@ builder.Services.AddTransient<ICostStorage, CostStorage>();
builder.Services.AddTransient<IPurchaseStorage, PurchaseStorage>(); builder.Services.AddTransient<IPurchaseStorage, PurchaseStorage>();
builder.Services.AddTransient<IPaymentStorage, PaymentStorage>(); builder.Services.AddTransient<IPaymentStorage, PaymentStorage>();
builder.Services.AddLogging(option =>
{
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile(path: "appsettings.json", optional: false, reloadOnChange: true)
.Build();
var logger = new LoggerConfiguration()
.ReadFrom.Configuration(configuration)
.CreateLogger();
option.AddSerilog(logger);
});
var app = builder.Build(); var app = builder.Build();

View File

@ -20,6 +20,8 @@
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Newtonsoft.Json.Bson" Version="1.0.2" /> <PackageReference Include="Newtonsoft.Json.Bson" Version="1.0.2" />
<PackageReference Include="Serilog" Version="3.1.1" /> <PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="System.Text.Json" Version="6.0.0" /> <PackageReference Include="System.Text.Json" Version="6.0.0" />
</ItemGroup> </ItemGroup>