Добавление логики CRUD работ
This commit is contained in:
parent
1662294c85
commit
e0e54cf872
@ -10,16 +10,16 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
||||
public class WorkLogic : IWorkLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IWorkStorage _customerStorage;
|
||||
private readonly IWorkStorage _workStorage;
|
||||
public WorkLogic(ILogger<WorkLogic> logger, IWorkStorage customerStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_customerStorage = customerStorage;
|
||||
_workStorage = customerStorage;
|
||||
}
|
||||
public List<WorkViewModel>? ReadList(WorkSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||
var list = model == null ? _customerStorage.GetFullList() : _customerStorage.GetFilteredList(model);
|
||||
var list = model == null ? _workStorage.GetFullList() : _workStorage.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 = _workStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
@ -47,7 +47,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
||||
public bool Create(WorkBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_customerStorage.Insert(model) == null)
|
||||
if (_workStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
@ -57,7 +57,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
||||
public bool Update(WorkBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_customerStorage.Update(model) == null)
|
||||
if (_workStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
@ -67,8 +67,8 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
||||
public bool Delete(WorkBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_customerStorage.Delete(model) == null)
|
||||
_logger.LogInformation("Delete. Id: {Id}", model.Id);
|
||||
if (_workStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
@ -79,12 +79,43 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
throw new ArgumentException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//Заполнено ли название?
|
||||
if (string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
_logger.LogWarning("Work name is empty");
|
||||
throw new ArgumentException("Не введено название");
|
||||
}
|
||||
//Название уникально?
|
||||
var existingWork = _workStorage.GetElement(new() { Name = model.Name });
|
||||
if (existingWork != null)
|
||||
{
|
||||
_logger.LogWarning("Work name is not unique");
|
||||
throw new ArgumentException("Работа с таким названием уже есть");
|
||||
}
|
||||
//Название не больше 60 символов?
|
||||
if (model.Name.Length > 60)
|
||||
{
|
||||
_logger.LogWarning("Work name's length > 60");
|
||||
throw new ArgumentException("Не введено название");
|
||||
}
|
||||
//Цена больше 0?
|
||||
if (model.Price <= 0)
|
||||
{
|
||||
_logger.LogWarning("Work Price is <= 0");
|
||||
throw new ArgumentException("Цена должна быть больше 0");
|
||||
}
|
||||
//Длительность больше 0?
|
||||
if (model.Duration <= 0)
|
||||
{
|
||||
_logger.LogWarning("Work Duration is <= 0");
|
||||
throw new ArgumentException("Длительность должна быть больше 0");
|
||||
}
|
||||
_logger.LogInformation("Work. Id: {Id}", model.Id);
|
||||
}
|
||||
}
|
||||
|
@ -3,5 +3,6 @@
|
||||
public class WorkSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -13,5 +13,7 @@ namespace CarServiceContracts.ViewModels
|
||||
[DisplayName("Длительность")]
|
||||
public decimal Duration { get; set; }
|
||||
public int WorkerId { get; set; }
|
||||
[DisplayName("Работник")]
|
||||
public string WorkerName { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
87
CarService/CarServiceDatabase/Implements/WorkStorage.cs
Normal file
87
CarService/CarServiceDatabase/Implements/WorkStorage.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using CarServiceContracts.BindingModels;
|
||||
using CarServiceContracts.SearchModels;
|
||||
using CarServiceContracts.StorageContracts;
|
||||
using CarServiceContracts.ViewModels;
|
||||
using CarServiceDatabase.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace CarServiceDatabase.Implements
|
||||
{
|
||||
public class WorkStorage : IWorkStorage
|
||||
{
|
||||
public List<WorkViewModel> GetFullList()
|
||||
{
|
||||
using var context = new CarServiceDbContext();
|
||||
return context.Works
|
||||
.Include(x => x.Worker)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<WorkViewModel> GetFilteredList(WorkSearchModel model)
|
||||
{
|
||||
using var context = new CarServiceDbContext();
|
||||
return context.Works
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Include(x => x.Worker)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public WorkViewModel? GetElement(WorkSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new CarServiceDbContext();
|
||||
if (model.Id.HasValue)//сначала ищем по Id
|
||||
{
|
||||
return context.Works
|
||||
.Include(x => x.Worker)
|
||||
.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(model.Name))//затем по названию
|
||||
{
|
||||
return context.Works
|
||||
.Include(x => x.Worker)
|
||||
.FirstOrDefault(x => x.Name == model.Name)?.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public WorkViewModel? Insert(WorkBindingModel model)
|
||||
{
|
||||
using var context = new CarServiceDbContext();
|
||||
var newWork = Work.Create(context, model);
|
||||
if (newWork != null)
|
||||
{
|
||||
context.Works.Add(newWork);
|
||||
context.SaveChanges();
|
||||
return newWork.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public WorkViewModel? Update(WorkBindingModel model)
|
||||
{
|
||||
using var context = new CarServiceDbContext();
|
||||
var work = context.Works.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (work == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
work.Update(context, model);
|
||||
context.SaveChanges();
|
||||
return work.GetViewModel;
|
||||
}
|
||||
public WorkViewModel? Delete(WorkBindingModel model)
|
||||
{
|
||||
using var context = new CarServiceDbContext();
|
||||
var work = context.Works.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (work == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Works.Remove(work);
|
||||
context.SaveChanges();
|
||||
return work.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -11,15 +11,24 @@ namespace CarServiceDatabase.Implements
|
||||
public List<WorkerViewModel> GetFullList()
|
||||
{
|
||||
using var context = new CarServiceDbContext();
|
||||
return context.Workers.Select(x => x.GetViewModel).ToList();
|
||||
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();
|
||||
return context.Workers
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public WorkerViewModel? GetElement(WorkerSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new CarServiceDbContext();
|
||||
if (model.Id.HasValue)//Сначала ищем по Id
|
||||
{
|
||||
@ -27,11 +36,13 @@ namespace CarServiceDatabase.Implements
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(model.Login) && string.IsNullOrEmpty(model.Password))//Затем по логину (для проверки уникальности)
|
||||
{
|
||||
return context.Workers.FirstOrDefault(x => x.Login == model.Login)?.GetViewModel;
|
||||
return context.Workers
|
||||
.FirstOrDefault(x => x.Login == model.Login)?.GetViewModel;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(model.Login) && !string.IsNullOrEmpty(model.Password))//Затем по логину и паролю (для входа)
|
||||
{
|
||||
return context.Workers.FirstOrDefault(x => x.Login == model.Login && x.Password == model.Password)?.GetViewModel;
|
||||
return context.Workers
|
||||
.FirstOrDefault(x => x.Login == model.Login && x.Password == model.Password)?.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -50,7 +61,8 @@ namespace CarServiceDatabase.Implements
|
||||
public WorkerViewModel? Update(WorkerBindingModel model)
|
||||
{
|
||||
using var context = new CarServiceDbContext();
|
||||
var worker = context.Workers.FirstOrDefault(x => x.Id == model.Id);
|
||||
var worker = context.Workers
|
||||
.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (worker == null)
|
||||
{
|
||||
return null;
|
||||
@ -62,7 +74,8 @@ namespace CarServiceDatabase.Implements
|
||||
public WorkerViewModel? Delete(WorkerBindingModel model)
|
||||
{
|
||||
using var context = new CarServiceDbContext();
|
||||
var worker = context.Workers.FirstOrDefault(x => x.Id == model.Id);
|
||||
var worker = context.Workers
|
||||
.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (worker == null)
|
||||
{
|
||||
return null;
|
||||
|
@ -23,7 +23,7 @@ namespace CarServiceDatabase.Models
|
||||
[ForeignKey("WorkId")]
|
||||
public virtual List<WorkInRequest> WorksInRequest { get; set; } = new();
|
||||
public virtual Worker Worker { get; set; } = new();
|
||||
public static Work? Create(WorkBindingModel? model)
|
||||
public static Work? Create(CarServiceDbContext context, WorkBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -35,10 +35,10 @@ namespace CarServiceDatabase.Models
|
||||
Name = model.Name,
|
||||
Price = model.Price,
|
||||
Duration = model.Duration,
|
||||
WorkerId = model.WorkerId
|
||||
Worker = context.Workers.First(x => x.Id == model.WorkerId)
|
||||
};
|
||||
}
|
||||
public static Work Create(WorkViewModel model)
|
||||
public static Work Create(CarServiceDbContext context, WorkViewModel model)
|
||||
{
|
||||
return new()
|
||||
{
|
||||
@ -46,10 +46,10 @@ namespace CarServiceDatabase.Models
|
||||
Name = model.Name,
|
||||
Price = model.Price,
|
||||
Duration = model.Duration,
|
||||
WorkerId = model.WorkerId
|
||||
Worker = context.Workers.First(x => x.Id == model.WorkerId)
|
||||
};
|
||||
}
|
||||
public void Update(WorkBindingModel? model)
|
||||
public void Update(CarServiceDbContext context, WorkBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -59,7 +59,7 @@ namespace CarServiceDatabase.Models
|
||||
Name = model.Name;
|
||||
Price = model.Price;
|
||||
Duration = model.Duration;
|
||||
WorkerId = model.WorkerId;
|
||||
Worker = context.Workers.First(x => x.Id == model.WorkerId);
|
||||
}
|
||||
public WorkViewModel GetViewModel => new()
|
||||
{
|
||||
@ -67,7 +67,8 @@ namespace CarServiceDatabase.Models
|
||||
Name = Name,
|
||||
Price = Price,
|
||||
Duration = Duration,
|
||||
WorkerId = WorkerId
|
||||
WorkerId = WorkerId,
|
||||
WorkerName = Worker.Name + " " + Worker.Surname
|
||||
};
|
||||
}
|
||||
}
|
||||
|
127
CarService/CarServiceView/FormAddWorkTest.Designer.cs
generated
Normal file
127
CarService/CarServiceView/FormAddWorkTest.Designer.cs
generated
Normal file
@ -0,0 +1,127 @@
|
||||
namespace CarServiceView
|
||||
{
|
||||
partial class FormAddWorkTest
|
||||
{
|
||||
/// <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.textBoxName = new System.Windows.Forms.TextBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.textBoxCost = new System.Windows.Forms.TextBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.textBoxDuration = new System.Windows.Forms.TextBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.buttonAdd = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
this.textBoxName.Location = new System.Drawing.Point(126, 16);
|
||||
this.textBoxName.Name = "textBoxName";
|
||||
this.textBoxName.Size = new System.Drawing.Size(100, 23);
|
||||
this.textBoxName.TabIndex = 0;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(30, 19);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(90, 15);
|
||||
this.label1.TabIndex = 1;
|
||||
this.label1.Text = "Наименование";
|
||||
//
|
||||
// textBoxCost
|
||||
//
|
||||
this.textBoxCost.Location = new System.Drawing.Point(126, 45);
|
||||
this.textBoxCost.Name = "textBoxCost";
|
||||
this.textBoxCost.Size = new System.Drawing.Size(100, 23);
|
||||
this.textBoxCost.TabIndex = 0;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(30, 48);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(67, 15);
|
||||
this.label2.TabIndex = 1;
|
||||
this.label2.Text = "Стоимость";
|
||||
//
|
||||
// textBoxDuration
|
||||
//
|
||||
this.textBoxDuration.Location = new System.Drawing.Point(126, 74);
|
||||
this.textBoxDuration.Name = "textBoxDuration";
|
||||
this.textBoxDuration.Size = new System.Drawing.Size(100, 23);
|
||||
this.textBoxDuration.TabIndex = 0;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(30, 77);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(84, 15);
|
||||
this.label3.TabIndex = 1;
|
||||
this.label3.Text = "Длительность";
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
this.buttonAdd.Location = new System.Drawing.Point(54, 135);
|
||||
this.buttonAdd.Name = "buttonAdd";
|
||||
this.buttonAdd.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonAdd.TabIndex = 2;
|
||||
this.buttonAdd.Text = "Добавить";
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
||||
//
|
||||
// FormAddWorkTest
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.buttonAdd);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.textBoxDuration);
|
||||
this.Controls.Add(this.textBoxCost);
|
||||
this.Controls.Add(this.textBoxName);
|
||||
this.Name = "FormAddWorkTest";
|
||||
this.Text = "FormAddWorkTest";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TextBox textBoxName;
|
||||
private Label label1;
|
||||
private TextBox textBoxCost;
|
||||
private Label label2;
|
||||
private TextBox textBoxDuration;
|
||||
private Label label3;
|
||||
private Button buttonAdd;
|
||||
}
|
||||
}
|
33
CarService/CarServiceView/FormAddWorkTest.cs
Normal file
33
CarService/CarServiceView/FormAddWorkTest.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using CarServiceContracts.BusinessLogicsContracts;
|
||||
|
||||
namespace CarServiceView
|
||||
{
|
||||
public partial class FormAddWorkTest : Form
|
||||
{
|
||||
IWorkLogic _workLogic;
|
||||
public FormAddWorkTest(IWorkLogic workLogic)
|
||||
{
|
||||
_workLogic = workLogic;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
_workLogic.Create(new()
|
||||
{
|
||||
Name = textBoxName.Text,
|
||||
Price = Convert.ToDecimal(textBoxCost.Text),
|
||||
Duration = Convert.ToDecimal(textBoxDuration.Text),
|
||||
WorkerId = 1
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
60
CarService/CarServiceView/FormAddWorkTest.resx
Normal file
60
CarService/CarServiceView/FormAddWorkTest.resx
Normal 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>
|
108
CarService/CarServiceView/FormWorkTest.Designer.cs
generated
Normal file
108
CarService/CarServiceView/FormWorkTest.Designer.cs
generated
Normal file
@ -0,0 +1,108 @@
|
||||
namespace CarServiceView
|
||||
{
|
||||
partial class FormWorkTest
|
||||
{
|
||||
/// <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.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.menuStrip = new System.Windows.Forms.MenuStrip();
|
||||
this.addToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.updateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.menuStrip.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Location = new System.Drawing.Point(0, 27);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowTemplate.Height = 25;
|
||||
this.dataGridView.Size = new System.Drawing.Size(798, 421);
|
||||
this.dataGridView.TabIndex = 3;
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.addToolStripMenuItem,
|
||||
this.updateToolStripMenuItem,
|
||||
this.deleteToolStripMenuItem});
|
||||
this.menuStrip.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip.Name = "menuStrip";
|
||||
this.menuStrip.Size = new System.Drawing.Size(800, 24);
|
||||
this.menuStrip.TabIndex = 4;
|
||||
this.menuStrip.Text = "menuStrip1";
|
||||
//
|
||||
// addToolStripMenuItem
|
||||
//
|
||||
this.addToolStripMenuItem.Name = "addToolStripMenuItem";
|
||||
this.addToolStripMenuItem.Size = new System.Drawing.Size(71, 20);
|
||||
this.addToolStripMenuItem.Text = "Добавить";
|
||||
this.addToolStripMenuItem.Click += new System.EventHandler(this.addToolStripMenuItem_Click);
|
||||
//
|
||||
// updateToolStripMenuItem
|
||||
//
|
||||
this.updateToolStripMenuItem.Name = "updateToolStripMenuItem";
|
||||
this.updateToolStripMenuItem.Size = new System.Drawing.Size(73, 20);
|
||||
this.updateToolStripMenuItem.Text = "Изменить";
|
||||
//
|
||||
// deleteToolStripMenuItem
|
||||
//
|
||||
this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
|
||||
this.deleteToolStripMenuItem.Size = new System.Drawing.Size(63, 20);
|
||||
this.deleteToolStripMenuItem.Text = "Удалить";
|
||||
this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click);
|
||||
//
|
||||
// FormWorkTest
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.menuStrip);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Name = "FormWorkTest";
|
||||
this.Text = "FormGridViewTest";
|
||||
this.Load += new System.EventHandler(this.FormWorkTest_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.menuStrip.ResumeLayout(false);
|
||||
this.menuStrip.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private MenuStrip menuStrip;
|
||||
private ToolStripMenuItem addToolStripMenuItem;
|
||||
private ToolStripMenuItem updateToolStripMenuItem;
|
||||
private ToolStripMenuItem deleteToolStripMenuItem;
|
||||
}
|
||||
}
|
47
CarService/CarServiceView/FormWorkTest.cs
Normal file
47
CarService/CarServiceView/FormWorkTest.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using CarServiceContracts.BusinessLogicsContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CarServiceView
|
||||
{
|
||||
public partial class FormWorkTest : Form
|
||||
{
|
||||
IWorkLogic _workLogic;
|
||||
public FormWorkTest(IWorkLogic workLogic)
|
||||
{
|
||||
_workLogic = workLogic;
|
||||
InitializeComponent();
|
||||
}
|
||||
private void FormWorkTest_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
var list = _workLogic.ReadList(null);
|
||||
dataGridView.DataSource = list;
|
||||
}
|
||||
|
||||
private void addToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormAddWorkTest));
|
||||
if (service is FormAddWorkTest form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
63
CarService/CarServiceView/FormWorkTest.resx
Normal file
63
CarService/CarServiceView/FormWorkTest.resx
Normal file
@ -0,0 +1,63 @@
|
||||
<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>
|
||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
@ -19,7 +19,7 @@ namespace CarServiceView
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
Application.Run(_serviceProvider.GetRequiredService<FormRegistrationWorker>());
|
||||
Application.Run(_serviceProvider.GetRequiredService<FormWorkTest>());
|
||||
}
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
@ -43,8 +43,11 @@ namespace CarServiceView
|
||||
services.AddTransient<IWorkPaymentLogic, WorkPaymentLogic>();
|
||||
|
||||
services.AddTransient<IWorkerStorage, WorkerStorage>();
|
||||
services.AddTransient<IWorkStorage, WorkStorage>();
|
||||
|
||||
services.AddTransient<FormRegistrationWorker>();
|
||||
services.AddTransient<FormWorkTest>();
|
||||
services.AddTransient<FormAddWorkTest>();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user