diff --git a/CarService/CarServiceBusinessLogic/BusinessLogics/WorkerLogic.cs b/CarService/CarServiceBusinessLogic/BusinessLogics/WorkerLogic.cs index a40a72c..82636e7 100644 --- a/CarService/CarServiceBusinessLogic/BusinessLogics/WorkerLogic.cs +++ b/CarService/CarServiceBusinessLogic/BusinessLogics/WorkerLogic.cs @@ -10,16 +10,16 @@ namespace CarServiceBusinessLogic.BusinessLogics public class WorkerLogic : IWorkerLogic { private readonly ILogger _logger; - private readonly IWorkerStorage _customerStorage; - public WorkerLogic(ILogger logger, IWorkerStorage customerStorage) + private readonly IWorkerStorage _workerStorage; + public WorkerLogic(ILogger logger, IWorkerStorage workerStorage) { _logger = logger; - _customerStorage = customerStorage; + _workerStorage = workerStorage; } public List? 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; diff --git a/CarService/CarServiceDatabase/CarServiceDatabase.csproj b/CarService/CarServiceDatabase/CarServiceDatabase.csproj index 54ca861..d2d2939 100644 --- a/CarService/CarServiceDatabase/CarServiceDatabase.csproj +++ b/CarService/CarServiceDatabase/CarServiceDatabase.csproj @@ -16,7 +16,6 @@ - diff --git a/CarService/CarServiceDatabase/Implements/WorkerStorage.cs b/CarService/CarServiceDatabase/Implements/WorkerStorage.cs new file mode 100644 index 0000000..5e734b5 --- /dev/null +++ b/CarService/CarServiceDatabase/Implements/WorkerStorage.cs @@ -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 GetFullList() + { + using var context = new CarServiceDbContext(); + return context.Workers.Select(x => x.GetViewModel).ToList(); + } + public List 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(); + } + } +} diff --git a/CarService/CarServiceDatabase/Migrations/20230402115927_InitMigration.Designer.cs b/CarService/CarServiceDatabase/Migrations/20230404184042_InitMigration.Designer.cs similarity index 94% rename from CarService/CarServiceDatabase/Migrations/20230402115927_InitMigration.Designer.cs rename to CarService/CarServiceDatabase/Migrations/20230404184042_InitMigration.Designer.cs index dc298fd..2c22dcc 100644 --- a/CarService/CarServiceDatabase/Migrations/20230402115927_InitMigration.Designer.cs +++ b/CarService/CarServiceDatabase/Migrations/20230404184042_InitMigration.Designer.cs @@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace CarServiceDatabase.Migrations { [DbContext(typeof(CarServiceDbContext))] - [Migration("20230402115927_InitMigration")] + [Migration("20230404184042_InitMigration")] partial class InitMigration { /// @@ -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 => diff --git a/CarService/CarServiceDatabase/Migrations/20230402115927_InitMigration.cs b/CarService/CarServiceDatabase/Migrations/20230404184042_InitMigration.cs similarity index 100% rename from CarService/CarServiceDatabase/Migrations/20230402115927_InitMigration.cs rename to CarService/CarServiceDatabase/Migrations/20230404184042_InitMigration.cs diff --git a/CarService/CarServiceDatabase/Migrations/CarServiceDbContextModelSnapshot.cs b/CarService/CarServiceDatabase/Migrations/CarServiceDbContextModelSnapshot.cs index eb61091..3dcb2d0 100644 --- a/CarService/CarServiceDatabase/Migrations/CarServiceDbContextModelSnapshot.cs +++ b/CarService/CarServiceDatabase/Migrations/CarServiceDbContextModelSnapshot.cs @@ -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 => diff --git a/CarService/CarServiceDatabase/Models/Item.cs b/CarService/CarServiceDatabase/Models/Item.cs index 4108142..51956bb 100644 --- a/CarService/CarServiceDatabase/Models/Item.cs +++ b/CarService/CarServiceDatabase/Models/Item.cs @@ -22,6 +22,7 @@ namespace CarServiceDatabase.Models /// [ForeignKey("ItemId")] public virtual List ItemsForRepair { get; set; } = new(); + public virtual Worker Worker { get; set; } = new(); public static Item? Create(ItemBindingModel? model) { if (model == null) diff --git a/CarService/CarServiceDatabase/Models/ItemForRepair.cs b/CarService/CarServiceDatabase/Models/ItemForRepair.cs index 7c6ba03..f4b0417 100644 --- a/CarService/CarServiceDatabase/Models/ItemForRepair.cs +++ b/CarService/CarServiceDatabase/Models/ItemForRepair.cs @@ -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) diff --git a/CarService/CarServiceDatabase/Models/RepairRequest.cs b/CarService/CarServiceDatabase/Models/RepairRequest.cs index 8b441be..d0e68b7 100644 --- a/CarService/CarServiceDatabase/Models/RepairRequest.cs +++ b/CarService/CarServiceDatabase/Models/RepairRequest.cs @@ -23,6 +23,7 @@ namespace CarServiceDatabase.Models /// [ForeignKey("RepairRequestId")] public virtual List ItemsForRepair { get; set; } = new(); + public virtual Vehicle Vehicle { get; set; } = new(); public static RepairRequest? Create(RepairRequestBindingModel? model) { if (model == null) diff --git a/CarService/CarServiceDatabase/Models/Vehicle.cs b/CarService/CarServiceDatabase/Models/Vehicle.cs index 099c02a..a9694be 100644 --- a/CarService/CarServiceDatabase/Models/Vehicle.cs +++ b/CarService/CarServiceDatabase/Models/Vehicle.cs @@ -20,6 +20,7 @@ namespace CarServiceDatabase.Models /// [ForeignKey("VehicleId")] public virtual List RepairRequests { get; set; } = new(); + public virtual Customer Customer { get; set; } = new(); public static Vehicle? Create(VehicleBindingModel? model) { if (model == null) diff --git a/CarService/CarServiceDatabase/Models/Work.cs b/CarService/CarServiceDatabase/Models/Work.cs index 0e2966e..4bd8c70 100644 --- a/CarService/CarServiceDatabase/Models/Work.cs +++ b/CarService/CarServiceDatabase/Models/Work.cs @@ -22,6 +22,7 @@ namespace CarServiceDatabase.Models /// [ForeignKey("WorkId")] public virtual List WorksInRequest { get; set; } = new(); + public virtual Worker Worker { get; set; } = new(); public static Work? Create(WorkBindingModel? model) { if (model == null) diff --git a/CarService/CarServiceDatabase/Models/WorkInRequest.cs b/CarService/CarServiceDatabase/Models/WorkInRequest.cs index 9fb830a..627fd0e 100644 --- a/CarService/CarServiceDatabase/Models/WorkInRequest.cs +++ b/CarService/CarServiceDatabase/Models/WorkInRequest.cs @@ -22,6 +22,8 @@ namespace CarServiceDatabase.Models /// [ForeignKey("WorkInRequestId")] public virtual List 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) diff --git a/CarService/CarServiceDatabase/Models/WorkPayment.cs b/CarService/CarServiceDatabase/Models/WorkPayment.cs index b4b6a80..1d0ee23 100644 --- a/CarService/CarServiceDatabase/Models/WorkPayment.cs +++ b/CarService/CarServiceDatabase/Models/WorkPayment.cs @@ -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) diff --git a/CarService/CarServiceView/CarServiceView.csproj b/CarService/CarServiceView/CarServiceView.csproj index 085bb98..66aaf25 100644 --- a/CarService/CarServiceView/CarServiceView.csproj +++ b/CarService/CarServiceView/CarServiceView.csproj @@ -23,9 +23,11 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/CarService/CarServiceView/FormRegistrationWorker.Designer.cs b/CarService/CarServiceView/FormRegistrationWorker.Designer.cs new file mode 100644 index 0000000..b1edcad --- /dev/null +++ b/CarService/CarServiceView/FormRegistrationWorker.Designer.cs @@ -0,0 +1,173 @@ +namespace CarServiceView +{ + partial class FormRegistrationWorker + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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; + } +} \ No newline at end of file diff --git a/CarService/CarServiceView/FormRegistrationWorker.cs b/CarService/CarServiceView/FormRegistrationWorker.cs new file mode 100644 index 0000000..2ca35f1 --- /dev/null +++ b/CarService/CarServiceView/FormRegistrationWorker.cs @@ -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 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 + }); + } + } +} diff --git a/CarService/CarServiceView/FormRegistrationWorker.resx b/CarService/CarServiceView/FormRegistrationWorker.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/CarService/CarServiceView/FormRegistrationWorker.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/CarService/CarServiceView/Program.cs b/CarService/CarServiceView/Program.cs index f1e742e..54ddef3 100644 --- a/CarService/CarServiceView/Program.cs +++ b/CarService/CarServiceView/Program.cs @@ -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 { - /// - /// The main entry point for the application. - /// + 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()); + } + private static void ConfigureServices(ServiceCollection services) + { + services.AddLogging(option => + { + option.SetMinimumLevel(LogLevel.Information); + option.AddNLog("nlog.config"); + }); + //services.AddTransient(); + //services.AddTransient(); + //services.AddTransient(); + //services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + + services.AddTransient(); + + services.AddTransient(); } } } \ No newline at end of file