зафиксировать
This commit is contained in:
parent
4e779f2b1b
commit
028fe4a232
@ -10,10 +10,12 @@ namespace BlackcmithWorkshopFileImplement
|
||||
private readonly string OrderFileName = "Order.xml";
|
||||
private readonly string ManufactureFileName = "Manufacture.xml";
|
||||
private readonly string ClientFileName = "Client.xml";
|
||||
private readonly string ImplementerFileName = "Implementer.xml";
|
||||
public List<Component> Components { get; private set; }
|
||||
public List<Order> Orders { get; private set; }
|
||||
public List<Manufacture> Manufactures { get; private set; }
|
||||
public List<Client> Clients { get; private set; }
|
||||
public List<Implementer> Implementers { get; private set; }
|
||||
public static DataFileSingleton GetInstance()
|
||||
{
|
||||
if (instance == null)
|
||||
@ -30,6 +32,8 @@ namespace BlackcmithWorkshopFileImplement
|
||||
"Orders", x => x.GetXElement);
|
||||
public void SaveClients() => SaveData(Clients, ClientFileName,
|
||||
"Clients", x => x.GetXElement);
|
||||
public void SaveImplementers() => SaveData(Implementers, ImplementerFileName,
|
||||
"Implementers", x => x.GetXElement);
|
||||
private DataFileSingleton()
|
||||
{
|
||||
Components = LoadData(ComponentFileName, "Component", x =>
|
||||
@ -40,6 +44,8 @@ namespace BlackcmithWorkshopFileImplement
|
||||
Order.Create(x)!)!;
|
||||
Clients = LoadData(ClientFileName, "Client", x =>
|
||||
Client.Create(x)!)!;
|
||||
Implementers = LoadData(ImplementerFileName, "Implementer", x =>
|
||||
Implementer.Create(x)!)!;
|
||||
}
|
||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName,
|
||||
Func<XElement, T> selectFunction)
|
||||
|
@ -0,0 +1,79 @@
|
||||
using BlackcmithWorkshopFileImplement;
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.StoragesContracts;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopFileImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopFileImplement.Implements
|
||||
{
|
||||
public class ImplementerStorage : IImplementerStorage
|
||||
{
|
||||
private readonly DataFileSingleton source;
|
||||
public ImplementerStorage()
|
||||
{
|
||||
source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
public List<ImplementerViewModel> GetFullList()
|
||||
{
|
||||
return source.Implementers
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ImplementerFIO) && string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return source.Implementers
|
||||
.Where(x => (string.IsNullOrEmpty(model.ImplementerFIO) ||
|
||||
x.ImplementerFIO.Contains(model.ImplementerFIO)) &&
|
||||
(string.IsNullOrEmpty(model.Password) || x.Password.Contains(model.Password)))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
||||
{
|
||||
return source.Implementers
|
||||
.FirstOrDefault(x => (string.IsNullOrEmpty(model.ImplementerFIO) || x.ImplementerFIO == model.ImplementerFIO) &&
|
||||
(!model.Id.HasValue || x.Id == model.Id) && (string.IsNullOrEmpty(model.Password) || x.Password == model.Password))?
|
||||
.GetViewModel;
|
||||
}
|
||||
public ImplementerViewModel? Insert(ImplementerBindingModel model)
|
||||
{
|
||||
model.Id = source.Implementers.Count > 0 ? source.Implementers.Max(x => x.Id) + 1 : 1;
|
||||
var newImplementer = Implementer.Create(model);
|
||||
if (newImplementer == null)
|
||||
return null;
|
||||
source.Implementers.Add(newImplementer);
|
||||
source.SaveImplementers();
|
||||
return newImplementer.GetViewModel;
|
||||
}
|
||||
public ImplementerViewModel? Update(ImplementerBindingModel model)
|
||||
{
|
||||
var implementer = source.Implementers.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (implementer == null)
|
||||
return null;
|
||||
implementer.Update(model);
|
||||
source.SaveImplementers();
|
||||
return implementer.GetViewModel;
|
||||
}
|
||||
public ImplementerViewModel? Delete(ImplementerBindingModel model)
|
||||
{
|
||||
var element = source.Implementers.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
source.Implementers.Remove(element);
|
||||
source.SaveImplementers();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -28,14 +28,14 @@ namespace BlacksmithWorkshopFileImplement.Implements
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
return source.Orders
|
||||
.Where(x => (
|
||||
(!model.Id.HasValue || x.Id == model.Id) &&
|
||||
(!model.DateFrom.HasValue || x.DateCreate >= model.DateFrom) &&
|
||||
(!model.DateTo.HasValue || x.DateCreate <= model.DateTo) &&
|
||||
(!model.ClientId.HasValue || x.ClientId == model.ClientId)
|
||||
)
|
||||
.Where(x =>
|
||||
(!model.Id.HasValue || x.Id == model.Id) &&
|
||||
(!model.DateFrom.HasValue || x.DateCreate >= model.DateFrom) &&
|
||||
(!model.DateTo.HasValue || x.DateCreate <= model.DateTo) &&
|
||||
(!model.ClientId.HasValue || x.ClientId == model.ClientId) &&
|
||||
(!model.Status.HasValue || x.Status == model.Status)
|
||||
)
|
||||
.Select(x => AccessStorage(x.GetViewModel))
|
||||
.Select(x => AccessStorage(x.GetViewModel) ?? new())
|
||||
.ToList();
|
||||
}
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
@ -44,9 +44,12 @@ namespace BlacksmithWorkshopFileImplement.Implements
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return AccessStorage(source.Orders.FirstOrDefault(
|
||||
x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel
|
||||
);
|
||||
return AccessStorage(source.Orders
|
||||
.FirstOrDefault(
|
||||
x => (model.Id.HasValue && x.Id == model.Id) ||
|
||||
(model.ImplementerId.HasValue && model.Status.HasValue &&
|
||||
x.ImplementerId == model.ImplementerId && x.Status == model.Status))?
|
||||
.GetViewModel ?? new());
|
||||
}
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
{
|
||||
@ -85,19 +88,15 @@ namespace BlacksmithWorkshopFileImplement.Implements
|
||||
}
|
||||
public OrderViewModel? AccessStorage(OrderViewModel model)
|
||||
{
|
||||
if (model == null)
|
||||
return null;
|
||||
var manufacture = source.Manufactures.FirstOrDefault(x => x.Id == model.Id);
|
||||
var client = source.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||
var implementer = source.Implementers.FirstOrDefault(x => x.Id == model.ImplementerId);
|
||||
if (manufacture != null)
|
||||
model.ManufactureName = manufacture.ManufactureName;
|
||||
if (client != null)
|
||||
model.ClientFIO = client.ClientFIO;
|
||||
foreach (var Manufacture in source.Manufactures)
|
||||
{
|
||||
if (Manufacture.Id == model.ManufactureId)
|
||||
{
|
||||
model.ManufactureName = Manufacture.ManufactureName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (implementer != null)
|
||||
model.ImplementerFIO = implementer.ImplementerFIO;
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,76 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace BlacksmithWorkshopFileImplement.Models
|
||||
{
|
||||
public class Implementer : IImplementerModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public int Qualification { get; set; } = 0;
|
||||
public int WorkExperience { get; set; } = 0;
|
||||
public static Implementer? Create(ImplementerBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Implementer()
|
||||
{
|
||||
Id = model.Id,
|
||||
ImplementerFIO = model.ImplementerFIO,
|
||||
Password = model.Password,
|
||||
WorkExperience = model.WorkExperience,
|
||||
Qualification = model.Qualification
|
||||
};
|
||||
}
|
||||
public void Update(ImplementerBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ImplementerFIO = model.ImplementerFIO;
|
||||
Password = model.Password;
|
||||
WorkExperience = model.WorkExperience;
|
||||
Qualification = model.Qualification;
|
||||
}
|
||||
public ImplementerViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ImplementerFIO = ImplementerFIO,
|
||||
Password = Password,
|
||||
WorkExperience = WorkExperience,
|
||||
Qualification = Qualification
|
||||
};
|
||||
public static Implementer? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Implementer()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
ImplementerFIO = element.Element("ImplementerFIO")!.Value,
|
||||
Password = element.Element("Password")!.Value,
|
||||
Qualification = Convert.ToInt32(element.Element("Qualification")!.Value),
|
||||
WorkExperience = Convert.ToInt32(element.Element("WorkExperience")!.Value)
|
||||
};
|
||||
}
|
||||
public XElement GetXElement => new("Implementer",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("ImplementerFIO", ImplementerFIO),
|
||||
new XElement("Password", Password),
|
||||
new XElement("Qualification", Qualification.ToString()),
|
||||
new XElement("WorkExperience", WorkExperience.ToString()));
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ namespace BlacksmithWorkshopFileImplement.Models
|
||||
public int Id { get; private set; }
|
||||
public int ManufactureId { get; private set; }
|
||||
public int ClientId { get; private set; }
|
||||
public int? ImplementerId { get; private set; } = null;
|
||||
public int Count { get; private set; }
|
||||
public double Sum { get; private set; }
|
||||
public OrderStatus Status { get; private set; }
|
||||
@ -32,6 +33,7 @@ namespace BlacksmithWorkshopFileImplement.Models
|
||||
{
|
||||
Id = model.Id,
|
||||
ManufactureId = model.ManufactureId,
|
||||
ImplementerId = model.ImplementerId,
|
||||
ClientId = model.ClientId,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
@ -50,6 +52,7 @@ namespace BlacksmithWorkshopFileImplement.Models
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
ManufactureId = Convert.ToInt32(element.Element("ManufactureId")!.Value),
|
||||
ImplementerId = Convert.ToInt32(element.Element("ImplementerId")!.Value),
|
||||
ClientId = Convert.ToInt32(element.Element("ClientId")!.Value),
|
||||
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
||||
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
||||
@ -71,6 +74,7 @@ namespace BlacksmithWorkshopFileImplement.Models
|
||||
{
|
||||
Id = Id,
|
||||
ManufactureId = ManufactureId,
|
||||
ImplementerId = ImplementerId,
|
||||
ClientId = ClientId,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
@ -82,6 +86,7 @@ namespace BlacksmithWorkshopFileImplement.Models
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("ManufactureId", ManufactureId),
|
||||
new XElement("ClientId", ClientId),
|
||||
new XElement("ImplementerId", ImplementerId),
|
||||
new XElement("Sum", Sum.ToString()),
|
||||
new XElement("Count", Count),
|
||||
new XElement("Status", Status.ToString()),
|
||||
|
@ -21,9 +21,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlacksmithWorkshopDatabaseI
|
||||
{96E8CFC7-A9D8-438B-AE8C-184ED25D5AAC} = {96E8CFC7-A9D8-438B-AE8C-184ED25D5AAC}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlacksmithWorkshopRestApi", "BlacksmithWorkshopRestApi\BlacksmithWorkshopRestApi.csproj", "{6A862F56-2756-4A60-B0EC-3E03184D8294}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlacksmithWorkshopClientApp", "BlacksmithWorkshopClientApp\BlacksmithWorkshopClientApp.csproj", "{6D3E224A-AD63-48A8-897D-72F52BF3B62A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlacksmithWorkshopClientApp", "BlacksmithWorkshopClientApp\BlacksmithWorkshopClientApp.csproj", "{DA7AA048-D9D0-4C3C-AD3A-5540D3969809}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlacksmithWorkshopRestApi", "BlacksmithWorkshopRestApi\BlacksmithWorkshopRestApi.csproj", "{6A862F56-2756-4A60-B0EC-3E03184D8294}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -59,14 +59,14 @@ Global
|
||||
{07550D11-E516-44E1-88A4-5B21E3EE72CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{07550D11-E516-44E1-88A4-5B21E3EE72CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{07550D11-E516-44E1-88A4-5B21E3EE72CC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6D3E224A-AD63-48A8-897D-72F52BF3B62A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6D3E224A-AD63-48A8-897D-72F52BF3B62A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6D3E224A-AD63-48A8-897D-72F52BF3B62A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6D3E224A-AD63-48A8-897D-72F52BF3B62A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6A862F56-2756-4A60-B0EC-3E03184D8294}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6A862F56-2756-4A60-B0EC-3E03184D8294}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6A862F56-2756-4A60-B0EC-3E03184D8294}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6A862F56-2756-4A60-B0EC-3E03184D8294}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{DA7AA048-D9D0-4C3C-AD3A-5540D3969809}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DA7AA048-D9D0-4C3C-AD3A-5540D3969809}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DA7AA048-D9D0-4C3C-AD3A-5540D3969809}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DA7AA048-D9D0-4C3C-AD3A-5540D3969809}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -32,6 +32,9 @@
|
||||
GuidesToolStripMenuItem = new ToolStripMenuItem();
|
||||
ComponentsToolStripMenuItem = new ToolStripMenuItem();
|
||||
ManufacturesToolStripMenuItem = new ToolStripMenuItem();
|
||||
ClientsToolStripMenuItem = new ToolStripMenuItem();
|
||||
ImplementersToolStripMenuItem = new ToolStripMenuItem();
|
||||
StartWorkingToolStripMenuItem = new ToolStripMenuItem();
|
||||
ReportsToolStripMenuItem = new ToolStripMenuItem();
|
||||
ManufacturesListToolStripMenuItem = new ToolStripMenuItem();
|
||||
ManufacturesComponentsListToolStripMenuItem = new ToolStripMenuItem();
|
||||
@ -42,7 +45,6 @@
|
||||
buttonIssued = new Button();
|
||||
buttonReady = new Button();
|
||||
buttonTakeInWork = new Button();
|
||||
ClientsToolStripMenuItem = new ToolStripMenuItem();
|
||||
menuStrip.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
@ -52,13 +54,13 @@
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { GuidesToolStripMenuItem, ReportsToolStripMenuItem });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Size = new Size(1011, 24);
|
||||
menuStrip.Size = new Size(1267, 24);
|
||||
menuStrip.TabIndex = 0;
|
||||
menuStrip.Text = "Меню";
|
||||
//
|
||||
// GuidesToolStripMenuItem
|
||||
//
|
||||
GuidesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ComponentsToolStripMenuItem, ManufacturesToolStripMenuItem, ClientsToolStripMenuItem});
|
||||
GuidesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ComponentsToolStripMenuItem, ManufacturesToolStripMenuItem, ClientsToolStripMenuItem, ImplementersToolStripMenuItem, StartWorkingToolStripMenuItem });
|
||||
GuidesToolStripMenuItem.Name = "GuidesToolStripMenuItem";
|
||||
GuidesToolStripMenuItem.Size = new Size(94, 20);
|
||||
GuidesToolStripMenuItem.Text = "Справочники";
|
||||
@ -66,20 +68,41 @@
|
||||
// ComponentsToolStripMenuItem
|
||||
//
|
||||
ComponentsToolStripMenuItem.Name = "ComponentsToolStripMenuItem";
|
||||
ComponentsToolStripMenuItem.Size = new Size(198, 22);
|
||||
ComponentsToolStripMenuItem.Size = new Size(181, 22);
|
||||
ComponentsToolStripMenuItem.Text = "Компоненты";
|
||||
ComponentsToolStripMenuItem.Click += ComponentsStripMenuItem_Click;
|
||||
//
|
||||
// ManufacturesToolStripMenuItem
|
||||
//
|
||||
ManufacturesToolStripMenuItem.Name = "ManufacturesToolStripMenuItem";
|
||||
ManufacturesToolStripMenuItem.Size = new Size(198, 22);
|
||||
ManufacturesToolStripMenuItem.Size = new Size(181, 22);
|
||||
ManufacturesToolStripMenuItem.Text = "Кузнечные изделия";
|
||||
ManufacturesToolStripMenuItem.Click += ManufacturesStripMenuItem_Click;
|
||||
//
|
||||
// ClientsToolStripMenuItem
|
||||
//
|
||||
ClientsToolStripMenuItem.Name = "ClientsToolStripMenuItem";
|
||||
ClientsToolStripMenuItem.Size = new Size(181, 22);
|
||||
ClientsToolStripMenuItem.Text = "Клиенты";
|
||||
ClientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click;
|
||||
//
|
||||
// ImplementersToolStripMenuItem
|
||||
//
|
||||
ImplementersToolStripMenuItem.Name = "ImplementersToolStripMenuItem";
|
||||
ImplementersToolStripMenuItem.Size = new Size(181, 22);
|
||||
ImplementersToolStripMenuItem.Text = "Исполнители";
|
||||
ImplementersToolStripMenuItem.Click += ImplementersToolStripMenuItem_Click;
|
||||
//
|
||||
// StartWorkingToolStripMenuItem
|
||||
//
|
||||
StartWorkingToolStripMenuItem.Name = "StartWorkingToolStripMenuItem";
|
||||
StartWorkingToolStripMenuItem.Size = new Size(181, 22);
|
||||
StartWorkingToolStripMenuItem.Text = "Старт работ";
|
||||
StartWorkingToolStripMenuItem.Click += StartWorkingToolStripMenuItem_Click;
|
||||
//
|
||||
// ReportsToolStripMenuItem
|
||||
//
|
||||
ReportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ManufacturesListToolStripMenuItem, ManufacturesComponentsListToolStripMenuItem, OrdersListToolStripMenuItem});
|
||||
ReportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ManufacturesListToolStripMenuItem, ManufacturesComponentsListToolStripMenuItem, OrdersListToolStripMenuItem });
|
||||
ReportsToolStripMenuItem.Name = "ReportsToolStripMenuItem";
|
||||
ReportsToolStripMenuItem.Size = new Size(60, 20);
|
||||
ReportsToolStripMenuItem.Text = "Отчёты";
|
||||
@ -111,12 +134,12 @@
|
||||
dataGridView.Location = new Point(0, 23);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowTemplate.Height = 25;
|
||||
dataGridView.Size = new Size(847, 427);
|
||||
dataGridView.Size = new Size(1101, 427);
|
||||
dataGridView.TabIndex = 1;
|
||||
//
|
||||
// buttonCreateOrder
|
||||
//
|
||||
buttonCreateOrder.Location = new Point(853, 38);
|
||||
buttonCreateOrder.Location = new Point(1107, 27);
|
||||
buttonCreateOrder.Name = "buttonCreateOrder";
|
||||
buttonCreateOrder.Size = new Size(148, 31);
|
||||
buttonCreateOrder.TabIndex = 2;
|
||||
@ -126,7 +149,7 @@
|
||||
//
|
||||
// buttonRefresh
|
||||
//
|
||||
buttonRefresh.Location = new Point(853, 186);
|
||||
buttonRefresh.Location = new Point(1107, 175);
|
||||
buttonRefresh.Name = "buttonRefresh";
|
||||
buttonRefresh.Size = new Size(148, 31);
|
||||
buttonRefresh.TabIndex = 3;
|
||||
@ -136,7 +159,7 @@
|
||||
//
|
||||
// buttonIssued
|
||||
//
|
||||
buttonIssued.Location = new Point(853, 149);
|
||||
buttonIssued.Location = new Point(1107, 138);
|
||||
buttonIssued.Name = "buttonIssued";
|
||||
buttonIssued.Size = new Size(148, 31);
|
||||
buttonIssued.TabIndex = 4;
|
||||
@ -146,7 +169,7 @@
|
||||
//
|
||||
// buttonReady
|
||||
//
|
||||
buttonReady.Location = new Point(853, 112);
|
||||
buttonReady.Location = new Point(1107, 101);
|
||||
buttonReady.Name = "buttonReady";
|
||||
buttonReady.Size = new Size(148, 31);
|
||||
buttonReady.TabIndex = 5;
|
||||
@ -156,7 +179,7 @@
|
||||
//
|
||||
// buttonTakeInWork
|
||||
//
|
||||
buttonTakeInWork.Location = new Point(853, 75);
|
||||
buttonTakeInWork.Location = new Point(1107, 64);
|
||||
buttonTakeInWork.Name = "buttonTakeInWork";
|
||||
buttonTakeInWork.Size = new Size(148, 31);
|
||||
buttonTakeInWork.TabIndex = 6;
|
||||
@ -164,18 +187,11 @@
|
||||
buttonTakeInWork.UseVisualStyleBackColor = true;
|
||||
buttonTakeInWork.Click += TakeInWorkButton_Click;
|
||||
//
|
||||
// ClientsToolStripMenuItem
|
||||
//
|
||||
ClientsToolStripMenuItem.Name = "ClientsToolStripMenuItem";
|
||||
ClientsToolStripMenuItem.Size = new Size(198, 22);
|
||||
ClientsToolStripMenuItem.Text = "Клиенты";
|
||||
ClientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1011, 450);
|
||||
ClientSize = new Size(1267, 450);
|
||||
Controls.Add(buttonTakeInWork);
|
||||
Controls.Add(buttonReady);
|
||||
Controls.Add(buttonIssued);
|
||||
@ -212,5 +228,7 @@
|
||||
private ToolStripMenuItem ManufacturesComponentsListToolStripMenuItem;
|
||||
private ToolStripMenuItem OrdersListToolStripMenuItem;
|
||||
private ToolStripMenuItem ClientsToolStripMenuItem;
|
||||
private ToolStripMenuItem ImplementersToolStripMenuItem;
|
||||
private ToolStripMenuItem StartWorkingToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -19,12 +19,15 @@ namespace BlacksmithWorkshop
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderLogic _orderLogic;
|
||||
private readonly IReportLogic _reportLogic;
|
||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic)
|
||||
private readonly IWorkProcess _workProcess;
|
||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic,
|
||||
IReportLogic reportLogic, IWorkProcess workProcess)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_orderLogic = orderLogic;
|
||||
_reportLogic = reportLogic;
|
||||
_workProcess = workProcess;
|
||||
}
|
||||
private void ComponentsStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
@ -48,8 +51,11 @@ namespace BlacksmithWorkshop
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["ManufactureId"].Visible = false;
|
||||
dataGridView.Columns["ManufactureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["ImplementerId"].Visible = false;
|
||||
dataGridView.Columns["ClientId"].Visible = false;
|
||||
dataGridView.Columns["ManufactureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
}
|
||||
@ -93,8 +99,7 @@ namespace BlacksmithWorkshop
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id =
|
||||
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
|
||||
try
|
||||
{
|
||||
@ -204,5 +209,18 @@ namespace BlacksmithWorkshop
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void StartWorkingToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
_workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic);
|
||||
MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
private void ImplementersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(ImplementersForm));
|
||||
if (service is ImplementersForm form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
172
BlacksmithWorkshop/BlacksmithWorkshop/ImplementerForm.Designer.cs
generated
Normal file
172
BlacksmithWorkshop/BlacksmithWorkshop/ImplementerForm.Designer.cs
generated
Normal file
@ -0,0 +1,172 @@
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
|
||||
namespace BlacksmithWorkshop
|
||||
{
|
||||
partial class ImplementerForm
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
FIOTextBox = new TextBox();
|
||||
PasswordTextBox = new TextBox();
|
||||
QualificationTextBox = new TextBox();
|
||||
WorkExperienceTextBox = new TextBox();
|
||||
labelFio = new Label();
|
||||
labelPassword = new Label();
|
||||
labelQualification = new Label();
|
||||
labelExperience = new Label();
|
||||
SaveButton = new Button();
|
||||
CancelButton = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// FIOTextBox
|
||||
//
|
||||
FIOTextBox.Location = new Point(108, 14);
|
||||
FIOTextBox.Margin = new Padding(3, 2, 3, 2);
|
||||
FIOTextBox.Name = "FIOTextBox";
|
||||
FIOTextBox.Size = new Size(360, 23);
|
||||
FIOTextBox.TabIndex = 0;
|
||||
//
|
||||
// PasswordTextBox
|
||||
//
|
||||
PasswordTextBox.Location = new Point(108, 39);
|
||||
PasswordTextBox.Margin = new Padding(3, 2, 3, 2);
|
||||
PasswordTextBox.Name = "PasswordTextBox";
|
||||
PasswordTextBox.Size = new Size(360, 23);
|
||||
PasswordTextBox.TabIndex = 1;
|
||||
//
|
||||
// QualificationTextBox
|
||||
//
|
||||
QualificationTextBox.Location = new Point(108, 64);
|
||||
QualificationTextBox.Margin = new Padding(3, 2, 3, 2);
|
||||
QualificationTextBox.Name = "QualificationTextBox";
|
||||
QualificationTextBox.Size = new Size(360, 23);
|
||||
QualificationTextBox.TabIndex = 2;
|
||||
//
|
||||
// WorkExperienceTextBox
|
||||
//
|
||||
WorkExperienceTextBox.Location = new Point(108, 88);
|
||||
WorkExperienceTextBox.Margin = new Padding(3, 2, 3, 2);
|
||||
WorkExperienceTextBox.Name = "WorkExperienceTextBox";
|
||||
WorkExperienceTextBox.Size = new Size(360, 23);
|
||||
WorkExperienceTextBox.TabIndex = 3;
|
||||
//
|
||||
// labelFio
|
||||
//
|
||||
labelFio.AutoSize = true;
|
||||
labelFio.Location = new Point(8, 14);
|
||||
labelFio.Name = "labelFio";
|
||||
labelFio.Size = new Size(34, 15);
|
||||
labelFio.TabIndex = 4;
|
||||
labelFio.Text = "ФИО";
|
||||
//
|
||||
// labelPassword
|
||||
//
|
||||
labelPassword.AutoSize = true;
|
||||
labelPassword.Location = new Point(8, 39);
|
||||
labelPassword.Name = "labelPassword";
|
||||
labelPassword.Size = new Size(49, 15);
|
||||
labelPassword.TabIndex = 5;
|
||||
labelPassword.Text = "Пароль";
|
||||
//
|
||||
// labelQualification
|
||||
//
|
||||
labelQualification.AutoSize = true;
|
||||
labelQualification.Location = new Point(8, 64);
|
||||
labelQualification.Name = "labelQualification";
|
||||
labelQualification.Size = new Size(88, 15);
|
||||
labelQualification.TabIndex = 6;
|
||||
labelQualification.Text = "Квалификация";
|
||||
//
|
||||
// labelExperience
|
||||
//
|
||||
labelExperience.AutoSize = true;
|
||||
labelExperience.Location = new Point(8, 88);
|
||||
labelExperience.Name = "labelExperience";
|
||||
labelExperience.Size = new Size(79, 15);
|
||||
labelExperience.TabIndex = 7;
|
||||
labelExperience.Text = "Стаж работы";
|
||||
//
|
||||
// SaveButton
|
||||
//
|
||||
SaveButton.Location = new Point(298, 113);
|
||||
SaveButton.Margin = new Padding(3, 2, 3, 2);
|
||||
SaveButton.Name = "SaveButton";
|
||||
SaveButton.Size = new Size(82, 22);
|
||||
SaveButton.TabIndex = 8;
|
||||
SaveButton.Text = "Сохранить";
|
||||
SaveButton.UseVisualStyleBackColor = true;
|
||||
SaveButton.Click += SaveButton_Click;
|
||||
//
|
||||
// CancelButton
|
||||
//
|
||||
CancelButton.Location = new Point(386, 113);
|
||||
CancelButton.Margin = new Padding(3, 2, 3, 2);
|
||||
CancelButton.Name = "CancelButton";
|
||||
CancelButton.Size = new Size(82, 22);
|
||||
CancelButton.TabIndex = 9;
|
||||
CancelButton.Text = "Отмена";
|
||||
CancelButton.UseVisualStyleBackColor = true;
|
||||
CancelButton.Click += CancelButton_Click;
|
||||
//
|
||||
// ImplementerForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(480, 140);
|
||||
Controls.Add(CancelButton);
|
||||
Controls.Add(SaveButton);
|
||||
Controls.Add(labelExperience);
|
||||
Controls.Add(labelQualification);
|
||||
Controls.Add(labelPassword);
|
||||
Controls.Add(labelFio);
|
||||
Controls.Add(WorkExperienceTextBox);
|
||||
Controls.Add(QualificationTextBox);
|
||||
Controls.Add(PasswordTextBox);
|
||||
Controls.Add(FIOTextBox);
|
||||
Margin = new Padding(3, 2, 3, 2);
|
||||
Name = "ImplementerForm";
|
||||
Text = "Исполнитель";
|
||||
Load += ImplementerForm_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TextBox FIOTextBox;
|
||||
private TextBox PasswordTextBox;
|
||||
private TextBox QualificationTextBox;
|
||||
private TextBox WorkExperienceTextBox;
|
||||
private Label labelFio;
|
||||
private Label labelPassword;
|
||||
private Label labelQualification;
|
||||
private Label labelExperience;
|
||||
private Button SaveButton;
|
||||
private Button CancelButton;
|
||||
}
|
||||
}
|
102
BlacksmithWorkshop/BlacksmithWorkshop/ImplementerForm.cs
Normal file
102
BlacksmithWorkshop/BlacksmithWorkshop/ImplementerForm.cs
Normal file
@ -0,0 +1,102 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
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 BlacksmithWorkshop
|
||||
{
|
||||
public partial class ImplementerForm : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IImplementerLogic _logic;
|
||||
private int? _id;
|
||||
public int Id { set { _id = value; } }
|
||||
public ImplementerForm(ILogger<ImplementerForm> logger, IImplementerLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void ImplementerForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Получение исполнителя");
|
||||
var view = _logic.ReadElement(new ImplementerSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
});
|
||||
if (view != null)
|
||||
{
|
||||
FIOTextBox.Text = view.ImplementerFIO;
|
||||
PasswordTextBox.Text = view.Password;
|
||||
QualificationTextBox.Text = view.Qualification.ToString();
|
||||
WorkExperienceTextBox.Text = view.WorkExperience.ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения исполнителя");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(FIOTextBox.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните ФИО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(PasswordTextBox.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните пароль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Сохранение компонента");
|
||||
try
|
||||
{
|
||||
var model = new ImplementerBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
ImplementerFIO = FIOTextBox.Text,
|
||||
Password = PasswordTextBox.Text,
|
||||
Qualification = Convert.ToInt32(QualificationTextBox.Text),
|
||||
WorkExperience = Convert.ToInt32(WorkExperienceTextBox.Text),
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения исполнителя");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void CancelButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
BlacksmithWorkshop/BlacksmithWorkshop/ImplementerForm.resx
Normal file
120
BlacksmithWorkshop/BlacksmithWorkshop/ImplementerForm.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<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>
|
114
BlacksmithWorkshop/BlacksmithWorkshop/ImplementersForm.Designer.cs
generated
Normal file
114
BlacksmithWorkshop/BlacksmithWorkshop/ImplementersForm.Designer.cs
generated
Normal file
@ -0,0 +1,114 @@
|
||||
namespace BlacksmithWorkshop
|
||||
{
|
||||
partial class ImplementersForm
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
dataGridView1 = new DataGridView();
|
||||
CreateButton = new Button();
|
||||
ChangeButton = new Button();
|
||||
DeleteButton = new Button();
|
||||
RefreshButton = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView1
|
||||
//
|
||||
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView1.Location = new Point(12, 12);
|
||||
dataGridView1.Name = "dataGridView1";
|
||||
dataGridView1.RowHeadersWidth = 51;
|
||||
dataGridView1.RowTemplate.Height = 29;
|
||||
dataGridView1.Size = new Size(565, 426);
|
||||
dataGridView1.TabIndex = 0;
|
||||
//
|
||||
// CreateButton
|
||||
//
|
||||
CreateButton.Location = new Point(583, 12);
|
||||
CreateButton.Name = "CreateButton";
|
||||
CreateButton.Size = new Size(205, 29);
|
||||
CreateButton.TabIndex = 1;
|
||||
CreateButton.Text = "Создать";
|
||||
CreateButton.UseVisualStyleBackColor = true;
|
||||
CreateButton.Click += CreateButton_Click;
|
||||
//
|
||||
// ChangeButton
|
||||
//
|
||||
ChangeButton.Location = new Point(583, 47);
|
||||
ChangeButton.Name = "ChangeButton";
|
||||
ChangeButton.Size = new Size(205, 29);
|
||||
ChangeButton.TabIndex = 2;
|
||||
ChangeButton.Text = "Изменить";
|
||||
ChangeButton.UseVisualStyleBackColor = true;
|
||||
ChangeButton.Click += ChangeButton_Click;
|
||||
//
|
||||
// DeleteButton
|
||||
//
|
||||
DeleteButton.Location = new Point(583, 82);
|
||||
DeleteButton.Name = "DeleteButton";
|
||||
DeleteButton.Size = new Size(205, 29);
|
||||
DeleteButton.TabIndex = 3;
|
||||
DeleteButton.Text = "Удалить";
|
||||
DeleteButton.UseVisualStyleBackColor = true;
|
||||
DeleteButton.Click += DeleteButton_Click;
|
||||
//
|
||||
// RefreshButton
|
||||
//
|
||||
RefreshButton.Location = new Point(583, 117);
|
||||
RefreshButton.Name = "RefreshButton";
|
||||
RefreshButton.Size = new Size(205, 29);
|
||||
RefreshButton.TabIndex = 4;
|
||||
RefreshButton.Text = "Обновить";
|
||||
RefreshButton.UseVisualStyleBackColor = true;
|
||||
RefreshButton.Click += RefreshButton_Click;
|
||||
//
|
||||
// ImplementersForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(RefreshButton);
|
||||
Controls.Add(DeleteButton);
|
||||
Controls.Add(ChangeButton);
|
||||
Controls.Add(CreateButton);
|
||||
Controls.Add(dataGridView1);
|
||||
Name = "ImplementersForm";
|
||||
Text = "Исполнители";
|
||||
Load += ImplementersForm_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView1;
|
||||
private Button CreateButton;
|
||||
private Button ChangeButton;
|
||||
private Button DeleteButton;
|
||||
private Button RefreshButton;
|
||||
}
|
||||
}
|
113
BlacksmithWorkshop/BlacksmithWorkshop/ImplementersForm.cs
Normal file
113
BlacksmithWorkshop/BlacksmithWorkshop/ImplementersForm.cs
Normal file
@ -0,0 +1,113 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
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 BlacksmithWorkshop
|
||||
{
|
||||
public partial class ImplementersForm : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IImplementerLogic _logic;
|
||||
public ImplementersForm(ILogger<ImplementersForm> logger, IImplementerLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
private void ImplementersForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView1.DataSource = list;
|
||||
dataGridView1.Columns["Id"].Visible = false;
|
||||
dataGridView1.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView1.Columns["Password"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView1.Columns["Qualification"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView1.Columns["WorkExperience"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка компонентов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки исполнителей");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void CreateButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(ImplementerForm));
|
||||
if (service is ImplementerForm form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ChangeButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView1.SelectedRows.Count == 1)
|
||||
{
|
||||
var service =
|
||||
Program.ServiceProvider?.GetService(typeof(ImplementerForm));
|
||||
if (service is ImplementerForm form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void DeleteButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView1.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Удаление компонента");
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new ImplementerBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления исполнителя");
|
||||
MessageBox.Show(ex.Message, "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void RefreshButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
120
BlacksmithWorkshop/BlacksmithWorkshop/ImplementersForm.resx
Normal file
120
BlacksmithWorkshop/BlacksmithWorkshop/ImplementersForm.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<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>
|
@ -48,6 +48,9 @@ namespace BlacksmithWorkshop
|
||||
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||
services.AddTransient<IClientLogic, ClientLogic>();
|
||||
services.AddTransient<IClientStorage, ClientStorage>();
|
||||
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||
services.AddTransient<IWorkProcess, WorkModeling>();
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormComponent>();
|
||||
services.AddTransient<FormComponents>();
|
||||
@ -58,6 +61,8 @@ namespace BlacksmithWorkshop
|
||||
services.AddTransient<FormReportManufacturesComponents>();
|
||||
services.AddTransient<FormReportOrders>();
|
||||
services.AddTransient<ClientsForm>();
|
||||
services.AddTransient<ImplementersForm>();
|
||||
services.AddTransient<ImplementerForm>();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,126 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.StoragesContracts;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ImplementerLogic : IImplementerLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IImplementerStorage _implementerStorage;
|
||||
public ImplementerLogic(ILogger<ImplementerLogic> logger, IImplementerStorage implementerStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_implementerStorage = implementerStorage;
|
||||
}
|
||||
public List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. ImplementerFIO:{ClientFIO}. Id:{ Id}", model?.ImplementerFIO, model?.Id);
|
||||
var list = model == null ? _implementerStorage.GetFullList() : _implementerStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public ImplementerViewModel? ReadElement(ImplementerSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. ImplementerFIO:{ImplementerFIO}.Id:{ Id}", model.ImplementerFIO, model.Id);
|
||||
var element = _implementerStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
public bool Create(ImplementerBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_implementerStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(ImplementerBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_implementerStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(ImplementerBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_implementerStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(ImplementerBindingModel model, bool withParams =
|
||||
true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.ImplementerFIO))
|
||||
{
|
||||
throw new ArgumentNullException("Нет ФИО исполнителя",
|
||||
nameof(model.ImplementerFIO));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
throw new ArgumentNullException("Нет пароля клиента",
|
||||
nameof(model.Password));
|
||||
}
|
||||
if (model.WorkExperience < 0)
|
||||
{
|
||||
throw new ArgumentNullException("Стаж меньше 0",
|
||||
nameof(model.WorkExperience));
|
||||
}
|
||||
if (model.Qualification < 0)
|
||||
{
|
||||
throw new ArgumentException("Квалификация меньше 0", nameof(model.Qualification));
|
||||
}
|
||||
_logger.LogInformation("Implementer. ImplementerFIO:{ImplementerFIO}." +
|
||||
"Password:{ Password}. WorkExperience:{ WorkExperience}. Qualification:{ Qualification}. Id: { Id} ",
|
||||
model.ImplementerFIO, model.Password, model.WorkExperience, model.Qualification, model.Id);
|
||||
var element = _implementerStorage.GetElement(new ImplementerSearchModel
|
||||
{
|
||||
ImplementerFIO = model.ImplementerFIO,
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Исполнитель с таким ФИО уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -17,13 +17,29 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogics
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
static readonly object locker = new object();
|
||||
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_orderStorage = orderStorage;
|
||||
}
|
||||
|
||||
public OrderViewModel? ReadElement(OrderSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. Id:{ Id}", model.Id);
|
||||
var element = _orderStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id:{ Id}", model?.Id);
|
||||
@ -37,7 +53,6 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogics
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool CreateOrder(OrderBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
@ -50,10 +65,9 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogics
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool ChangeStatus(OrderBindingModel model, OrderStatus status)
|
||||
{
|
||||
CheckModel(model);
|
||||
CheckModel(model, false);
|
||||
var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||
if (element == null)
|
||||
{
|
||||
@ -68,27 +82,27 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogics
|
||||
model.Status = status;
|
||||
if (model.Status == OrderStatus.Выдан)
|
||||
model.DateImplement = DateTime.Now;
|
||||
if (element.ImplementerId.HasValue)
|
||||
model.ImplementerId = element.ImplementerId;
|
||||
_orderStorage.Update(model);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool TakeOrderInWork(OrderBindingModel model)
|
||||
{
|
||||
return ChangeStatus(model, OrderStatus.Выполняется);
|
||||
lock (locker)
|
||||
{
|
||||
return ChangeStatus(model, OrderStatus.Выполняется);
|
||||
}
|
||||
}
|
||||
|
||||
public bool FinishOrder(OrderBindingModel model)
|
||||
{
|
||||
return ChangeStatus(model, OrderStatus.Готов);
|
||||
}
|
||||
|
||||
public bool DeliveryOrder(OrderBindingModel model)
|
||||
{
|
||||
return ChangeStatus(model, OrderStatus.Выдан);
|
||||
}
|
||||
|
||||
private void CheckModel(OrderBindingModel model, bool withParams =
|
||||
true)
|
||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
|
@ -0,0 +1,136 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopDataModels.Enums;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class WorkModeling : IWorkProcess
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly Random _rnd;
|
||||
private IOrderLogic? _orderLogic;
|
||||
public WorkModeling(ILogger<WorkModeling> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_rnd = new Random(1000);
|
||||
}
|
||||
public void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic)
|
||||
{
|
||||
_orderLogic = orderLogic;
|
||||
var implementers = implementerLogic.ReadList(null);
|
||||
if (implementers == null)
|
||||
{
|
||||
_logger.LogWarning("DoWork. Implementers is null");
|
||||
return;
|
||||
}
|
||||
var orders = _orderLogic.ReadList(new OrderSearchModel
|
||||
{
|
||||
Status = OrderStatus.Принят
|
||||
});
|
||||
if (orders == null || orders.Count == 0)
|
||||
{
|
||||
_logger.LogWarning("DoWork. Orders is null or empty");
|
||||
return;
|
||||
}
|
||||
_logger.LogDebug("DoWork for {Count} orders", orders.Count);
|
||||
foreach (var implementer in implementers)
|
||||
{
|
||||
Task.Run(() => WorkerWorkAsync(implementer, orders));
|
||||
}
|
||||
}
|
||||
/// Иммитация работы исполнителя
|
||||
private async Task WorkerWorkAsync(ImplementerViewModel implementer, List<OrderViewModel> orders)
|
||||
{
|
||||
if (_orderLogic == null || implementer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
await RunOrderInWork(implementer);
|
||||
await Task.Run(() =>
|
||||
{
|
||||
foreach (var order in orders)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogDebug("DoWork. Worker {Id} try get order { Order}", implementer.Id, order.Id);
|
||||
// пытаемся назначить заказ на исполнителя
|
||||
_orderLogic.TakeOrderInWork(new OrderBindingModel
|
||||
{
|
||||
Id = order.Id,
|
||||
ImplementerId = implementer.Id
|
||||
});
|
||||
// делаем работу
|
||||
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 1000) * order.Count);
|
||||
_logger.LogDebug("DoWork. Worker {Id} finish order { Order}", implementer.Id, order.Id);
|
||||
_orderLogic.FinishOrder(new OrderBindingModel
|
||||
{
|
||||
Id = order.Id
|
||||
});
|
||||
// отдыхаем
|
||||
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
||||
}
|
||||
// кто-то мог уже перехватить заказ, игнорируем ошибку
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Error try get work");
|
||||
}
|
||||
// заканчиваем выполнение имитации в случае иной ошибки
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error while do work");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
/// Ищем заказ, которые уже в работе (вдруг исполнителя прервали)
|
||||
private async Task RunOrderInWork(ImplementerViewModel implementer)
|
||||
{
|
||||
if (_orderLogic == null || implementer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var runOrder = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel
|
||||
{
|
||||
ImplementerId = implementer.Id,
|
||||
Status = OrderStatus.Выполняется
|
||||
}));
|
||||
if (runOrder == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogDebug("DoWork. Worker {Id} back to order {Order}", implementer.Id, runOrder.Id);
|
||||
// доделываем работу
|
||||
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 300) * runOrder.Count);
|
||||
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, runOrder.Id);
|
||||
_orderLogic.FinishOrder(new OrderBindingModel
|
||||
{
|
||||
Id = runOrder.Id
|
||||
});
|
||||
// отдыхаем
|
||||
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
||||
}
|
||||
// заказа может не быть, просто игнорируем ошибку
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Error try get work");
|
||||
}
|
||||
// а может возникнуть иная ошибка, тогда просто заканчиваем выполнение имитации
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error while do work");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -5,40 +5,40 @@ using Newtonsoft.Json;
|
||||
|
||||
namespace BlacksmithWorkshopClientApp
|
||||
{
|
||||
public static class APIClient
|
||||
{
|
||||
private static readonly HttpClient _client = new();
|
||||
public static ClientViewModel? Client { get; set; } = null;
|
||||
public static void Connect(IConfiguration configuration)
|
||||
{
|
||||
_client.BaseAddress = new Uri(configuration["IPAddress"]);
|
||||
_client.DefaultRequestHeaders.Accept.Clear();
|
||||
_client.DefaultRequestHeaders.Accept.Add(new
|
||||
MediaTypeWithQualityHeaderValue("application/json"));
|
||||
}
|
||||
public static T? GetRequest<T>(string requestUrl)
|
||||
{
|
||||
var response = _client.GetAsync(requestUrl);
|
||||
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||
if (response.Result.IsSuccessStatusCode)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(result);
|
||||
}
|
||||
}
|
||||
public static void PostRequest<T>(string requestUrl, T model)
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(model);
|
||||
var data = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
var response = _client.PostAsync(requestUrl, data);
|
||||
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||
if (!response.Result.IsSuccessStatusCode)
|
||||
{
|
||||
throw new Exception(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static class APIClient
|
||||
{
|
||||
private static readonly HttpClient _client = new();
|
||||
public static ClientViewModel? Client { get; set; } = null;
|
||||
public static void Connect(IConfiguration configuration)
|
||||
{
|
||||
_client.BaseAddress = new Uri(configuration["IPAddress"]);
|
||||
_client.DefaultRequestHeaders.Accept.Clear();
|
||||
_client.DefaultRequestHeaders.Accept.Add(new
|
||||
MediaTypeWithQualityHeaderValue("application/json"));
|
||||
}
|
||||
public static T? GetRequest<T>(string requestUrl)
|
||||
{
|
||||
var response = _client.GetAsync(requestUrl);
|
||||
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||
if (response.Result.IsSuccessStatusCode)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(result);
|
||||
}
|
||||
}
|
||||
public static void PostRequest<T>(string requestUrl, T model)
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(model);
|
||||
var data = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
var response = _client.PostAsync(requestUrl, data);
|
||||
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||
if (!response.Result.IsSuccessStatusCode)
|
||||
{
|
||||
throw new Exception(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BlacksmithWorkshopContracts\BlacksmithWorkshopContracts.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BlacksmithWorkshopContracts\BlacksmithWorkshopContracts.csproj" />
|
||||
<ProjectReference Include="..\BlacksmithWorkshopRestApi\BlacksmithWorkshopRestApi.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -1,4 +1,4 @@
|
||||
using BlacksmithWorkshopClientApp.Models;
|
||||
using BlacksmithWorkshopClientApp.Models;
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@ -36,12 +36,12 @@ namespace BlacksmithWorkshopClientApp.Controllers
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
throw new Exception("Âû êàê ñóäà ïîïàëè? Ñóäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
}
|
||||
if (string.IsNullOrEmpty(login) ||
|
||||
string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio))
|
||||
{
|
||||
throw new Exception("Введите логин, пароль и ФИО");
|
||||
throw new Exception("Ââåäèòå ëîãèí, ïàðîëü è ÔÈÎ");
|
||||
}
|
||||
APIClient.PostRequest("api/client/updatedata", new
|
||||
ClientBindingModel
|
||||
@ -77,12 +77,12 @@ namespace BlacksmithWorkshopClientApp.Controllers
|
||||
if (string.IsNullOrEmpty(login) ||
|
||||
string.IsNullOrEmpty(password))
|
||||
{
|
||||
throw new Exception("Введите логин и пароль");
|
||||
throw new Exception("Ââåäèòå ëîãèí è ïàðîëü");
|
||||
}
|
||||
APIClient.Client = APIClient.GetRequest<ClientViewModel>($"api/client/login?login={login}&password={password}");
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Неверный логин/пароль");
|
||||
throw new Exception("Íåâåðíûé ëîãèí/ïàðîëü");
|
||||
}
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
@ -97,7 +97,7 @@ namespace BlacksmithWorkshopClientApp.Controllers
|
||||
if (string.IsNullOrEmpty(login) ||
|
||||
string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio))
|
||||
{
|
||||
throw new Exception("Введите логин, пароль и ФИО");
|
||||
throw new Exception("Ââåäèòå ëîãèí, ïàðîëü è ÔÈÎ");
|
||||
}
|
||||
APIClient.PostRequest("api/client/register", new
|
||||
ClientBindingModel
|
||||
@ -120,11 +120,11 @@ namespace BlacksmithWorkshopClientApp.Controllers
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
throw new Exception("Âû êàê ñóäà ïîïàëè? Ñóäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
}
|
||||
if (count <= 0)
|
||||
{
|
||||
throw new Exception("Количество и сумма должны быть больше 0");
|
||||
throw new Exception("Êîëè÷åñòâî è ñóììà äîëæíû áûòü áîëüøå 0");
|
||||
}
|
||||
APIClient.PostRequest("api/main/createorder", new
|
||||
OrderBindingModel
|
||||
@ -139,7 +139,7 @@ namespace BlacksmithWorkshopClientApp.Controllers
|
||||
[HttpPost]
|
||||
public double Calc(int count, int manufacture)
|
||||
{
|
||||
var _manufacture =
|
||||
var _manufacture =
|
||||
APIClient.GetRequest<ManufactureViewModel>($"api/main/getmanufacture?manufactureid={manufacture}");
|
||||
return Math.Round(count * (_manufacture?.Price ?? 1), 2);
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
namespace BlacksmithWorkshopClientApp.Models
|
||||
{
|
||||
public class ErrorViewModel
|
||||
{
|
||||
public string? RequestId { get; set; }
|
||||
public class ErrorViewModel
|
||||
{
|
||||
public string? RequestId { get; set; }
|
||||
|
||||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||
}
|
||||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||
}
|
||||
}
|
||||
|
@ -28,4 +28,4 @@ app.MapControllerRoute(
|
||||
name: "default",
|
||||
pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||
|
||||
app.Run();
|
||||
app.Run();
|
@ -1,18 +1,28 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:31512",
|
||||
"sslPort": 44361
|
||||
"applicationUrl": "http://localhost:50843",
|
||||
"sslPort": 44319
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"BlacksmithWorkshopClientApp": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:7278;http://localhost:5081",
|
||||
"applicationUrl": "http://localhost:5083",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:7159;http://localhost:5083",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
|
@ -11,18 +11,18 @@
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Логин:</div>
|
||||
<div class="col-8"><input type="text" name="login" value="@Model.Email" /></div>
|
||||
<div class="col-8"><input type="text" name="login" value="@Model.Email"/></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Пароль:</div>
|
||||
<div class="col-8"><input type="password" name="password" value="@Model.Password" /></div>
|
||||
<div class="col-8"><input type="password" name="password" value="@Model.Password"/></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">ФИО:</div>
|
||||
<div class="col-8"><input type="text" name="fio" value="@Model.ClientFIO" /></div>
|
||||
<div class="col-8"><input type="text" name="fio" value="@Model.ClientFIO"/></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
||||
</form>
|
@ -26,4 +26,3 @@
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
|
||||
/* Please see documentation at https://learn.microsoft.com/aspnet/core/client-side/bundling-and-minification
|
||||
for details on configuring this project to bundle and minify static web assets. */
|
||||
|
||||
a.navbar-brand {
|
||||
|
@ -6,5 +6,5 @@
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"IPAddress": "http://localhost:5230/"
|
||||
}
|
||||
"IPAddress": "http://localhost:5230"
|
||||
}
|
@ -8,6 +8,10 @@ html {
|
||||
}
|
||||
}
|
||||
|
||||
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
|
||||
box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
|
||||
}
|
||||
|
||||
html {
|
||||
position: relative;
|
||||
min-height: 100%;
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
|
||||
// Please see documentation at https://learn.microsoft.com/aspnet/core/client-side/bundling-and-minification
|
||||
// for details on configuring this project to bundle and minify static web assets.
|
||||
|
||||
// Write your JavaScript code.
|
||||
|
@ -1,12 +1,23 @@
|
||||
Copyright (c) .NET Foundation. All rights reserved.
|
||||
The MIT License (MIT)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
these files except in compliance with the License. You may obtain a copy of the
|
||||
License at
|
||||
Copyright (c) .NET Foundation and Contributors
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
All rights reserved.
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software distributed
|
||||
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations under the License.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
@ -1,7 +1,10 @@
|
||||
// Unobtrusive validation support library for jQuery and jQuery Validate
|
||||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
// @version v3.2.11
|
||||
/**
|
||||
* @license
|
||||
* Unobtrusive validation support library for jQuery and jQuery Validate
|
||||
* Copyright (c) .NET Foundation. All rights reserved.
|
||||
* Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
* @version v4.0.0
|
||||
*/
|
||||
|
||||
/*jslint white: true, browser: true, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: false */
|
||||
/*global document: false, jQuery: false */
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,13 +1,5 @@
|
||||
Copyright JS Foundation and other contributors, https://js.foundation/
|
||||
|
||||
This software consists of voluntary contributions made by many
|
||||
individuals. For exact contribution history, see the revision history
|
||||
available at https://github.com/jquery/jquery
|
||||
|
||||
The following license applies to all parts of this software except as
|
||||
documented below:
|
||||
|
||||
====
|
||||
Copyright OpenJS Foundation and other contributors, https://openjsf.org/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
@ -26,11 +18,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
====
|
||||
|
||||
All files located in the node_modules and external directories are
|
||||
externally maintained libraries used by this software which have their
|
||||
own licenses; we recommend you read them, as their terms may differ from
|
||||
the terms above.
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@ -1,15 +1,15 @@
|
||||
/*!
|
||||
* jQuery JavaScript Library v3.5.1
|
||||
* jQuery JavaScript Library v3.6.0
|
||||
* https://jquery.com/
|
||||
*
|
||||
* Includes Sizzle.js
|
||||
* https://sizzlejs.com/
|
||||
*
|
||||
* Copyright JS Foundation and other contributors
|
||||
* Copyright OpenJS Foundation and other contributors
|
||||
* Released under the MIT license
|
||||
* https://jquery.org/license
|
||||
*
|
||||
* Date: 2020-05-04T22:49Z
|
||||
* Date: 2021-03-02T17:08Z
|
||||
*/
|
||||
( function( global, factory ) {
|
||||
|
||||
@ -76,12 +76,16 @@ var support = {};
|
||||
|
||||
var isFunction = function isFunction( obj ) {
|
||||
|
||||
// Support: Chrome <=57, Firefox <=52
|
||||
// In some browsers, typeof returns "function" for HTML <object> elements
|
||||
// (i.e., `typeof document.createElement( "object" ) === "function"`).
|
||||
// We don't want to classify *any* DOM node as a function.
|
||||
return typeof obj === "function" && typeof obj.nodeType !== "number";
|
||||
};
|
||||
// Support: Chrome <=57, Firefox <=52
|
||||
// In some browsers, typeof returns "function" for HTML <object> elements
|
||||
// (i.e., `typeof document.createElement( "object" ) === "function"`).
|
||||
// We don't want to classify *any* DOM node as a function.
|
||||
// Support: QtWeb <=3.8.5, WebKit <=534.34, wkhtmltopdf tool <=0.12.5
|
||||
// Plus for old WebKit, typeof returns "function" for HTML collections
|
||||
// (e.g., `typeof document.getElementsByTagName("div") === "function"`). (gh-4756)
|
||||
return typeof obj === "function" && typeof obj.nodeType !== "number" &&
|
||||
typeof obj.item !== "function";
|
||||
};
|
||||
|
||||
|
||||
var isWindow = function isWindow( obj ) {
|
||||
@ -147,7 +151,7 @@ function toType( obj ) {
|
||||
|
||||
|
||||
var
|
||||
version = "3.5.1",
|
||||
version = "3.6.0",
|
||||
|
||||
// Define a local copy of jQuery
|
||||
jQuery = function( selector, context ) {
|
||||
@ -401,7 +405,7 @@ jQuery.extend( {
|
||||
if ( isArrayLike( Object( arr ) ) ) {
|
||||
jQuery.merge( ret,
|
||||
typeof arr === "string" ?
|
||||
[ arr ] : arr
|
||||
[ arr ] : arr
|
||||
);
|
||||
} else {
|
||||
push.call( ret, arr );
|
||||
@ -496,9 +500,9 @@ if ( typeof Symbol === "function" ) {
|
||||
|
||||
// Populate the class2type map
|
||||
jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
|
||||
function( _i, name ) {
|
||||
class2type[ "[object " + name + "]" ] = name.toLowerCase();
|
||||
} );
|
||||
function( _i, name ) {
|
||||
class2type[ "[object " + name + "]" ] = name.toLowerCase();
|
||||
} );
|
||||
|
||||
function isArrayLike( obj ) {
|
||||
|
||||
@ -518,14 +522,14 @@ function isArrayLike( obj ) {
|
||||
}
|
||||
var Sizzle =
|
||||
/*!
|
||||
* Sizzle CSS Selector Engine v2.3.5
|
||||
* Sizzle CSS Selector Engine v2.3.6
|
||||
* https://sizzlejs.com/
|
||||
*
|
||||
* Copyright JS Foundation and other contributors
|
||||
* Released under the MIT license
|
||||
* https://js.foundation/
|
||||
*
|
||||
* Date: 2020-03-14
|
||||
* Date: 2021-02-16
|
||||
*/
|
||||
( function( window ) {
|
||||
var i,
|
||||
@ -1108,8 +1112,8 @@ support = Sizzle.support = {};
|
||||
* @returns {Boolean} True iff elem is a non-HTML XML node
|
||||
*/
|
||||
isXML = Sizzle.isXML = function( elem ) {
|
||||
var namespace = elem.namespaceURI,
|
||||
docElem = ( elem.ownerDocument || elem ).documentElement;
|
||||
var namespace = elem && elem.namespaceURI,
|
||||
docElem = elem && ( elem.ownerDocument || elem ).documentElement;
|
||||
|
||||
// Support: IE <=8
|
||||
// Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
|
||||
@ -3024,9 +3028,9 @@ var rneedsContext = jQuery.expr.match.needsContext;
|
||||
|
||||
function nodeName( elem, name ) {
|
||||
|
||||
return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
|
||||
return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
|
||||
|
||||
};
|
||||
}
|
||||
var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
|
||||
|
||||
|
||||
@ -3997,8 +4001,8 @@ jQuery.extend( {
|
||||
resolveContexts = Array( i ),
|
||||
resolveValues = slice.call( arguments ),
|
||||
|
||||
// the master Deferred
|
||||
master = jQuery.Deferred(),
|
||||
// the primary Deferred
|
||||
primary = jQuery.Deferred(),
|
||||
|
||||
// subordinate callback factory
|
||||
updateFunc = function( i ) {
|
||||
@ -4006,30 +4010,30 @@ jQuery.extend( {
|
||||
resolveContexts[ i ] = this;
|
||||
resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
|
||||
if ( !( --remaining ) ) {
|
||||
master.resolveWith( resolveContexts, resolveValues );
|
||||
primary.resolveWith( resolveContexts, resolveValues );
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// Single- and empty arguments are adopted like Promise.resolve
|
||||
if ( remaining <= 1 ) {
|
||||
adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
|
||||
adoptValue( singleValue, primary.done( updateFunc( i ) ).resolve, primary.reject,
|
||||
!remaining );
|
||||
|
||||
// Use .then() to unwrap secondary thenables (cf. gh-3000)
|
||||
if ( master.state() === "pending" ||
|
||||
if ( primary.state() === "pending" ||
|
||||
isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
|
||||
|
||||
return master.then();
|
||||
return primary.then();
|
||||
}
|
||||
}
|
||||
|
||||
// Multiple arguments are aggregated like Promise.all array elements
|
||||
while ( i-- ) {
|
||||
adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
|
||||
adoptValue( resolveValues[ i ], updateFunc( i ), primary.reject );
|
||||
}
|
||||
|
||||
return master.promise();
|
||||
return primary.promise();
|
||||
}
|
||||
} );
|
||||
|
||||
@ -4180,8 +4184,8 @@ var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
|
||||
for ( ; i < len; i++ ) {
|
||||
fn(
|
||||
elems[ i ], key, raw ?
|
||||
value :
|
||||
value.call( elems[ i ], i, fn( elems[ i ], key ) )
|
||||
value :
|
||||
value.call( elems[ i ], i, fn( elems[ i ], key ) )
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -5089,10 +5093,7 @@ function buildFragment( elems, context, scripts, selection, ignored ) {
|
||||
}
|
||||
|
||||
|
||||
var
|
||||
rkeyEvent = /^key/,
|
||||
rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
|
||||
rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
|
||||
var rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
|
||||
|
||||
function returnTrue() {
|
||||
return true;
|
||||
@ -5387,8 +5388,8 @@ jQuery.event = {
|
||||
event = jQuery.event.fix( nativeEvent ),
|
||||
|
||||
handlers = (
|
||||
dataPriv.get( this, "events" ) || Object.create( null )
|
||||
)[ event.type ] || [],
|
||||
dataPriv.get( this, "events" ) || Object.create( null )
|
||||
)[ event.type ] || [],
|
||||
special = jQuery.event.special[ event.type ] || {};
|
||||
|
||||
// Use the fix-ed jQuery.Event rather than the (read-only) native event
|
||||
@ -5512,12 +5513,12 @@ jQuery.event = {
|
||||
get: isFunction( hook ) ?
|
||||
function() {
|
||||
if ( this.originalEvent ) {
|
||||
return hook( this.originalEvent );
|
||||
return hook( this.originalEvent );
|
||||
}
|
||||
} :
|
||||
function() {
|
||||
if ( this.originalEvent ) {
|
||||
return this.originalEvent[ name ];
|
||||
return this.originalEvent[ name ];
|
||||
}
|
||||
},
|
||||
|
||||
@ -5656,7 +5657,13 @@ function leverageNative( el, type, expectSync ) {
|
||||
// Cancel the outer synthetic event
|
||||
event.stopImmediatePropagation();
|
||||
event.preventDefault();
|
||||
return result.value;
|
||||
|
||||
// Support: Chrome 86+
|
||||
// In Chrome, if an element having a focusout handler is blurred by
|
||||
// clicking outside of it, it invokes the handler synchronously. If
|
||||
// that handler calls `.remove()` on the element, the data is cleared,
|
||||
// leaving `result` undefined. We need to guard against this.
|
||||
return result && result.value;
|
||||
}
|
||||
|
||||
// If this is an inner synthetic event for an event with a bubbling surrogate
|
||||
@ -5821,34 +5828,7 @@ jQuery.each( {
|
||||
targetTouches: true,
|
||||
toElement: true,
|
||||
touches: true,
|
||||
|
||||
which: function( event ) {
|
||||
var button = event.button;
|
||||
|
||||
// Add which for key events
|
||||
if ( event.which == null && rkeyEvent.test( event.type ) ) {
|
||||
return event.charCode != null ? event.charCode : event.keyCode;
|
||||
}
|
||||
|
||||
// Add which for click: 1 === left; 2 === middle; 3 === right
|
||||
if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
|
||||
if ( button & 1 ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( button & 2 ) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if ( button & 4 ) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return event.which;
|
||||
}
|
||||
which: true
|
||||
}, jQuery.event.addProp );
|
||||
|
||||
jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
|
||||
@ -5874,6 +5854,12 @@ jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateTyp
|
||||
return true;
|
||||
},
|
||||
|
||||
// Suppress native focus or blur as it's already being fired
|
||||
// in leverageNative.
|
||||
_default: function() {
|
||||
return true;
|
||||
},
|
||||
|
||||
delegateType: delegateType
|
||||
};
|
||||
} );
|
||||
@ -6541,6 +6527,10 @@ var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
|
||||
// set in CSS while `offset*` properties report correct values.
|
||||
// Behavior in IE 9 is more subtle than in newer versions & it passes
|
||||
// some versions of this test; make sure not to make it pass there!
|
||||
//
|
||||
// Support: Firefox 70+
|
||||
// Only Firefox includes border widths
|
||||
// in computed dimensions. (gh-4529)
|
||||
reliableTrDimensions: function() {
|
||||
var table, tr, trChild, trStyle;
|
||||
if ( reliableTrDimensionsVal == null ) {
|
||||
@ -6548,17 +6538,32 @@ var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
|
||||
tr = document.createElement( "tr" );
|
||||
trChild = document.createElement( "div" );
|
||||
|
||||
table.style.cssText = "position:absolute;left:-11111px";
|
||||
table.style.cssText = "position:absolute;left:-11111px;border-collapse:separate";
|
||||
tr.style.cssText = "border:1px solid";
|
||||
|
||||
// Support: Chrome 86+
|
||||
// Height set through cssText does not get applied.
|
||||
// Computed height then comes back as 0.
|
||||
tr.style.height = "1px";
|
||||
trChild.style.height = "9px";
|
||||
|
||||
// Support: Android 8 Chrome 86+
|
||||
// In our bodyBackground.html iframe,
|
||||
// display for all div elements is set to "inline",
|
||||
// which causes a problem only in Android 8 Chrome 86.
|
||||
// Ensuring the div is display: block
|
||||
// gets around this issue.
|
||||
trChild.style.display = "block";
|
||||
|
||||
documentElement
|
||||
.appendChild( table )
|
||||
.appendChild( tr )
|
||||
.appendChild( trChild );
|
||||
|
||||
trStyle = window.getComputedStyle( tr );
|
||||
reliableTrDimensionsVal = parseInt( trStyle.height ) > 3;
|
||||
reliableTrDimensionsVal = ( parseInt( trStyle.height, 10 ) +
|
||||
parseInt( trStyle.borderTopWidth, 10 ) +
|
||||
parseInt( trStyle.borderBottomWidth, 10 ) ) === tr.offsetHeight;
|
||||
|
||||
documentElement.removeChild( table );
|
||||
}
|
||||
@ -7022,10 +7027,10 @@ jQuery.each( [ "height", "width" ], function( _i, dimension ) {
|
||||
// Running getBoundingClientRect on a disconnected node
|
||||
// in IE throws an error.
|
||||
( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
|
||||
swap( elem, cssShow, function() {
|
||||
return getWidthOrHeight( elem, dimension, extra );
|
||||
} ) :
|
||||
getWidthOrHeight( elem, dimension, extra );
|
||||
swap( elem, cssShow, function() {
|
||||
return getWidthOrHeight( elem, dimension, extra );
|
||||
} ) :
|
||||
getWidthOrHeight( elem, dimension, extra );
|
||||
}
|
||||
},
|
||||
|
||||
@ -7084,7 +7089,7 @@ jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
|
||||
swap( elem, { marginLeft: 0 }, function() {
|
||||
return elem.getBoundingClientRect().left;
|
||||
} )
|
||||
) + "px";
|
||||
) + "px";
|
||||
}
|
||||
}
|
||||
);
|
||||
@ -7223,7 +7228,7 @@ Tween.propHooks = {
|
||||
if ( jQuery.fx.step[ tween.prop ] ) {
|
||||
jQuery.fx.step[ tween.prop ]( tween );
|
||||
} else if ( tween.elem.nodeType === 1 && (
|
||||
jQuery.cssHooks[ tween.prop ] ||
|
||||
jQuery.cssHooks[ tween.prop ] ||
|
||||
tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
|
||||
jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
|
||||
} else {
|
||||
@ -7468,7 +7473,7 @@ function defaultPrefilter( elem, props, opts ) {
|
||||
|
||||
anim.done( function() {
|
||||
|
||||
/* eslint-enable no-loop-func */
|
||||
/* eslint-enable no-loop-func */
|
||||
|
||||
// The final step of a "hide" animation is actually hiding the element
|
||||
if ( !hidden ) {
|
||||
@ -7588,7 +7593,7 @@ function Animation( elem, properties, options ) {
|
||||
tweens: [],
|
||||
createTween: function( prop, end ) {
|
||||
var tween = jQuery.Tween( elem, animation.opts, prop, end,
|
||||
animation.opts.specialEasing[ prop ] || animation.opts.easing );
|
||||
animation.opts.specialEasing[ prop ] || animation.opts.easing );
|
||||
animation.tweens.push( tween );
|
||||
return tween;
|
||||
},
|
||||
@ -7761,7 +7766,8 @@ jQuery.fn.extend( {
|
||||
anim.stop( true );
|
||||
}
|
||||
};
|
||||
doAnimation.finish = doAnimation;
|
||||
|
||||
doAnimation.finish = doAnimation;
|
||||
|
||||
return empty || optall.queue === false ?
|
||||
this.each( doAnimation ) :
|
||||
@ -8401,8 +8407,8 @@ jQuery.fn.extend( {
|
||||
if ( this.setAttribute ) {
|
||||
this.setAttribute( "class",
|
||||
className || value === false ?
|
||||
"" :
|
||||
dataPriv.get( this, "__className__" ) || ""
|
||||
"" :
|
||||
dataPriv.get( this, "__className__" ) || ""
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -8417,7 +8423,7 @@ jQuery.fn.extend( {
|
||||
while ( ( elem = this[ i++ ] ) ) {
|
||||
if ( elem.nodeType === 1 &&
|
||||
( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -8707,9 +8713,7 @@ jQuery.extend( jQuery.event, {
|
||||
special.bindType || type;
|
||||
|
||||
// jQuery handler
|
||||
handle = (
|
||||
dataPriv.get( cur, "events" ) || Object.create( null )
|
||||
)[ event.type ] &&
|
||||
handle = ( dataPriv.get( cur, "events" ) || Object.create( null ) )[ event.type ] &&
|
||||
dataPriv.get( cur, "handle" );
|
||||
if ( handle ) {
|
||||
handle.apply( cur, data );
|
||||
@ -8856,7 +8860,7 @@ var rquery = ( /\?/ );
|
||||
|
||||
// Cross-browser xml parsing
|
||||
jQuery.parseXML = function( data ) {
|
||||
var xml;
|
||||
var xml, parserErrorElem;
|
||||
if ( !data || typeof data !== "string" ) {
|
||||
return null;
|
||||
}
|
||||
@ -8865,12 +8869,17 @@ jQuery.parseXML = function( data ) {
|
||||
// IE throws on parseFromString with invalid input.
|
||||
try {
|
||||
xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
|
||||
} catch ( e ) {
|
||||
xml = undefined;
|
||||
}
|
||||
} catch ( e ) {}
|
||||
|
||||
if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
|
||||
jQuery.error( "Invalid XML: " + data );
|
||||
parserErrorElem = xml && xml.getElementsByTagName( "parsererror" )[ 0 ];
|
||||
if ( !xml || parserErrorElem ) {
|
||||
jQuery.error( "Invalid XML: " + (
|
||||
parserErrorElem ?
|
||||
jQuery.map( parserErrorElem.childNodes, function( el ) {
|
||||
return el.textContent;
|
||||
} ).join( "\n" ) :
|
||||
data
|
||||
) );
|
||||
}
|
||||
return xml;
|
||||
};
|
||||
@ -8971,16 +8980,14 @@ jQuery.fn.extend( {
|
||||
// Can add propHook for "elements" to filter or add form elements
|
||||
var elements = jQuery.prop( this, "elements" );
|
||||
return elements ? jQuery.makeArray( elements ) : this;
|
||||
} )
|
||||
.filter( function() {
|
||||
} ).filter( function() {
|
||||
var type = this.type;
|
||||
|
||||
// Use .is( ":disabled" ) so that fieldset[disabled] works
|
||||
return this.name && !jQuery( this ).is( ":disabled" ) &&
|
||||
rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
|
||||
( this.checked || !rcheckableType.test( type ) );
|
||||
} )
|
||||
.map( function( _i, elem ) {
|
||||
} ).map( function( _i, elem ) {
|
||||
var val = jQuery( this ).val();
|
||||
|
||||
if ( val == null ) {
|
||||
@ -9033,7 +9040,8 @@ var
|
||||
|
||||
// Anchor tag for parsing the document origin
|
||||
originAnchor = document.createElement( "a" );
|
||||
originAnchor.href = location.href;
|
||||
|
||||
originAnchor.href = location.href;
|
||||
|
||||
// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
|
||||
function addToPrefiltersOrTransports( structure ) {
|
||||
@ -9414,8 +9422,8 @@ jQuery.extend( {
|
||||
// Context for global events is callbackContext if it is a DOM node or jQuery collection
|
||||
globalEventContext = s.context &&
|
||||
( callbackContext.nodeType || callbackContext.jquery ) ?
|
||||
jQuery( callbackContext ) :
|
||||
jQuery.event,
|
||||
jQuery( callbackContext ) :
|
||||
jQuery.event,
|
||||
|
||||
// Deferreds
|
||||
deferred = jQuery.Deferred(),
|
||||
@ -9727,8 +9735,10 @@ jQuery.extend( {
|
||||
response = ajaxHandleResponses( s, jqXHR, responses );
|
||||
}
|
||||
|
||||
// Use a noop converter for missing script
|
||||
if ( !isSuccess && jQuery.inArray( "script", s.dataTypes ) > -1 ) {
|
||||
// Use a noop converter for missing script but not if jsonp
|
||||
if ( !isSuccess &&
|
||||
jQuery.inArray( "script", s.dataTypes ) > -1 &&
|
||||
jQuery.inArray( "json", s.dataTypes ) < 0 ) {
|
||||
s.converters[ "text script" ] = function() {};
|
||||
}
|
||||
|
||||
@ -10466,12 +10476,6 @@ jQuery.offset = {
|
||||
options.using.call( elem, props );
|
||||
|
||||
} else {
|
||||
if ( typeof props.top === "number" ) {
|
||||
props.top += "px";
|
||||
}
|
||||
if ( typeof props.left === "number" ) {
|
||||
props.left += "px";
|
||||
}
|
||||
curElem.css( props );
|
||||
}
|
||||
}
|
||||
@ -10640,8 +10644,11 @@ jQuery.each( [ "top", "left" ], function( _i, prop ) {
|
||||
|
||||
// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
|
||||
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
|
||||
jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
|
||||
function( defaultExtra, funcName ) {
|
||||
jQuery.each( {
|
||||
padding: "inner" + name,
|
||||
content: type,
|
||||
"": "outer" + name
|
||||
}, function( defaultExtra, funcName ) {
|
||||
|
||||
// Margin is only for outerHeight, outerWidth
|
||||
jQuery.fn[ funcName ] = function( margin, value ) {
|
||||
@ -10726,7 +10733,8 @@ jQuery.fn.extend( {
|
||||
}
|
||||
} );
|
||||
|
||||
jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
|
||||
jQuery.each(
|
||||
( "blur focus focusin focusout resize scroll click dblclick " +
|
||||
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
|
||||
"change select submit keydown keypress keyup contextmenu" ).split( " " ),
|
||||
function( _i, name ) {
|
||||
@ -10737,7 +10745,8 @@ jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
|
||||
this.on( name, null, data, fn ) :
|
||||
this.trigger( name );
|
||||
};
|
||||
} );
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,18 @@
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.BindingModels
|
||||
{
|
||||
public class ImplementerBindingModel : IImplementerModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
public int WorkExperience { get; set; } = 0;
|
||||
public int Qualification { get; set; } = 0;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -18,6 +18,7 @@ namespace BlacksmithWorkshopContracts.BindingModels
|
||||
public int Count { get; set; }
|
||||
|
||||
public double Sum { get; set; }
|
||||
public int? ImplementerId { get; set; } = null;
|
||||
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
|
||||
|
@ -0,0 +1,20 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IImplementerLogic
|
||||
{
|
||||
List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model);
|
||||
ImplementerViewModel? ReadElement(ImplementerSearchModel model);
|
||||
bool Create(ImplementerBindingModel model);
|
||||
bool Update(ImplementerBindingModel model);
|
||||
bool Delete(ImplementerBindingModel model);
|
||||
}
|
||||
}
|
@ -16,5 +16,6 @@ namespace BlacksmithWorkshopContracts.BusinessLogicsContracts
|
||||
bool TakeOrderInWork(OrderBindingModel model);
|
||||
bool FinishOrder(OrderBindingModel model);
|
||||
bool DeliveryOrder(OrderBindingModel model);
|
||||
OrderViewModel? ReadElement(OrderSearchModel model);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IWorkProcess
|
||||
{
|
||||
void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.SearchModels
|
||||
{
|
||||
public class ImplementerSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? ImplementerFIO { get; set; } = string.Empty;
|
||||
public string? Password { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using BlacksmithWorkshopDataModels.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -12,5 +13,7 @@ namespace BlacksmithWorkshopContracts.SearchModels
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
public int? ClientId { get; set; }
|
||||
public int? ImplementerId { get; set; }
|
||||
public OrderStatus? Status { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.StoragesContracts
|
||||
{
|
||||
public interface IImplementerStorage
|
||||
{
|
||||
List<ImplementerViewModel> GetFullList();
|
||||
List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model);
|
||||
ImplementerViewModel? GetElement(ImplementerSearchModel model);
|
||||
ImplementerViewModel? Insert(ImplementerBindingModel model);
|
||||
ImplementerViewModel? Update(ImplementerBindingModel model);
|
||||
ImplementerViewModel? Delete(ImplementerBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.ViewModels
|
||||
{
|
||||
public class ImplementerViewModel : IImplementerModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("ФИО исполнителя")]
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
[DisplayName("Стаж работы")]
|
||||
public int WorkExperience { get; set; } = 0;
|
||||
[DisplayName("Квалификация")]
|
||||
public int Qualification { get; set; } = 0;
|
||||
[DisplayName("Пароль")]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@ namespace BlacksmithWorkshopContracts.ViewModels
|
||||
{
|
||||
[DisplayName("Номер")]
|
||||
public int Id { get; set; }
|
||||
public int? ImplementerId { get; set; } = null;
|
||||
public int ClientId { get; set; }
|
||||
[DisplayName("Клиент")]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
@ -25,6 +26,8 @@ namespace BlacksmithWorkshopContracts.ViewModels
|
||||
public double Sum { get; set; }
|
||||
[DisplayName("Статус")]
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
[DisplayName("Исполнитель")]
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
[DisplayName("Дата создания")]
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
[DisplayName("Дата выполнения")]
|
||||
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopDataModels.Models
|
||||
{
|
||||
public interface IImplementerModel
|
||||
{
|
||||
string ImplementerFIO { get; }
|
||||
string Password { get; }
|
||||
int WorkExperience { get; }
|
||||
int Qualification { get; }
|
||||
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@ namespace BlacksmithWorkshopDataModels.Models
|
||||
int ClientId { get; }
|
||||
int Count { get; }
|
||||
double Sum { get; }
|
||||
int? ImplementerId { get; }
|
||||
OrderStatus Status { get; }
|
||||
DateTime DateCreate { get; }
|
||||
DateTime? DateImplement { get; }
|
||||
|
@ -1,4 +1,5 @@
|
||||
using BlacksmithWorkshopDatabaseImplement.Models;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -14,7 +15,7 @@ namespace BlacksmithWorkshopDatabaseImplement
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=BlacksmithWorkshopDataBase1;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=BlacksmithWorkshopDataBase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
@ -23,5 +24,7 @@ namespace BlacksmithWorkshopDatabaseImplement
|
||||
public virtual DbSet<ManufactureComponent> ManufactureComponents { set; get; }
|
||||
public virtual DbSet<Order> Orders { set; get; }
|
||||
public virtual DbSet<Client> Clients { set; get; }
|
||||
public virtual DbSet<Implementer> Implementers { set; get; }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,82 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.StoragesContracts;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopDatabaseImplement.Implements
|
||||
{
|
||||
public class ImplementerStorage : IImplementerStorage
|
||||
{
|
||||
public ImplementerViewModel? Delete(ImplementerBindingModel model)
|
||||
{
|
||||
using var context = new BlacksmithWorkshopDataBase();
|
||||
var res = context.Implementers.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (res != null)
|
||||
{
|
||||
context.Implementers.Remove(res);
|
||||
context.SaveChanges();
|
||||
}
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ImplementerFIO) && string.IsNullOrEmpty(model.Password) &&
|
||||
!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new BlacksmithWorkshopDataBase();
|
||||
return context.Implementers
|
||||
.FirstOrDefault(x => (string.IsNullOrEmpty(model.ImplementerFIO) || x.ImplementerFIO == model.ImplementerFIO) &&
|
||||
(!model.Id.HasValue || x.Id == model.Id) &&
|
||||
(string.IsNullOrEmpty(model.Password) || x.Password == model.Password))
|
||||
?.GetViewModel;
|
||||
}
|
||||
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
var res = GetElement(model);
|
||||
return res != null ? new() { res } : new();
|
||||
}
|
||||
return new();
|
||||
}
|
||||
public List<ImplementerViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BlacksmithWorkshopDataBase();
|
||||
return context.Implementers.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
public ImplementerViewModel? Insert(ImplementerBindingModel model)
|
||||
{
|
||||
using var context = new BlacksmithWorkshopDataBase();
|
||||
var res = Implementer.Create(model);
|
||||
if (res != null)
|
||||
{
|
||||
context.Implementers.Add(res);
|
||||
context.SaveChanges();
|
||||
}
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
public ImplementerViewModel? Update(ImplementerBindingModel model)
|
||||
{
|
||||
using var context = new BlacksmithWorkshopDataBase();
|
||||
var res = context.Implementers.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (res != null)
|
||||
{
|
||||
res.Update(model);
|
||||
context.SaveChanges();
|
||||
}
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements
|
||||
return context.Orders
|
||||
.Include(x => x.Manufacture)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@ -29,12 +30,13 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements
|
||||
return context.Orders
|
||||
.Include(x => x.Manufacture)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.Where(x => (
|
||||
(!model.Id.HasValue || x.Id == model.Id) &&
|
||||
(!model.DateFrom.HasValue || x.DateCreate >= model.DateFrom) &&
|
||||
(!model.DateTo.HasValue || x.DateCreate <= model.DateTo) &&
|
||||
(!model.ClientId.HasValue || x.ClientId == model.ClientId)
|
||||
)
|
||||
(!model.ClientId.HasValue || x.ClientId == model.ClientId) &&
|
||||
(!model.Status.HasValue || x.Status == model.Status))
|
||||
)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
@ -47,9 +49,14 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements
|
||||
}
|
||||
using var context = new BlacksmithWorkshopDataBase();
|
||||
return context.Orders
|
||||
.Include(x => x.Manufacture)
|
||||
.Include(x => x.Client)
|
||||
.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
.Include(x => x.Manufacture)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.FirstOrDefault(
|
||||
x => (model.Id.HasValue && x.Id == model.Id) ||
|
||||
(model.ImplementerId.HasValue && model.Status.HasValue &&
|
||||
x.ImplementerId == model.ImplementerId && x.Status == model.Status))?
|
||||
.GetViewModel;
|
||||
}
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
{
|
||||
@ -69,6 +76,7 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements
|
||||
var order = context.Orders
|
||||
.Include(x => x.Manufacture)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (order == null)
|
||||
{
|
||||
@ -84,6 +92,7 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements
|
||||
var element = context.Orders
|
||||
.Include(x => x.Manufacture)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
|
@ -0,0 +1,257 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using BlacksmithWorkshopDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BlacksmithWorkshopDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(BlacksmithWorkshopDataBase))]
|
||||
[Migration("20240422165434_addingImplementors")]
|
||||
partial class addingImplementors
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.16")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDataModels.Models.Implementer", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ImplementerFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Qualification")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("WorkExperience")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Implementers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ClientFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ManufactureName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Manufactures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ManufactureId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("ManufactureId");
|
||||
|
||||
b.ToTable("ManufactureComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int?>("ImplementerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ManufactureId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("ImplementerId");
|
||||
|
||||
b.HasIndex("ManufactureId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureComponent", b =>
|
||||
{
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("ManufactureComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("ManufactureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Manufacture");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BlacksmithWorkshopDataModels.Models.Implementer", "Implementer")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ImplementerId");
|
||||
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ManufactureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Implementer");
|
||||
|
||||
b.Navigation("Manufacture");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDataModels.Models.Implementer", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("ManufactureComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BlacksmithWorkshopDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class addingImplementors : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ImplementerId",
|
||||
table: "Orders",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Implementers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ImplementerFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Qualification = table.Column<int>(type: "int", nullable: false),
|
||||
WorkExperience = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Implementers", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_ImplementerId",
|
||||
table: "Orders",
|
||||
column: "ImplementerId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Orders_Implementers_ImplementerId",
|
||||
table: "Orders",
|
||||
column: "ImplementerId",
|
||||
principalTable: "Implementers",
|
||||
principalColumn: "Id");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Orders_Implementers_ImplementerId",
|
||||
table: "Orders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Implementers");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Orders_ImplementerId",
|
||||
table: "Orders");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ImplementerId",
|
||||
table: "Orders");
|
||||
}
|
||||
}
|
||||
}
|
@ -22,6 +22,33 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDataModels.Models.Implementer", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ImplementerFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Qualification")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("WorkExperience")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Implementers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -133,6 +160,9 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int?>("ImplementerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ManufactureId")
|
||||
.HasColumnType("int");
|
||||
|
||||
@ -146,6 +176,8 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("ImplementerId");
|
||||
|
||||
b.HasIndex("ManufactureId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
@ -178,6 +210,10 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BlacksmithWorkshopDataModels.Models.Implementer", "Implementer")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ImplementerId");
|
||||
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ManufactureId")
|
||||
@ -186,9 +222,16 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Implementer");
|
||||
|
||||
b.Navigation("Manufacture");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDataModels.Models.Implementer", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
|
@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopDatabaseImplement.Models;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
|
||||
namespace BlacksmithWorkshopDataModels.Models
|
||||
{
|
||||
public class Implementer : IImplementerModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public int Qualification { get; set; } = 0;
|
||||
[Required]
|
||||
public int WorkExperience { get; set; } = 0;
|
||||
[ForeignKey("ImplementerId")]
|
||||
public virtual List<Order> Orders { get; set; } = new();
|
||||
public static Implementer? Create(ImplementerBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new()
|
||||
{
|
||||
Id = model.Id,
|
||||
Password = model.Password,
|
||||
Qualification = model.Qualification,
|
||||
ImplementerFIO = model.ImplementerFIO,
|
||||
WorkExperience = model.WorkExperience,
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ImplementerBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Password = model.Password;
|
||||
Qualification = model.Qualification;
|
||||
ImplementerFIO = model.ImplementerFIO;
|
||||
WorkExperience = model.WorkExperience;
|
||||
}
|
||||
|
||||
public ImplementerViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Password = Password,
|
||||
Qualification = Qualification,
|
||||
ImplementerFIO = ImplementerFIO,
|
||||
WorkExperience = WorkExperience,
|
||||
};
|
||||
}
|
||||
}
|
@ -29,6 +29,8 @@ namespace BlacksmithWorkshopDatabaseImplement.Models
|
||||
[Required]
|
||||
public int ManufactureId { get; private set; }
|
||||
public virtual Manufacture? Manufacture { get; set; }
|
||||
public int? ImplementerId { get; private set; } = null;
|
||||
public virtual Implementer? Implementer { get; private set; }
|
||||
|
||||
public static Order Create(OrderBindingModel model)
|
||||
{
|
||||
@ -42,6 +44,7 @@ namespace BlacksmithWorkshopDatabaseImplement.Models
|
||||
DateImplement = model.DateImplement,
|
||||
ManufactureId = model.ManufactureId,
|
||||
ClientId = model.ClientId,
|
||||
ImplementerId = model.ImplementerId,
|
||||
};
|
||||
}
|
||||
public void Update(OrderBindingModel? model)
|
||||
@ -51,7 +54,8 @@ namespace BlacksmithWorkshopDatabaseImplement.Models
|
||||
return;
|
||||
}
|
||||
Status = model.Status;
|
||||
DateImplement = model.DateImplement;
|
||||
DateImplement = model.DateImplement;
|
||||
ImplementerId = model.ImplementerId;
|
||||
}
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
@ -65,6 +69,8 @@ namespace BlacksmithWorkshopDatabaseImplement.Models
|
||||
Id = Id,
|
||||
ClientId = ClientId,
|
||||
ClientFIO = Client?.ClientFIO ?? string.Empty,
|
||||
ImplementerId = ImplementerId,
|
||||
ImplementerFIO = Implementer != null ? Implementer.ImplementerFIO : string.Empty
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -14,12 +14,14 @@ namespace BlacksmithWorkshopListImplement
|
||||
public List<Order> Orders { get; set; }
|
||||
public List<Manufacture> Manufactures { get; set; }
|
||||
public List<Client> Clients { get; set; }
|
||||
public List<Implementer> Implementers { get; set; }
|
||||
private DataListSingleton()
|
||||
{
|
||||
Components = new List<Component>();
|
||||
Orders = new List<Order>();
|
||||
Manufactures = new List<Manufacture>();
|
||||
Clients = new List<Client>();
|
||||
Implementers = new List<Implementer>();
|
||||
}
|
||||
public static DataListSingleton GetInstance()
|
||||
{
|
||||
|
@ -0,0 +1,102 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.StoragesContracts;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopListImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopListImplement.Implements
|
||||
{
|
||||
public class ImplementerStorage : IImplementerStorage
|
||||
{
|
||||
private readonly DataListSingleton _source;
|
||||
public ImplementerStorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
public List<ImplementerViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<ImplementerViewModel>();
|
||||
foreach (var implementer in _source.Implementers)
|
||||
{
|
||||
result.Add(implementer.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
|
||||
{
|
||||
var result = new List<ImplementerViewModel>();
|
||||
if (string.IsNullOrEmpty(model.ImplementerFIO) && string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
foreach (var implementer in _source.Implementers)
|
||||
{
|
||||
if (model.ImplementerFIO != null && implementer.ImplementerFIO.Contains(model.ImplementerFIO))
|
||||
{
|
||||
result.Add(implementer.GetViewModel);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
||||
{
|
||||
foreach (var implementer in _source.Implementers)
|
||||
{
|
||||
if ((string.IsNullOrEmpty(model.ImplementerFIO) || implementer.ImplementerFIO == model.ImplementerFIO) &&
|
||||
(!model.Id.HasValue || implementer.Id == model.Id) && (string.IsNullOrEmpty(model.Password) || implementer.Password == model.Password))
|
||||
{
|
||||
return implementer.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public ImplementerViewModel? Insert(ImplementerBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
foreach (var implementer in _source.Implementers)
|
||||
{
|
||||
if (model.Id <= implementer.Id)
|
||||
{
|
||||
model.Id = implementer.Id + 1;
|
||||
}
|
||||
}
|
||||
var newImplementer = Implementer.Create(model);
|
||||
if (newImplementer == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.Implementers.Add(newImplementer);
|
||||
return newImplementer.GetViewModel;
|
||||
}
|
||||
public ImplementerViewModel? Update(ImplementerBindingModel model)
|
||||
{
|
||||
foreach (var implementer in _source.Implementers)
|
||||
{
|
||||
if (model.Id == implementer.Id)
|
||||
{
|
||||
implementer.Update(model);
|
||||
return implementer.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public ImplementerViewModel? Delete(ImplementerBindingModel model)
|
||||
{
|
||||
for (int i = 0; i < _source.Implementers.Count; ++i)
|
||||
{
|
||||
if (_source.Implementers[i].Id == model.Id)
|
||||
{
|
||||
var element = _source.Implementers[i];
|
||||
_source.Implementers.RemoveAt(i);
|
||||
return element.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -36,7 +36,8 @@ namespace BlacksmithWorkshopListImplement.Implements
|
||||
if ((!model.Id.HasValue || order.Id == model.Id) &&
|
||||
(!model.DateFrom.HasValue || order.DateCreate >= model.DateFrom) &&
|
||||
(!model.DateTo.HasValue || order.DateCreate <= model.DateTo) &&
|
||||
(!model.ClientId.HasValue || order.ClientId == model.ClientId))
|
||||
(!model.ClientId.HasValue || order.ClientId == model.ClientId) &&
|
||||
(!model.Status.HasValue || order.Status == model.Status))
|
||||
{
|
||||
result.Add(AccessStorage(order.GetViewModel));
|
||||
}
|
||||
@ -51,9 +52,11 @@ namespace BlacksmithWorkshopListImplement.Implements
|
||||
}
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if (model.Id.HasValue && order.Id == model.Id)
|
||||
if ((model.Id.HasValue && order.Id == model.Id) ||
|
||||
(model.ImplementerId.HasValue && model.Status.HasValue &&
|
||||
order.ImplementerId == model.ImplementerId && order.Status == model.Status))
|
||||
{
|
||||
return order.GetViewModel;
|
||||
return AccessStorage(order.GetViewModel);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -103,17 +106,17 @@ namespace BlacksmithWorkshopListImplement.Implements
|
||||
}
|
||||
public OrderViewModel AccessStorage(OrderViewModel model)
|
||||
{
|
||||
var client = _source.Clients.FirstOrDefault(x => x.Id == model.ClientId);
|
||||
if (model == null)
|
||||
return null;
|
||||
var manufacture = _source.Manufactures.FirstOrDefault(x => x.Id == model.Id);
|
||||
var client = _source.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||
var implementer = _source.Implementers.FirstOrDefault(x => x.Id == model.ImplementerId);
|
||||
if (manufacture != null)
|
||||
model.ManufactureName = manufacture.ManufactureName;
|
||||
if (client != null)
|
||||
model.ClientFIO = client.ClientFIO;
|
||||
foreach (var Manufacture in _source.Manufactures)
|
||||
{
|
||||
if (Manufacture.Id == model.ManufactureId)
|
||||
{
|
||||
model.ManufactureName = Manufacture.ManufactureName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (implementer != null)
|
||||
model.ImplementerFIO = implementer.ImplementerFIO;
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,54 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopListImplement.Models
|
||||
{
|
||||
public class Implementer : IImplementerModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public int WorkExperience { get; set; } = 0;
|
||||
public int Qualification { get; set; } = 0;
|
||||
public static Implementer? Create(ImplementerBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Implementer()
|
||||
{
|
||||
Id = model.Id,
|
||||
ImplementerFIO = model.ImplementerFIO,
|
||||
Password = model.Password,
|
||||
WorkExperience = model.WorkExperience,
|
||||
Qualification = model.Qualification
|
||||
};
|
||||
}
|
||||
public void Update(ImplementerBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ImplementerFIO = model.ImplementerFIO;
|
||||
Password = model.Password;
|
||||
WorkExperience = model.WorkExperience;
|
||||
Qualification = model.Qualification;
|
||||
}
|
||||
public ImplementerViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ImplementerFIO = ImplementerFIO,
|
||||
Password = Password,
|
||||
WorkExperience = WorkExperience,
|
||||
Qualification = Qualification
|
||||
};
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@ namespace BlacksmithWorkshopListImplement.Models
|
||||
public int Id { get; private set; }
|
||||
public int ManufactureId { get; private set; }
|
||||
public int ClientId { get; private set; }
|
||||
public int? ImplementerId { get; private set; }
|
||||
public int Count { get; private set; }
|
||||
public double Sum { get; private set; }
|
||||
public OrderStatus Status { get; private set; }
|
||||
@ -37,6 +38,7 @@ namespace BlacksmithWorkshopListImplement.Models
|
||||
Status = model.Status,
|
||||
DateCreate = model.DateCreate,
|
||||
DateImplement = model.DateImplement,
|
||||
ImplementerId = model.ImplementerId
|
||||
};
|
||||
}
|
||||
public void Update(OrderBindingModel? model)
|
||||
@ -47,6 +49,7 @@ namespace BlacksmithWorkshopListImplement.Models
|
||||
}
|
||||
Status = model.Status;
|
||||
DateImplement = model.DateImplement;
|
||||
ImplementerId = model.ImplementerId;
|
||||
}
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
@ -58,6 +61,7 @@ namespace BlacksmithWorkshopListImplement.Models
|
||||
Status = Status,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement,
|
||||
ImplementerId = ImplementerId,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -10,11 +10,10 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
//отвечает за обработку запросов, связанных с сущностью клиента
|
||||
namespace BlacksmithWorkshopRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]//маршрут для контроллера
|
||||
[ApiController]//возвращается к контроллерам api, который возвращает данные в json
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class ClientController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
@ -25,10 +24,8 @@ namespace BlacksmithWorkshopRestApi.Controllers
|
||||
_logic = logic;
|
||||
}
|
||||
[HttpGet]
|
||||
|
||||
//действия
|
||||
public ClientViewModel? Login(string login, string password)//Возвращает результат чтения сущности клиента из бд
|
||||
{
|
||||
public ClientViewModel? Login(string login, string password)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadElement(new ClientSearchModel
|
||||
@ -44,8 +41,8 @@ namespace BlacksmithWorkshopRestApi.Controllers
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void Register(ClientBindingModel model)//Создает новую сущность клиента в базе данных на основе предоставленной модели
|
||||
{
|
||||
public void Register(ClientBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Create(model);
|
||||
@ -57,8 +54,8 @@ namespace BlacksmithWorkshopRestApi.Controllers
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void UpdateData(ClientBindingModel model)//Обновляет существующую сущность клиента в базе данных на основе предоставленной модели
|
||||
{
|
||||
public void UpdateData(ClientBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Update(model);
|
||||
|
@ -0,0 +1,101 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopDataModels.Enums;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BlacksmithWorkshopRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class ImplementerController : ControllerBase
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderLogic _order;
|
||||
private readonly IImplementerLogic _logic;
|
||||
public ImplementerController(IOrderLogic order, IImplementerLogic logic, ILogger<ImplementerController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_order = order;
|
||||
_logic = logic;
|
||||
}
|
||||
[HttpGet]
|
||||
public ImplementerViewModel? Login(string login, string password)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadElement(new ImplementerSearchModel
|
||||
{
|
||||
ImplementerFIO = login,
|
||||
Password = password
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка авторизации сотрудника");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public List<OrderViewModel>? GetNewOrders()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _order.ReadList(new OrderSearchModel
|
||||
{
|
||||
Status = OrderStatus.Принят
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения новых заказов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public OrderViewModel? GetImplementerOrder(int implementerId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _order.ReadElement(new OrderSearchModel
|
||||
{
|
||||
ImplementerId = implementerId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения текущего заказа исполнителя");
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void TakeOrderInWork(OrderBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_order.TakeOrderInWork(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка перевода заказа с №{Id} в работу", model.Id);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void FinishOrder(OrderBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_order.FinishOrder(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отметки о готовности заказа с №{ Id}", model.Id);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -10,7 +10,6 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
//отвечает за обработку запросов, связанных с сущностями заказов и кузнечных изделий
|
||||
namespace BlacksmithWorkshopRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
@ -27,8 +26,8 @@ namespace BlacksmithWorkshopRestApi.Controllers
|
||||
_manufacture = manufacture;
|
||||
}
|
||||
[HttpGet]
|
||||
public List<ManufactureViewModel>? GetManufactureList()//Возвращает список всех кузнечных изделий из базы данных.
|
||||
{
|
||||
public List<ManufactureViewModel>? GetManufactureList()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _manufacture.ReadList(null);
|
||||
@ -40,8 +39,8 @@ namespace BlacksmithWorkshopRestApi.Controllers
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public ManufactureViewModel? GetManufacture(int manufactureId)//Возвращает конкретное кузнечное изделие из базы данных по его идентификатору
|
||||
{
|
||||
public ManufactureViewModel? GetManufacture(int manufactureId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _manufacture.ReadElement(new ManufactureSearchModel
|
||||
@ -56,8 +55,8 @@ namespace BlacksmithWorkshopRestApi.Controllers
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public List<OrderViewModel>? GetOrders(int clientId)// Возвращает список заказов из базы данных, размещенных конкретным клиентом.
|
||||
{
|
||||
public List<OrderViewModel>? GetOrders(int clientId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _order.ReadList(new OrderSearchModel
|
||||
@ -72,8 +71,8 @@ namespace BlacksmithWorkshopRestApi.Controllers
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateOrder(OrderBindingModel model)//Создает новый заказ в базе данных на основе предоставленной модели.
|
||||
{
|
||||
public void CreateOrder(OrderBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_order.CreateOrder(model);
|
||||
|
Loading…
Reference in New Issue
Block a user