PIbd-22. Fedorenko G.Y. Lab Work 5 BASE #6
@ -15,7 +15,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CarpentryWorkshopBusinessLo
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CarpentryWorkshopFileImplement", "CarpentryWorkshopFileImplement\CarpentryWorkshopFileImplement.csproj", "{6EFF6C01-263D-4D25-806A-1DC593820AB1}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CarpentryWorkshopDatabaseImplement", "CarpentryWorkshopDatabaseImplement\CarpentryWorkshopDatabaseImplement.csproj", "{249894CF-B596-4AFD-8EB7-F167056920A1}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CarpentryWorkshopDatabaseImplement", "CarpentryWorkshopDatabaseImplement\CarpentryWorkshopDatabaseImplement.csproj", "{249894CF-B596-4AFD-8EB7-F167056920A1}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CarpentryWorkshopRestApi", "CarpentryWorkshopRestApi\CarpentryWorkshopRestApi.csproj", "{D9D18CB0-4068-43B6-92F9-85905E53FF95}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -51,6 +53,10 @@ Global
|
||||
{249894CF-B596-4AFD-8EB7-F167056920A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{249894CF-B596-4AFD-8EB7-F167056920A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{249894CF-B596-4AFD-8EB7-F167056920A1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D9D18CB0-4068-43B6-92F9-85905E53FF95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D9D18CB0-4068-43B6-92F9-85905E53FF95}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D9D18CB0-4068-43B6-92F9-85905E53FF95}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D9D18CB0-4068-43B6-92F9-85905E53FF95}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
100
CarpentryWorkshop/CarpentryWorkshop/FormClients.Designer.cs
generated
Normal file
100
CarpentryWorkshop/CarpentryWorkshop/FormClients.Designer.cs
generated
Normal file
@ -0,0 +1,100 @@
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CarpentryWorkshopView
|
||||
{
|
||||
partial class FormClients
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
dataGridView = new DataGridView();
|
||||
buttonUpd = new Button();
|
||||
buttonDel = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.BackgroundColor = SystemColors.ControlLightLight;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Dock = DockStyle.Left;
|
||||
dataGridView.Location = new Point(0, 0);
|
||||
dataGridView.Margin = new Padding(4, 3, 4, 3);
|
||||
dataGridView.MultiSelect = false;
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.ReadOnly = true;
|
||||
dataGridView.RowHeadersVisible = false;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(408, 360);
|
||||
dataGridView.TabIndex = 1;
|
||||
//
|
||||
// buttonUpd
|
||||
//
|
||||
buttonUpd.Location = new Point(430, 59);
|
||||
buttonUpd.Margin = new Padding(4, 3, 4, 3);
|
||||
buttonUpd.Name = "buttonUpd";
|
||||
buttonUpd.Size = new Size(88, 27);
|
||||
buttonUpd.TabIndex = 8;
|
||||
buttonUpd.Text = "Обновить";
|
||||
buttonUpd.UseVisualStyleBackColor = true;
|
||||
buttonUpd.Click += ButtonUpd_Click;
|
||||
//
|
||||
// buttonDel
|
||||
//
|
||||
buttonDel.Location = new Point(430, 12);
|
||||
buttonDel.Margin = new Padding(4, 3, 4, 3);
|
||||
buttonDel.Name = "buttonDel";
|
||||
buttonDel.Size = new Size(88, 27);
|
||||
buttonDel.TabIndex = 7;
|
||||
buttonDel.Text = "Удалить";
|
||||
buttonDel.UseVisualStyleBackColor = true;
|
||||
buttonDel.Click += ButtonDel_Click;
|
||||
//
|
||||
// FormClients
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(541, 360);
|
||||
Controls.Add(buttonUpd);
|
||||
Controls.Add(buttonDel);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormClients";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Клиенты";
|
||||
Load += FormClients_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonUpd;
|
||||
private Button buttonDel;
|
||||
}
|
||||
}
|
84
CarpentryWorkshop/CarpentryWorkshop/FormClients.cs
Normal file
84
CarpentryWorkshop/CarpentryWorkshop/FormClients.cs
Normal file
@ -0,0 +1,84 @@
|
||||
using CarpentryWorkshopContracts.BindingModels;
|
||||
using CarpentryWorkshopContracts.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 CarpentryWorkshopView
|
||||
{
|
||||
public partial class FormClients : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IClientLogic _logic;
|
||||
|
||||
public FormClients(ILogger<FormClients> logger, IClientLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormClients_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Clients loading");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Clients loading error");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить клиента?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Deletion of client");
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new ClientBindingModel { Id = id }))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Client deletion error");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
120
CarpentryWorkshop/CarpentryWorkshop/FormClients.resx
Normal file
120
CarpentryWorkshop/CarpentryWorkshop/FormClients.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>
|
@ -32,6 +32,7 @@
|
||||
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||
КомпонентыToolStripMenuItem = new ToolStripMenuItem();
|
||||
ИзделияToolStripMenuItem = new ToolStripMenuItem();
|
||||
клиентыToolStripMenuItem = new ToolStripMenuItem();
|
||||
отчётыToolStripMenuItem = new ToolStripMenuItem();
|
||||
списокИзделийToolStripMenuItem = new ToolStripMenuItem();
|
||||
компонентыПоИзделиямToolStripMenuItem = new ToolStripMenuItem();
|
||||
@ -57,7 +58,7 @@
|
||||
//
|
||||
// справочникиToolStripMenuItem
|
||||
//
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { КомпонентыToolStripMenuItem, ИзделияToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { КомпонентыToolStripMenuItem, ИзделияToolStripMenuItem, клиентыToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||
справочникиToolStripMenuItem.Size = new Size(94, 20);
|
||||
справочникиToolStripMenuItem.Text = "Справочники";
|
||||
@ -76,6 +77,13 @@
|
||||
ИзделияToolStripMenuItem.Text = "Изделия";
|
||||
ИзделияToolStripMenuItem.Click += ИзделияToolStripMenuItem_Click;
|
||||
//
|
||||
// клиентыToolStripMenuItem
|
||||
//
|
||||
клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
|
||||
клиентыToolStripMenuItem.Size = new Size(224, 26);
|
||||
клиентыToolStripMenuItem.Text = "Клиенты";
|
||||
клиентыToolStripMenuItem.Click += КлиентыToolStripMenuItem_Click;
|
||||
//
|
||||
// отчётыToolStripMenuItem
|
||||
//
|
||||
отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокИзделийToolStripMenuItem, компонентыПоИзделиямToolStripMenuItem, списокЗаказовToolStripMenuItem });
|
||||
@ -210,5 +218,6 @@
|
||||
private ToolStripMenuItem списокИзделийToolStripMenuItem;
|
||||
private ToolStripMenuItem компонентыПоИзделиямToolStripMenuItem;
|
||||
private ToolStripMenuItem списокЗаказовToolStripMenuItem;
|
||||
private ToolStripMenuItem клиентыToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -33,6 +33,8 @@ namespace CarpentryWorkshopView
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["WoodId"].Visible = false;
|
||||
dataGridView.Columns["WoodName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["ClientId"].Visible = false;
|
||||
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
|
||||
}
|
||||
_logger.LogInformation("Загрузка изделий");
|
||||
@ -60,6 +62,15 @@ namespace CarpentryWorkshopView
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void КлиентыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
||||
if (service is FormClients form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
||||
|
@ -38,10 +38,12 @@ namespace CarpentryWorkshop
|
||||
option.SetMinimumLevel(LogLevel.Information);
|
||||
option.AddNLog("nlog.config");
|
||||
});
|
||||
services.AddTransient<IClientStorage, ClientStorage>();
|
||||
services.AddTransient<IComponentStorage, ComponentStorage>();
|
||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
services.AddTransient<IWoodStorage, WoodStorage>();
|
||||
|
||||
services.AddTransient<IClientLogic, ClientLogic>();
|
||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
services.AddTransient<IReportLogic, ReportLogic>();
|
||||
@ -54,6 +56,7 @@ namespace CarpentryWorkshop
|
||||
services.AddTransient<FormWood>();
|
||||
services.AddTransient<FormWoodComponent>();
|
||||
services.AddTransient<FormWoods>();
|
||||
services.AddTransient<FormClients>();
|
||||
|
||||
services.AddTransient<FormReportWoodComponents>();
|
||||
services.AddTransient<FormReportOrders>();
|
||||
|
@ -0,0 +1,112 @@
|
||||
using CarpentryWorkshopContracts.BindingModels;
|
||||
using CarpentryWorkshopContracts.BusinessLogicsContracts;
|
||||
using CarpentryWorkshopContracts.SearchModels;
|
||||
using CarpentryWorkshopContracts.StoragesContracts;
|
||||
using CarpentryWorkshopContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace CarpentryWorkshopBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ClientLogic : IClientLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IClientStorage _clientStorage;
|
||||
public ClientLogic(ILogger<ClientLogic> logger, IClientStorage clientStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_clientStorage = clientStorage;
|
||||
}
|
||||
|
||||
public bool Create(ClientBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_clientStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(ClientBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_clientStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(ClientBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_clientStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public ClientViewModel? ReadElement(ClientSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. Email:{Email}.Id:{ Id}", model.Email, model.Id);
|
||||
var element = _clientStorage.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<ClientViewModel>? ReadList(ClientSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Email:{Email}.Id:{ Id} ", model?.Email, model?.Id);
|
||||
var list = (model == null) ? _clientStorage.GetFullList() : _clientStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
||||
private void CheckModel(ClientBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.ClientFIO))
|
||||
{
|
||||
throw new ArgumentNullException("Нет ФИО клиента", nameof(model.ClientFIO));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Email))
|
||||
{
|
||||
throw new ArgumentNullException("Нет логина(почты) клиента", nameof(model.Email));
|
||||
}
|
||||
_logger.LogInformation("Client. Id: {Id}, FIO: {fio}, email: {email}", model.Id, model.ClientFIO, model.Email);
|
||||
var element = _clientStorage.GetElement(new ClientSearchModel
|
||||
{
|
||||
Email = model.Email,
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Клиент с таким логином(почтой) уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
using CarpentryWorkshopDataModels.Models;
|
||||
|
||||
namespace CarpentryWorkshopContracts.BindingModels
|
||||
{
|
||||
public class ClientBindingModel : IClientModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
public string Email { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ namespace CarpentryWorkshopContracts.BindingModels
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int WoodId { get; set; }
|
||||
public int ClientId { get; set; }
|
||||
public int Count { get; set; }
|
||||
public double Sum { get; set; }
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
|
@ -0,0 +1,15 @@
|
||||
using CarpentryWorkshopContracts.BindingModels;
|
||||
using CarpentryWorkshopContracts.SearchModels;
|
||||
using CarpentryWorkshopContracts.ViewModels;
|
||||
|
||||
namespace CarpentryWorkshopContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IClientLogic
|
||||
{
|
||||
List<ClientViewModel>? ReadList(ClientSearchModel? model);
|
||||
ClientViewModel? ReadElement(ClientSearchModel model);
|
||||
bool Create(ClientBindingModel model);
|
||||
bool Update(ClientBindingModel model);
|
||||
bool Delete(ClientBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
namespace CarpentryWorkshopContracts.SearchModels
|
||||
{
|
||||
public class ClientSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? ClientFIO { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public string? Password { get; set; }
|
||||
}
|
||||
}
|
@ -5,5 +5,6 @@
|
||||
public int? Id { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
public int? ClientId { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using CarpentryWorkshopContracts.BindingModels;
|
||||
using CarpentryWorkshopContracts.SearchModels;
|
||||
using CarpentryWorkshopContracts.ViewModels;
|
||||
|
||||
namespace CarpentryWorkshopContracts.StoragesContracts
|
||||
{
|
||||
public interface IClientStorage
|
||||
{
|
||||
List<ClientViewModel> GetFullList();
|
||||
List<ClientViewModel> GetFilteredList(ClientSearchModel model);
|
||||
ClientViewModel? GetElement(ClientSearchModel model);
|
||||
ClientViewModel? Insert(ClientBindingModel model);
|
||||
ClientViewModel? Update(ClientBindingModel model);
|
||||
ClientViewModel? Delete(ClientBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using CarpentryWorkshopDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace CarpentryWorkshopContracts.ViewModels
|
||||
{
|
||||
public class ClientViewModel : IClientModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Client's FIO")]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
[DisplayName("Login (Email)")]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
[DisplayName("Password")]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -11,6 +11,9 @@ namespace CarpentryWorkshopContracts.ViewModels
|
||||
public int WoodId { get; set; }
|
||||
[DisplayName("Изделие")]
|
||||
public string WoodName { get; set; } = string.Empty;
|
||||
public int ClientId { get; set; }
|
||||
[DisplayName("Клиент")]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
[DisplayName("Количество")]
|
||||
public int Count { get; set; }
|
||||
[DisplayName("Сумма")]
|
||||
|
@ -0,0 +1,9 @@
|
||||
namespace CarpentryWorkshopDataModels.Models
|
||||
{
|
||||
public interface IClientModel : IId
|
||||
{
|
||||
string ClientFIO { get; }
|
||||
string Email { get; }
|
||||
string Password { get; }
|
||||
}
|
||||
}
|
@ -17,5 +17,6 @@ namespace CarpentryWorkshopDatabaseImplement
|
||||
public virtual DbSet<Wood> Woods { set; get; }
|
||||
public virtual DbSet<WoodComponent> WoodComponents { set; get; }
|
||||
public virtual DbSet<Order> Orders { set; get; }
|
||||
public virtual DbSet<Client> Clients { set; get; }
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,80 @@
|
||||
using CarpentryWorkshopContracts.BindingModels;
|
||||
using CarpentryWorkshopContracts.SearchModels;
|
||||
using CarpentryWorkshopContracts.StoragesContracts;
|
||||
using CarpentryWorkshopContracts.ViewModels;
|
||||
using CarpentryWorkshopDatabaseImplement.Models;
|
||||
|
||||
namespace CarpentryWorkshopDatabaseImplement.Implements
|
||||
{
|
||||
public class ClientStorage : IClientStorage
|
||||
{
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Email) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new CarpentryWorkshopDatabase();
|
||||
return context.Clients.FirstOrDefault(x =>
|
||||
(!string.IsNullOrEmpty(model.Email) && x.Email == model.Email)
|
||||
|| (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Email))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new CarpentryWorkshopDatabase();
|
||||
return context.Clients
|
||||
.Where(x => x.Email.Contains(model.Email))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<ClientViewModel> GetFullList()
|
||||
{
|
||||
using var context = new CarpentryWorkshopDatabase();
|
||||
return context.Clients.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public ClientViewModel? Insert(ClientBindingModel model)
|
||||
{
|
||||
var newClient = Client.Create(model);
|
||||
if (newClient == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new CarpentryWorkshopDatabase();
|
||||
context.Clients.Add(newClient);
|
||||
context.SaveChanges();
|
||||
return newClient.GetViewModel;
|
||||
}
|
||||
|
||||
public ClientViewModel? Update(ClientBindingModel model)
|
||||
{
|
||||
using var context = new CarpentryWorkshopDatabase();
|
||||
var client = context.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (client == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
client.Update(model);
|
||||
context.SaveChanges();
|
||||
return client.GetViewModel;
|
||||
}
|
||||
public ClientViewModel? Delete(ClientBindingModel model)
|
||||
{
|
||||
using var context = new CarpentryWorkshopDatabase();
|
||||
var client = context.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (client == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Clients.Remove(client);
|
||||
context.SaveChanges();
|
||||
return client.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -16,19 +16,20 @@ namespace CarpentryWorkshopDatabaseImplement.Implements
|
||||
return null;
|
||||
}
|
||||
using var context = new CarpentryWorkshopDatabase();
|
||||
return context.Orders.Include(x => x.Wood).FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
return context.Orders.Include(x => x.Wood).Include(x => x.Client).FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue)
|
||||
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new CarpentryWorkshopDatabase();
|
||||
return context.Orders
|
||||
.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo)
|
||||
.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo || x.ClientId == model.ClientId)
|
||||
.Include(x => x.Wood)
|
||||
.Include(x => x.Client)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@ -36,7 +37,7 @@ namespace CarpentryWorkshopDatabaseImplement.Implements
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
using var context = new CarpentryWorkshopDatabase();
|
||||
return context.Orders.Include(x => x.Wood).Select(x => x.GetViewModel).ToList();
|
||||
return context.Orders.Include(x => x.Wood).Include(x => x.Client).Select(x => x.GetViewModel).ToList(); ;
|
||||
}
|
||||
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
@ -49,7 +50,7 @@ namespace CarpentryWorkshopDatabaseImplement.Implements
|
||||
using var context = new CarpentryWorkshopDatabase();
|
||||
context.Orders.Add(newOrder);
|
||||
context.SaveChanges();
|
||||
return context.Orders.Include(x => x.Wood).FirstOrDefault(x => x.Id == newOrder.Id)?.GetViewModel;
|
||||
return context.Orders.Include(x => x.Wood).Include(x => x.Client).FirstOrDefault(x => x.Id == newOrder.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
@ -62,7 +63,7 @@ namespace CarpentryWorkshopDatabaseImplement.Implements
|
||||
}
|
||||
order.Update(model);
|
||||
context.SaveChanges();
|
||||
return context.Orders.Include(x => x.Wood).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
return context.Orders.Include(x => x.Wood).Include(x => x.Client).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
|
214
CarpentryWorkshop/CarpentryWorkshopDatabaseImplement/Migrations/20240419085157_MbLab5.Designer.cs
generated
Normal file
214
CarpentryWorkshop/CarpentryWorkshopDatabaseImplement/Migrations/20240419085157_MbLab5.Designer.cs
generated
Normal file
@ -0,0 +1,214 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using CarpentryWorkshopDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CarpentryWorkshopDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(CarpentryWorkshopDatabase))]
|
||||
[Migration("20240419085157_MbLab5")]
|
||||
partial class MbLab5
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.17")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("CarpentryWorkshopDatabaseImplement.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("CarpentryWorkshopDatabaseImplement.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("CarpentryWorkshopDatabaseImplement.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>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("WoodId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("WoodId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarpentryWorkshopDatabaseImplement.Models.Wood", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("WoodName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Woods");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarpentryWorkshopDatabaseImplement.Models.WoodComponent", 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>("WoodId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("WoodId");
|
||||
|
||||
b.ToTable("WoodComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarpentryWorkshopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("CarpentryWorkshopDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CarpentryWorkshopDatabaseImplement.Models.Wood", "Wood")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("WoodId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Wood");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarpentryWorkshopDatabaseImplement.Models.WoodComponent", b =>
|
||||
{
|
||||
b.HasOne("CarpentryWorkshopDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("WoodComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CarpentryWorkshopDatabaseImplement.Models.Wood", "Wood")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("WoodId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Wood");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarpentryWorkshopDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarpentryWorkshopDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("WoodComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarpentryWorkshopDatabaseImplement.Models.Wood", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CarpentryWorkshopDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class MbLab5 : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.Sql("DELETE FROM [dbo].[Orders]");
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ClientId",
|
||||
table: "Orders",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Clients",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ClientFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Clients", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_ClientId",
|
||||
table: "Orders",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Orders_Clients_ClientId",
|
||||
table: "Orders",
|
||||
column: "ClientId",
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Orders_Clients_ClientId",
|
||||
table: "Orders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Clients");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Orders_ClientId",
|
||||
table: "Orders");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ClientId",
|
||||
table: "Orders");
|
||||
}
|
||||
}
|
||||
}
|
@ -22,6 +22,31 @@ namespace CarpentryWorkshopDatabaseImplement.Migrations
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("CarpentryWorkshopDatabaseImplement.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("CarpentryWorkshopDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -50,6 +75,9 @@ namespace CarpentryWorkshopDatabaseImplement.Migrations
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
@ -70,6 +98,8 @@ namespace CarpentryWorkshopDatabaseImplement.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("WoodId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
@ -123,12 +153,20 @@ namespace CarpentryWorkshopDatabaseImplement.Migrations
|
||||
|
||||
modelBuilder.Entity("CarpentryWorkshopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("CarpentryWorkshopDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CarpentryWorkshopDatabaseImplement.Models.Wood", "Wood")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("WoodId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Wood");
|
||||
});
|
||||
|
||||
@ -151,6 +189,11 @@ namespace CarpentryWorkshopDatabaseImplement.Migrations
|
||||
b.Navigation("Wood");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarpentryWorkshopDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarpentryWorkshopDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("WoodComponents");
|
||||
|
@ -0,0 +1,59 @@
|
||||
using CarpentryWorkshopContracts.BindingModels;
|
||||
using CarpentryWorkshopContracts.ViewModels;
|
||||
using CarpentryWorkshopDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace CarpentryWorkshopDatabaseImplement.Models
|
||||
{
|
||||
public class Client : IClientModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
[Required]
|
||||
public string ClientFIO { get; private set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string Email { get; private set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string Password { get; private set; } = string.Empty;
|
||||
|
||||
[ForeignKey("ClientId")]
|
||||
public virtual List<Order> Orders { get; set; } = new();
|
||||
|
||||
public static Client? Create(ClientBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new()
|
||||
{
|
||||
Id = model.Id,
|
||||
ClientFIO = model.ClientFIO,
|
||||
Email = model.Email,
|
||||
Password = model.Password
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ClientBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ClientFIO = model.ClientFIO;
|
||||
Email = model.Email;
|
||||
Password = model.Password;
|
||||
}
|
||||
|
||||
public ClientViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ClientFIO = ClientFIO,
|
||||
Email = Email,
|
||||
Password = Password,
|
||||
};
|
||||
}
|
||||
}
|
@ -11,7 +11,8 @@ namespace CarpentryWorkshopDatabaseImplement.Models
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public int WoodId { get; private set; }
|
||||
|
||||
[Required]
|
||||
public int ClientId { get; private set; }
|
||||
[Required]
|
||||
public int Count { get; private set; }
|
||||
[Required]
|
||||
@ -23,6 +24,7 @@ namespace CarpentryWorkshopDatabaseImplement.Models
|
||||
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
public virtual Wood Wood { get; private set; }
|
||||
public virtual Client Client { get; set; }
|
||||
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
{
|
||||
|
@ -9,9 +9,11 @@ namespace CarpentryWorkshopFileImplement
|
||||
private readonly string ComponentFileName = "Component.xml";
|
||||
private readonly string OrderFileName = "Order.xml";
|
||||
private readonly string WoodFileName = "Wood.xml";
|
||||
private readonly string ClientFileName = "Client.xml";
|
||||
public List<Component> Components { get; private set; }
|
||||
public List<Order> Orders { get; private set; }
|
||||
public List<Wood> Woods { get; private set; }
|
||||
public List<Client> Clients { get; private set; }
|
||||
public static DataFileSingleton GetInstance()
|
||||
{
|
||||
if (instance == null)
|
||||
@ -26,6 +28,8 @@ namespace CarpentryWorkshopFileImplement
|
||||
"Woods", x => x.GetXElement);
|
||||
public void SaveOrders() => SaveData(Orders, OrderFileName,
|
||||
"Orders", x => x.GetXElement);
|
||||
public void SaveClients() => SaveData(Clients, ClientFileName,
|
||||
"Clients", x => x.GetXElement);
|
||||
private DataFileSingleton()
|
||||
{
|
||||
Components = LoadData(ComponentFileName, "Component", x =>
|
||||
@ -34,6 +38,8 @@ namespace CarpentryWorkshopFileImplement
|
||||
Wood.Create(x)!)!;
|
||||
Orders = LoadData(OrderFileName, "Order", x =>
|
||||
Order.Create(x)!)!;
|
||||
Clients = LoadData(ClientFileName, "Client", x =>
|
||||
Client.Create(x)!)!;
|
||||
}
|
||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName,
|
||||
Func<XElement, T> selectFunction)
|
||||
|
@ -0,0 +1,81 @@
|
||||
using CarpentryWorkshopContracts.BindingModels;
|
||||
using CarpentryWorkshopContracts.SearchModels;
|
||||
using CarpentryWorkshopContracts.StoragesContracts;
|
||||
using CarpentryWorkshopContracts.ViewModels;
|
||||
using CarpentryWorkshopFileImplement.Models;
|
||||
|
||||
namespace CarpentryWorkshopFileImplement.Implements
|
||||
{
|
||||
public class ClientStorage : IClientStorage
|
||||
{
|
||||
private readonly DataFileSingleton source;
|
||||
public ClientStorage()
|
||||
{
|
||||
source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Email) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return source.Clients
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Email) && x.Email == model.Email) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Email))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return source.Clients
|
||||
.Where(x => x.Email.Contains(model.Email))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<ClientViewModel> GetFullList()
|
||||
{
|
||||
return source.Clients.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public ClientViewModel? Insert(ClientBindingModel model)
|
||||
{
|
||||
model.Id = source.Clients.Count > 0 ? source.Clients.Max(x => x.Id) + 1 : 1;
|
||||
var newClient = Client.Create(model);
|
||||
if (newClient == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
source.Clients.Add(newClient);
|
||||
source.SaveClients();
|
||||
return newClient.GetViewModel;
|
||||
}
|
||||
|
||||
public ClientViewModel? Update(ClientBindingModel model)
|
||||
{
|
||||
var client = source.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (client == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
client.Update(model);
|
||||
source.SaveClients();
|
||||
return client?.GetViewModel;
|
||||
}
|
||||
|
||||
public ClientViewModel? Delete(ClientBindingModel model)
|
||||
{
|
||||
var client = source.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (client == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
source.Clients.Remove(client);
|
||||
source.SaveClients();
|
||||
return client?.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
using CarpentryWorkshopContracts.BindingModels;
|
||||
using CarpentryWorkshopContracts.ViewModels;
|
||||
using CarpentryWorkshopDataModels.Models;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace CarpentryWorkshopFileImplement.Models
|
||||
{
|
||||
public class Client : IClientModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
public string ClientFIO { get; private set; } = string.Empty;
|
||||
|
||||
public string Email { get; private set; } = string.Empty;
|
||||
|
||||
public string Password { get; private set; } = string.Empty;
|
||||
|
||||
public static Client? Create(ClientBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new()
|
||||
{
|
||||
Id = model.Id,
|
||||
ClientFIO = model.ClientFIO,
|
||||
Email = model.Email,
|
||||
Password = model.Password
|
||||
};
|
||||
}
|
||||
public static Client? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
ClientFIO = element.Element("FIO")!.Value,
|
||||
Email = element.Element("Email")!.Value,
|
||||
Password = element.Element("Password")!.Value,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public void Update(ClientBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ClientFIO = model.ClientFIO;
|
||||
Email = model.Email;
|
||||
Password = model.Password;
|
||||
}
|
||||
|
||||
public ClientViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ClientFIO = ClientFIO,
|
||||
Email = Email,
|
||||
Password = Password,
|
||||
};
|
||||
|
||||
public XElement GetXElement => new("Client",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("FIO", ClientFIO),
|
||||
new XElement("Email", Email),
|
||||
new XElement("Password", Password)
|
||||
);
|
||||
}
|
||||
}
|
@ -8,11 +8,13 @@ namespace CarpentryWorkshopListImplement
|
||||
public List<Component> Components { get; set; }
|
||||
public List<Order> Orders { get; set; }
|
||||
public List<Wood> Woods { get; set; }
|
||||
public List<Client> Clients { get; set; }
|
||||
private DataListSingleton()
|
||||
{
|
||||
Components = new List<Component>();
|
||||
Orders = new List<Order>();
|
||||
Woods = new List<Wood>();
|
||||
Clients = new List<Client>();
|
||||
}
|
||||
public static DataListSingleton GetInstance()
|
||||
{
|
||||
|
@ -0,0 +1,99 @@
|
||||
using CarpentryWorkshopContracts.BindingModels;
|
||||
using CarpentryWorkshopContracts.SearchModels;
|
||||
using CarpentryWorkshopContracts.StoragesContracts;
|
||||
using CarpentryWorkshopContracts.ViewModels;
|
||||
using CarpentryWorkshopListImplement.Models;
|
||||
|
||||
namespace CarpentryWorkshopListImplement.Implements
|
||||
{
|
||||
public class ClientStorage : IClientStorage
|
||||
{
|
||||
private readonly DataListSingleton _source;
|
||||
public ClientStorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Email) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var client in _source.Clients)
|
||||
{
|
||||
if ((!string.IsNullOrEmpty(model.Email) && client.Email == model.Email) || (model.Id.HasValue && client.Id == model.Id))
|
||||
{
|
||||
return client.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||
{
|
||||
var result = new List<ClientViewModel>();
|
||||
if (string.IsNullOrEmpty(model.Email))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
var client = GetElement(model);
|
||||
if (client != null) result.Add(client);
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<ClientViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<ClientViewModel>();
|
||||
foreach (var client in _source.Clients)
|
||||
{
|
||||
result.Add(client.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public ClientViewModel? Insert(ClientBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
foreach (var client in _source.Clients)
|
||||
{
|
||||
if (model.Id <= client.Id)
|
||||
{
|
||||
model.Id = client.Id + 1;
|
||||
}
|
||||
}
|
||||
var res = Client.Create(model);
|
||||
if (res != null)
|
||||
{
|
||||
_source.Clients.Add(res);
|
||||
}
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
|
||||
public ClientViewModel? Update(ClientBindingModel model)
|
||||
{
|
||||
foreach (var client in _source.Clients)
|
||||
{
|
||||
if (client.Id == model.Id)
|
||||
{
|
||||
client.Update(model);
|
||||
return client.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public ClientViewModel? Delete(ClientBindingModel model)
|
||||
{
|
||||
for (int i = 0; i < _source.Clients.Count; ++i)
|
||||
{
|
||||
if (_source.Clients[i].Id == model.Id)
|
||||
{
|
||||
var element = _source.Clients[i];
|
||||
_source.Clients.RemoveAt(i);
|
||||
return element.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
using CarpentryWorkshopContracts.BindingModels;
|
||||
using CarpentryWorkshopContracts.ViewModels;
|
||||
using CarpentryWorkshopDataModels.Models;
|
||||
|
||||
namespace CarpentryWorkshopListImplement.Models
|
||||
{
|
||||
public class Client : IClientModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
public string ClientFIO { get; private set; } = string.Empty;
|
||||
|
||||
public string Email { get; private set; } = string.Empty;
|
||||
|
||||
public string Password { get; private set; } = string.Empty;
|
||||
|
||||
public static Client? Create(ClientBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new()
|
||||
{
|
||||
Id = model.Id,
|
||||
ClientFIO = model.ClientFIO,
|
||||
Email = model.Email,
|
||||
Password = model.Password
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ClientBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ClientFIO = model.ClientFIO;
|
||||
Email = model.Email;
|
||||
Password = model.Password;
|
||||
}
|
||||
|
||||
public ClientViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ClientFIO = ClientFIO,
|
||||
Email = Email,
|
||||
Password = Password,
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="8.0.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Controllers\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CarpentryWorkshopBusinessLogic\CarpentryWorkshopBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\CarpentryWorkshopDatabaseImplement\CarpentryWorkshopDatabaseImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
46
CarpentryWorkshop/CarpentryWorkshopRestApi/Program.cs
Normal file
46
CarpentryWorkshop/CarpentryWorkshopRestApi/Program.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using CarpentryWorkshopBusinessLogic.BusinessLogics;
|
||||
using CarpentryWorkshopContracts.BusinessLogicsContracts;
|
||||
using CarpentryWorkshopContracts.StoragesContracts;
|
||||
using CarpentryWorkshopDatabaseImplement.Implements;
|
||||
|
||||
using Microsoft.OpenApi.Models;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Logging.SetMinimumLevel(LogLevel.Trace);
|
||||
builder.Logging.AddLog4Net("log4net.config");
|
||||
// Add services to the container.
|
||||
builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
||||
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
builder.Services.AddTransient<IWoodStorage, WoodStorage>();
|
||||
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
||||
builder.Services.AddTransient<IWoodLogic, WoodLogic>();
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at
|
||||
https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen(c =>
|
||||
{
|
||||
c.SwaggerDoc("v1", new OpenApiInfo
|
||||
{
|
||||
Title = "CarpentryWorkshopRestApi",
|
||||
Version = "v1"
|
||||
});
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "CarpentryWorkshopRestApi v1"));
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
@ -0,0 +1,31 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:58874",
|
||||
"sslPort": 44387
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"CarpentryWorkshopRestApi": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "https://localhost:7115;http://localhost:5073",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
16
CarpentryWorkshop/CarpentryWorkshopRestApi/log4net.config
Normal file
16
CarpentryWorkshop/CarpentryWorkshopRestApi/log4net.config
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<log4net>
|
||||
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
|
||||
<file value="c:/temp/PrecastConcretePlantRestApi.log" />
|
||||
<appendToFile value="true" />
|
||||
<maximumFileSize value="100KB" />
|
||||
<maxSizeRollBackups value="2" />
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<conversionPattern value="%date %5level %logger.%method [%line] - MESSAGE: %message%newline %exception" />
|
||||
</layout>
|
||||
</appender>
|
||||
<root>
|
||||
<level value="TRACE" />
|
||||
<appender-ref ref="RollingFile" />
|
||||
</root>
|
||||
</log4net>
|
Loading…
Reference in New Issue
Block a user