корректировка моделей, тест бд

This commit is contained in:
Мк Игорь 2023-04-04 22:42:28 +04:00
parent 3f55e0a509
commit 134d136cd2
18 changed files with 421 additions and 34 deletions

View File

@ -10,16 +10,16 @@ namespace CarServiceBusinessLogic.BusinessLogics
public class WorkerLogic : IWorkerLogic
{
private readonly ILogger _logger;
private readonly IWorkerStorage _customerStorage;
public WorkerLogic(ILogger<WorkerLogic> logger, IWorkerStorage customerStorage)
private readonly IWorkerStorage _workerStorage;
public WorkerLogic(ILogger<WorkerLogic> logger, IWorkerStorage workerStorage)
{
_logger = logger;
_customerStorage = customerStorage;
_workerStorage = workerStorage;
}
public List<WorkerViewModel>? ReadList(WorkerSearchModel? model)
{
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
var list = model == null ? _customerStorage.GetFullList() : _customerStorage.GetFilteredList(model);
var list = model == null ? _workerStorage.GetFullList() : _workerStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
@ -35,7 +35,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
var element = _customerStorage.GetElement(model);
var element = _workerStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
@ -47,7 +47,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
public bool Create(WorkerBindingModel model)
{
CheckModel(model);
if (_customerStorage.Insert(model) == null)
if (_workerStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
@ -57,7 +57,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
public bool Update(WorkerBindingModel model)
{
CheckModel(model);
if (_customerStorage.Update(model) == null)
if (_workerStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
@ -68,7 +68,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_customerStorage.Delete(model) == null)
if (_workerStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;

View File

@ -16,7 +16,6 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Implements\" />
<Folder Include="Migrations\" />
</ItemGroup>

View File

@ -0,0 +1,48 @@
using CarServiceContracts.BindingModels;
using CarServiceContracts.SearchModels;
using CarServiceContracts.StorageContracts;
using CarServiceContracts.ViewModels;
using CarServiceDatabase.Models;
namespace CarServiceDatabase.Implements
{
public class WorkerStorage : IWorkerStorage
{
public List<WorkerViewModel> GetFullList()
{
using var context = new CarServiceDbContext();
return context.Workers.Select(x => x.GetViewModel).ToList();
}
public List<WorkerViewModel> GetFilteredList(WorkerSearchModel model)
{
using var context = new CarServiceDbContext();
return context.Workers.Select(x => x.GetViewModel).Where(x => x.Id == model.Id).ToList();
}
public WorkerViewModel? GetElement(WorkerSearchModel model)
{
using var context = new CarServiceDbContext();
return context.Workers.FirstOrDefault(x=> x.Id == model.Id)?.GetViewModel;
}
public WorkerViewModel? Insert(WorkerBindingModel model)
{
//TODO проверка на униКАЛьность
using var context = new CarServiceDbContext();
var newWorker = Worker.Create(model);
if(newWorker != null)
{
context.Workers.Add(newWorker);
context.SaveChanges();
return newWorker.GetViewModel;
}
return null;
}
public WorkerViewModel? Update(WorkerBindingModel model)
{
throw new NotImplementedException();
}
public WorkerViewModel? Delete(WorkerBindingModel model)
{
throw new NotImplementedException();
}
}
}

View File

@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace CarServiceDatabase.Migrations
{
[DbContext(typeof(CarServiceDbContext))]
[Migration("20230402115927_InitMigration")]
[Migration("20230404184042_InitMigration")]
partial class InitMigration
{
/// <inheritdoc />
@ -269,77 +269,95 @@ namespace CarServiceDatabase.Migrations
modelBuilder.Entity("CarServiceDatabase.Models.Item", b =>
{
b.HasOne("CarServiceDatabase.Models.Worker", null)
b.HasOne("CarServiceDatabase.Models.Worker", "Worker")
.WithMany("Items")
.HasForeignKey("WorkerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Worker");
});
modelBuilder.Entity("CarServiceDatabase.Models.ItemForRepair", b =>
{
b.HasOne("CarServiceDatabase.Models.Item", null)
b.HasOne("CarServiceDatabase.Models.Item", "Item")
.WithMany("ItemsForRepair")
.HasForeignKey("ItemId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CarServiceDatabase.Models.RepairRequest", null)
b.HasOne("CarServiceDatabase.Models.RepairRequest", "RepairRequest")
.WithMany("ItemsForRepair")
.HasForeignKey("RepairRequestId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Item");
b.Navigation("RepairRequest");
});
modelBuilder.Entity("CarServiceDatabase.Models.RepairRequest", b =>
{
b.HasOne("CarServiceDatabase.Models.Vehicle", null)
b.HasOne("CarServiceDatabase.Models.Vehicle", "Vehicle")
.WithMany("RepairRequests")
.HasForeignKey("VehicleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Vehicle");
});
modelBuilder.Entity("CarServiceDatabase.Models.Vehicle", b =>
{
b.HasOne("CarServiceDatabase.Models.Customer", null)
b.HasOne("CarServiceDatabase.Models.Customer", "Customer")
.WithMany("Vehicles")
.HasForeignKey("CustomerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Customer");
});
modelBuilder.Entity("CarServiceDatabase.Models.Work", b =>
{
b.HasOne("CarServiceDatabase.Models.Worker", null)
b.HasOne("CarServiceDatabase.Models.Worker", "Worker")
.WithMany("Works")
.HasForeignKey("WorkerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Worker");
});
modelBuilder.Entity("CarServiceDatabase.Models.WorkInRequest", b =>
{
b.HasOne("CarServiceDatabase.Models.RepairRequest", null)
b.HasOne("CarServiceDatabase.Models.RepairRequest", "RepairRequest")
.WithMany("WorksInRequest")
.HasForeignKey("RepairRequestId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CarServiceDatabase.Models.Work", null)
b.HasOne("CarServiceDatabase.Models.Work", "Work")
.WithMany("WorksInRequest")
.HasForeignKey("WorkId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("RepairRequest");
b.Navigation("Work");
});
modelBuilder.Entity("CarServiceDatabase.Models.WorkPayment", b =>
{
b.HasOne("CarServiceDatabase.Models.WorkInRequest", null)
b.HasOne("CarServiceDatabase.Models.WorkInRequest", "WorkInRequest")
.WithMany("WorkPayments")
.HasForeignKey("WorkInRequestId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("WorkInRequest");
});
modelBuilder.Entity("CarServiceDatabase.Models.Customer", b =>

View File

@ -266,77 +266,95 @@ namespace CarServiceDatabase.Migrations
modelBuilder.Entity("CarServiceDatabase.Models.Item", b =>
{
b.HasOne("CarServiceDatabase.Models.Worker", null)
b.HasOne("CarServiceDatabase.Models.Worker", "Worker")
.WithMany("Items")
.HasForeignKey("WorkerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Worker");
});
modelBuilder.Entity("CarServiceDatabase.Models.ItemForRepair", b =>
{
b.HasOne("CarServiceDatabase.Models.Item", null)
b.HasOne("CarServiceDatabase.Models.Item", "Item")
.WithMany("ItemsForRepair")
.HasForeignKey("ItemId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CarServiceDatabase.Models.RepairRequest", null)
b.HasOne("CarServiceDatabase.Models.RepairRequest", "RepairRequest")
.WithMany("ItemsForRepair")
.HasForeignKey("RepairRequestId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Item");
b.Navigation("RepairRequest");
});
modelBuilder.Entity("CarServiceDatabase.Models.RepairRequest", b =>
{
b.HasOne("CarServiceDatabase.Models.Vehicle", null)
b.HasOne("CarServiceDatabase.Models.Vehicle", "Vehicle")
.WithMany("RepairRequests")
.HasForeignKey("VehicleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Vehicle");
});
modelBuilder.Entity("CarServiceDatabase.Models.Vehicle", b =>
{
b.HasOne("CarServiceDatabase.Models.Customer", null)
b.HasOne("CarServiceDatabase.Models.Customer", "Customer")
.WithMany("Vehicles")
.HasForeignKey("CustomerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Customer");
});
modelBuilder.Entity("CarServiceDatabase.Models.Work", b =>
{
b.HasOne("CarServiceDatabase.Models.Worker", null)
b.HasOne("CarServiceDatabase.Models.Worker", "Worker")
.WithMany("Works")
.HasForeignKey("WorkerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Worker");
});
modelBuilder.Entity("CarServiceDatabase.Models.WorkInRequest", b =>
{
b.HasOne("CarServiceDatabase.Models.RepairRequest", null)
b.HasOne("CarServiceDatabase.Models.RepairRequest", "RepairRequest")
.WithMany("WorksInRequest")
.HasForeignKey("RepairRequestId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CarServiceDatabase.Models.Work", null)
b.HasOne("CarServiceDatabase.Models.Work", "Work")
.WithMany("WorksInRequest")
.HasForeignKey("WorkId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("RepairRequest");
b.Navigation("Work");
});
modelBuilder.Entity("CarServiceDatabase.Models.WorkPayment", b =>
{
b.HasOne("CarServiceDatabase.Models.WorkInRequest", null)
b.HasOne("CarServiceDatabase.Models.WorkInRequest", "WorkInRequest")
.WithMany("WorkPayments")
.HasForeignKey("WorkInRequestId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("WorkInRequest");
});
modelBuilder.Entity("CarServiceDatabase.Models.Customer", b =>

View File

@ -22,6 +22,7 @@ namespace CarServiceDatabase.Models
/// </summary>
[ForeignKey("ItemId")]
public virtual List<ItemForRepair> ItemsForRepair { get; set; } = new();
public virtual Worker Worker { get; set; } = new();
public static Item? Create(ItemBindingModel? model)
{
if (model == null)

View File

@ -14,6 +14,8 @@ namespace CarServiceDatabase.Models
public int ItemId { get; private set; }
[Required]
public int RepairRequestId { get; private set; }
public virtual Item Item { get; set; } = new();
public virtual RepairRequest RepairRequest { get; set; } = new();
public static ItemForRepair? Create(ItemForRepairBindingModel? model)
{
if (model == null)

View File

@ -23,6 +23,7 @@ namespace CarServiceDatabase.Models
/// </summary>
[ForeignKey("RepairRequestId")]
public virtual List<ItemForRepair> ItemsForRepair { get; set; } = new();
public virtual Vehicle Vehicle { get; set; } = new();
public static RepairRequest? Create(RepairRequestBindingModel? model)
{
if (model == null)

View File

@ -20,6 +20,7 @@ namespace CarServiceDatabase.Models
/// </summary>
[ForeignKey("VehicleId")]
public virtual List<RepairRequest> RepairRequests { get; set; } = new();
public virtual Customer Customer { get; set; } = new();
public static Vehicle? Create(VehicleBindingModel? model)
{
if (model == null)

View File

@ -22,6 +22,7 @@ namespace CarServiceDatabase.Models
/// </summary>
[ForeignKey("WorkId")]
public virtual List<WorkInRequest> WorksInRequest { get; set; } = new();
public virtual Worker Worker { get; set; } = new();
public static Work? Create(WorkBindingModel? model)
{
if (model == null)

View File

@ -22,6 +22,8 @@ namespace CarServiceDatabase.Models
/// </summary>
[ForeignKey("WorkInRequestId")]
public virtual List<WorkPayment> WorkPayments { get; set; } = new();
public virtual RepairRequest RepairRequest { get; set; } = new();
public virtual Work Work { get; set; } = new();
public static WorkInRequest? Create(WorkInRequestBindingModel? model)
{
if (model == null)

View File

@ -16,6 +16,7 @@ namespace CarServiceDatabase.Models
public decimal Sum { get; private set; }
[Required]
public int WorkInRequestId { get; private set; }
public virtual WorkInRequest WorkInRequest { get; set; } = new();
public static WorkPayment? Create(WorkPaymentBindingModel? model)
{
if (model == null)

View File

@ -23,9 +23,11 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CarServiceBusinessLogic\CarServiceBusinessLogic.csproj" />
<ProjectReference Include="..\CarServiceDatabase\CarServiceDatabase.csproj" />
</ItemGroup>

View File

@ -0,0 +1,173 @@
namespace CarServiceView
{
partial class FormRegistrationWorker
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.textBoxLogin = new System.Windows.Forms.TextBox();
this.textBoxPassword = new System.Windows.Forms.TextBox();
this.textBoxName = new System.Windows.Forms.TextBox();
this.textBoxSurname = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.buttonRegister = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonAuthorize = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// textBoxLogin
//
this.textBoxLogin.Location = new System.Drawing.Point(121, 47);
this.textBoxLogin.Name = "textBoxLogin";
this.textBoxLogin.Size = new System.Drawing.Size(100, 23);
this.textBoxLogin.TabIndex = 0;
//
// textBoxPassword
//
this.textBoxPassword.Location = new System.Drawing.Point(121, 76);
this.textBoxPassword.Name = "textBoxPassword";
this.textBoxPassword.Size = new System.Drawing.Size(100, 23);
this.textBoxPassword.TabIndex = 0;
//
// textBoxName
//
this.textBoxName.Location = new System.Drawing.Point(121, 105);
this.textBoxName.Name = "textBoxName";
this.textBoxName.Size = new System.Drawing.Size(100, 23);
this.textBoxName.TabIndex = 0;
//
// textBoxSurname
//
this.textBoxSurname.Location = new System.Drawing.Point(121, 134);
this.textBoxSurname.Name = "textBoxSurname";
this.textBoxSurname.Size = new System.Drawing.Size(100, 23);
this.textBoxSurname.TabIndex = 0;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(32, 50);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(41, 15);
this.label1.TabIndex = 1;
this.label1.Text = "Логин";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(32, 79);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(49, 15);
this.label2.TabIndex = 1;
this.label2.Text = "Пароль";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(32, 108);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(31, 15);
this.label3.TabIndex = 1;
this.label3.Text = "Имя";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(32, 137);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(58, 15);
this.label4.TabIndex = 1;
this.label4.Text = "Фамилия";
//
// buttonRegister
//
this.buttonRegister.Location = new System.Drawing.Point(32, 176);
this.buttonRegister.Name = "buttonRegister";
this.buttonRegister.Size = new System.Drawing.Size(131, 23);
this.buttonRegister.TabIndex = 2;
this.buttonRegister.Text = "Зарегистрироваться";
this.buttonRegister.UseVisualStyleBackColor = true;
this.buttonRegister.Click += new System.EventHandler(this.buttonRegister_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(209, 176);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(131, 23);
this.buttonCancel.TabIndex = 2;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
//
// buttonAuthorize
//
this.buttonAuthorize.Location = new System.Drawing.Point(227, 47);
this.buttonAuthorize.Name = "buttonAuthorize";
this.buttonAuthorize.Size = new System.Drawing.Size(113, 110);
this.buttonAuthorize.TabIndex = 3;
this.buttonAuthorize.Text = "Авторизоваться";
this.buttonAuthorize.UseVisualStyleBackColor = true;
//
// FormRegistrationWorker
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(394, 243);
this.Controls.Add(this.buttonAuthorize);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonRegister);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBoxSurname);
this.Controls.Add(this.textBoxName);
this.Controls.Add(this.textBoxPassword);
this.Controls.Add(this.textBoxLogin);
this.Name = "FormRegistrationWorker";
this.Text = "FormRegistrationWorker";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private TextBox textBoxLogin;
private TextBox textBoxPassword;
private TextBox textBoxName;
private TextBox textBoxSurname;
private Label label1;
private Label label2;
private Label label3;
private Label label4;
private Button buttonRegister;
private Button buttonCancel;
private Button buttonAuthorize;
}
}

View File

@ -0,0 +1,27 @@
using CarServiceContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
namespace CarServiceView
{
public partial class FormRegistrationWorker : Form
{
private readonly ILogger _logger;
private readonly IWorkerLogic _workerLogic;
public FormRegistrationWorker(ILogger<FormRegistrationWorker> logger, IWorkerLogic workerLogic)
{
_logger = logger;
_workerLogic = workerLogic;
InitializeComponent();
}
private void buttonRegister_Click(object sender, EventArgs e)
{
_workerLogic.Create(new()
{
Login = textBoxLogin.Text,
Password = textBoxPassword.Text,
Name = textBoxName.Text,
Surname= textBoxSurname.Text
});
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,17 +1,50 @@
using CarServiceBusinessLogic.BusinessLogics;
using CarServiceContracts.BusinessLogicsContracts;
using CarServiceContracts.StorageContracts;
using CarServiceDatabase.Implements;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
namespace CarServiceView
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run();
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<FormRegistrationWorker>());
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
//services.AddTransient<IComponentStorage, ComponentStorage>();
//services.AddTransient<IOrderStorage, OrderStorage>();
//services.AddTransient<IManufactureStorage, ManufactureStorage>();
//services.AddTransient<IClientStorage, ClientStorage>();
services.AddTransient<ICustomerLogic, CustomerLogic>();
services.AddTransient<IItemForRepairLogic, ItemForRepairLogic>();
services.AddTransient<IItemLogic, ItemLogic>();
services.AddTransient<IRepairRequestLogic, RepairRequestLogic>();
services.AddTransient<IVehicleLogic, VehicleLogic>();
services.AddTransient<IWorkerLogic, WorkerLogic>();
services.AddTransient<IWorkInRequestLogic, WorkInRequestLogic>();
services.AddTransient<IWorkLogic, WorkLogic>();
services.AddTransient<IWorkPaymentLogic, WorkPaymentLogic>();
services.AddTransient<IWorkerStorage, WorkerStorage>();
services.AddTransient<FormRegistrationWorker>();
}
}
}