migrate projects
This commit is contained in:
parent
e64e758621
commit
7c3053bbea
FurnitureAssembly
DataModels
FurnitureAssembly.slnFurnitureAssembly
FurnitureAssemblyContracts
BindingModels
FurnitureBindingModel.csFurnitureModuleBindingModel.csMaterialBindingModel.csOrderBindingModel.csReportBindingModel.csRoleBindingModel.csScopeBindingModel.csSetBindingModel.csUserBindingModel.cs
BusinessLogicContracts
IFurnitureLogic.csIFurnitureModuleLogic.csIMaterialLogic.csIOrderLogic.csIReportLogic.csIRoleLogic.csIScopeLogic.csISetLogic.csIUserLogic.cs
FurnitureAssemblyContracts.csprojSearchModels
FurnitureModuleSearchModel.csFurnitureSearchModel.csMaterialSearchModel.csOrderSearchModel.csRoleSearchModel.csScopeSearchModel.csSetSearchModel.csUserSearchModel.cs
StorageContracts
IFurnitureModuleStorage.csIFurnitureStorage.csIMaterialStorage.csIOrderStorage.csIRoleStorage.csIScopeStorage.csISetStorage.csIUserStorage.cs
ViewModels
FurnitureAssemblyDataModels
FurnitureAssemblyDatabaseImplement
FurnitureAssemblyDatabase.csFurnitureAssemblyDatabaseImplement.csproj
Implements
FurnitureModuleStorage.csFurnitureStorage.csMaterialStorage.csOrderStorage.csScopeStorage.csSetStorage.csUserStorage.cs
Migrations
Models
FurnitureAssembly_StorekeeperBusinessLogic/BusinessLogics
9
FurnitureAssembly/DataModels/DataModels.csproj
Normal file
9
FurnitureAssembly/DataModels/DataModels.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
16
FurnitureAssembly/DataModels/Enums/PaymentType.cs
Normal file
16
FurnitureAssembly/DataModels/Enums/PaymentType.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssembly_WorkerDataModels.Enums
|
||||
{
|
||||
public enum PaymentType
|
||||
{
|
||||
Неизвестен = -1,
|
||||
Наличными = 0,
|
||||
Картой = 1,
|
||||
Смешанный = 2
|
||||
}
|
||||
}
|
13
FurnitureAssembly/DataModels/IId.cs
Normal file
13
FurnitureAssembly/DataModels/IId.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssembly_WorkerDataModels
|
||||
{
|
||||
public interface IId
|
||||
{
|
||||
int Id { get; }
|
||||
}
|
||||
}
|
17
FurnitureAssembly/DataModels/Models/IFurnitureModel.cs
Normal file
17
FurnitureAssembly/DataModels/Models/IFurnitureModel.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssembly_WorkerDataModels.Models
|
||||
{
|
||||
public interface IFurnitureModel : IId
|
||||
{
|
||||
string Name { get; }
|
||||
double Cost { get; }
|
||||
DateTime DateCreate { get; }
|
||||
Dictionary<int, (IMaterialModel, int)> FurnitureMaterials { get; }
|
||||
int UserId { get; }
|
||||
}
|
||||
}
|
17
FurnitureAssembly/DataModels/Models/IFurnitureModuleModel.cs
Normal file
17
FurnitureAssembly/DataModels/Models/IFurnitureModuleModel.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssembly_WorkerDataModels.Models
|
||||
{
|
||||
public interface IFurnitureModuleModel : IId
|
||||
{
|
||||
string Name { get; }
|
||||
double Cost { get; }
|
||||
DateTime DateCreate { get; }
|
||||
int UserId { get; }
|
||||
Dictionary<int, (IFurnitureModel, int)> FurnitureModuleFurnitures { get; }
|
||||
}
|
||||
}
|
17
FurnitureAssembly/DataModels/Models/IMaterialModel.cs
Normal file
17
FurnitureAssembly/DataModels/Models/IMaterialModel.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Formats.Asn1.AsnWriter;
|
||||
|
||||
namespace FurnitureAssembly_WorkerDataModels.Models
|
||||
{
|
||||
public interface IMaterialModel : IId
|
||||
{
|
||||
string Name { get; }
|
||||
double Cost { get; }
|
||||
int ScopeId { get; }
|
||||
int UserId { get; }
|
||||
}
|
||||
}
|
19
FurnitureAssembly/DataModels/Models/IOrderModel.cs
Normal file
19
FurnitureAssembly/DataModels/Models/IOrderModel.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using FurnitureAssembly_WorkerDataModels.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssembly_WorkerDataModels.Models
|
||||
{
|
||||
public interface IOrderModel : IId
|
||||
{
|
||||
string CustomerName { get; }
|
||||
PaymentType PaymentType { get; }
|
||||
int SetId { get; }
|
||||
int UserId { get; }
|
||||
double Sum { get; }
|
||||
DateTime DateCreate { get; }
|
||||
}
|
||||
}
|
13
FurnitureAssembly/DataModels/Models/IRoleModel.cs
Normal file
13
FurnitureAssembly/DataModels/Models/IRoleModel.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssembly_WorkerDataModels.Models
|
||||
{
|
||||
public interface IRoleModel : IId
|
||||
{
|
||||
string Name { get; }
|
||||
}
|
||||
}
|
13
FurnitureAssembly/DataModels/Models/IScopeModel.cs
Normal file
13
FurnitureAssembly/DataModels/Models/IScopeModel.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssembly_WorkerDataModels.Models
|
||||
{
|
||||
public interface IScopeModel : IId
|
||||
{
|
||||
string Name { get; }
|
||||
}
|
||||
}
|
17
FurnitureAssembly/DataModels/Models/ISetModel.cs
Normal file
17
FurnitureAssembly/DataModels/Models/ISetModel.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssembly_WorkerDataModels.Models
|
||||
{
|
||||
public interface ISetModel : IId
|
||||
{
|
||||
string Name { get; }
|
||||
double Cost { get; }
|
||||
DateTime DateCreate { get; }
|
||||
int UserId { get; }
|
||||
Dictionary<int, (IFurnitureModuleModel, int)> SetFurnitureModules { get; }
|
||||
}
|
||||
}
|
17
FurnitureAssembly/DataModels/Models/IUserModel.cs
Normal file
17
FurnitureAssembly/DataModels/Models/IUserModel.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssembly_WorkerDataModels.Models
|
||||
{
|
||||
public interface IUserModel : IId
|
||||
{
|
||||
string Login { get; }
|
||||
string Password { get; }
|
||||
string Name { get; }
|
||||
int RoleId { get; }
|
||||
}
|
||||
}
|
25
FurnitureAssembly/FurnitureAssembly.sln
Normal file
25
FurnitureAssembly/FurnitureAssembly.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.5.33530.505
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FurnitureAssemblyDatabaseImplement", "FurnitureAssemblyDatabaseImplement\FurnitureAssemblyDatabaseImplement.csproj", "{DA551811-3214-4ACF-AFF2-ABBB03433197}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{DA551811-3214-4ACF-AFF2-ABBB03433197}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DA551811-3214-4ACF-AFF2-ABBB03433197}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DA551811-3214-4ACF-AFF2-ABBB03433197}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DA551811-3214-4ACF-AFF2-ABBB03433197}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {2DBF98A2-C7D8-4D99-9286-74F059FA57AA}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
39
FurnitureAssembly/FurnitureAssembly/Form1.Designer.cs
generated
Normal file
39
FurnitureAssembly/FurnitureAssembly/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,39 @@
|
||||
namespace FurnitureAssembly
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "Form1";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
10
FurnitureAssembly/FurnitureAssembly/Form1.cs
Normal file
10
FurnitureAssembly/FurnitureAssembly/Form1.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace FurnitureAssembly
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
120
FurnitureAssembly/FurnitureAssembly/Form1.resx
Normal file
120
FurnitureAssembly/FurnitureAssembly/Form1.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>
|
11
FurnitureAssembly/FurnitureAssembly/FurnitureAssembly.csproj
Normal file
11
FurnitureAssembly/FurnitureAssembly/FurnitureAssembly.csproj
Normal file
@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
17
FurnitureAssembly/FurnitureAssembly/Program.cs
Normal file
17
FurnitureAssembly/FurnitureAssembly/Program.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace FurnitureAssembly
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BindingModels
|
||||
{
|
||||
public class FurnitureBindingModel : IFurnitureModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public double Cost { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
public Dictionary<int, (IMaterialModel, int)> FurnitureMaterials { get; set; } = new();
|
||||
}
|
||||
}
|
21
FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/FurnitureModuleBindingModel.cs
Normal file
21
FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/FurnitureModuleBindingModel.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BindingModels
|
||||
{
|
||||
public class FurnitureModuleBindingModel : IFurnitureModuleModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public double Cost { get; set; }
|
||||
public DateTime DateCreate { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public Dictionary<int, (IFurnitureModel, int)> FurnitureModuleFurnitures { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Formats.Asn1.AsnWriter;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BindingModels
|
||||
{
|
||||
public class MaterialBindingModel : IMaterialModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public double Cost { get; set; }
|
||||
public int ScopeId { get; set; }
|
||||
public int UserId { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyDataModels.Enums;
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BindingModels
|
||||
{
|
||||
public class OrderBindingModel : IOrderModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string CustomerName { get; set; } = string.Empty;
|
||||
public PaymentType PaymentType { get; set; } = PaymentType.Неизвестен;
|
||||
public int SetId { get; set; }
|
||||
public DateTime DateCreate { get; set; }
|
||||
public double Sum { get; set; }
|
||||
public int UserId { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BindingModels
|
||||
{
|
||||
public class ReportBindingModel
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BindingModels
|
||||
{
|
||||
public class RoleBindingModel : IRoleModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Formats.Asn1.AsnWriter;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BindingModels
|
||||
{
|
||||
public class ScopeBindingModel : IScopeModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BindingModels
|
||||
{
|
||||
public class SetBindingModel : ISetModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public double Cost { get; set; }
|
||||
public DateTime DateCreate { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public Dictionary<int, (IFurnitureModuleModel, int)> SetFurnitureModules { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BindingModels
|
||||
{
|
||||
public class UserBindingModel : IUserModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Login { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public int RoleId { get; set; }
|
||||
}
|
||||
}
|
20
FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicContracts/IFurnitureLogic.cs
Normal file
20
FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicContracts/IFurnitureLogic.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IFurnitureLogic
|
||||
{
|
||||
List<FurnitureViewModel>? ReadList(FurnitureSearchModel? model);
|
||||
FurnitureViewModel? ReadElement(FurnitureSearchModel model);
|
||||
bool Create(FurnitureBindingModel model);
|
||||
bool Update(FurnitureBindingModel model);
|
||||
bool Delete(FurnitureBindingModel model);
|
||||
}
|
||||
}
|
20
FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicContracts/IFurnitureModuleLogic.cs
Normal file
20
FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicContracts/IFurnitureModuleLogic.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IFurnitureModuleLogic
|
||||
{
|
||||
List<FurnitureModuleViewModel>? ReadList(FurnitureModuleSearchModel? model);
|
||||
FurnitureModuleViewModel? ReadElement(FurnitureModuleSearchModel model);
|
||||
bool Create(FurnitureModuleBindingModel model);
|
||||
bool Update(FurnitureModuleBindingModel model);
|
||||
bool Delete(FurnitureModuleBindingModel model);
|
||||
}
|
||||
}
|
20
FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicContracts/IMaterialLogic.cs
Normal file
20
FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicContracts/IMaterialLogic.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IMaterialLogic
|
||||
{
|
||||
List<MaterialViewModel>? ReadList(MaterialSearchModel? model);
|
||||
MaterialViewModel? ReadElement(MaterialSearchModel model);
|
||||
bool Create(MaterialBindingModel model);
|
||||
bool Update(MaterialBindingModel model);
|
||||
bool Delete(MaterialBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IOrderLogic
|
||||
{
|
||||
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
||||
OrderViewModel? ReadElement(OrderSearchModel model);
|
||||
bool Create(OrderBindingModel model);
|
||||
bool Update(OrderBindingModel model);
|
||||
bool Delete(OrderBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IReportLogic
|
||||
{
|
||||
/// <summary>
|
||||
/// Получение списка мебельных модулей с указанием, в каких гарнитурах используются
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
List<ReportSetFurnitureModuleViewModel> GetSetFurnitureModule();
|
||||
/// <summary>
|
||||
/// Получение списка заказов за определенный период
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
List<ReportOrdersViewModel> GetOrders(ReportBindingModel model);
|
||||
/// <summary>
|
||||
/// Сохранение материалов в файл-Word
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
void SaveFurnitureModuleToWordFile(ReportBindingModel model);
|
||||
/// <summary>
|
||||
/// Сохранение материалов с указаеним мебельных модулей в файл-Excel
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
void SaveSetFurnitureModuleToExcelFile(ReportBindingModel model);
|
||||
/// <summary>
|
||||
/// Сохранение заказов в файл-Pdf
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
void SaveOrdersToPdfFile(ReportBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IRoleLogic
|
||||
{
|
||||
List<RoleViewModel>? ReadList(RoleSearchModel? model);
|
||||
RoleViewModel? ReadElement(RoleSearchModel model);
|
||||
bool Create(RoleBindingModel model);
|
||||
bool Update(RoleBindingModel model);
|
||||
bool Delete(RoleBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IScopeLogic
|
||||
{
|
||||
List<ScopeViewModel>? ReadList(ScopeSearchModel? model);
|
||||
ScopeViewModel? ReadElement(ScopeSearchModel model);
|
||||
bool Create(ScopeBindingModel model);
|
||||
bool Update(ScopeBindingModel model);
|
||||
bool Delete(ScopeBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface ISetLogic
|
||||
{
|
||||
List<SetViewModel>? ReadList(SetSearchModel? model);
|
||||
SetViewModel? ReadElement(SetSearchModel model);
|
||||
bool Create(SetBindingModel model);
|
||||
bool Update(SetBindingModel model);
|
||||
bool Delete(SetBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IUserLogic
|
||||
{
|
||||
List<UserViewModel>? ReadList(UserSearchModel? model);
|
||||
UserViewModel? ReadElement(UserSearchModel model);
|
||||
bool Create(UserBindingModel model);
|
||||
bool Update(UserBindingModel model);
|
||||
bool Delete(UserBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
15
FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/FurnitureModuleSearchModel.cs
Normal file
15
FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/FurnitureModuleSearchModel.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.SearchModels
|
||||
{
|
||||
public class FurnitureModuleSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public int? UserId { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.SearchModels
|
||||
{
|
||||
public class FurnitureSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public int? UserId { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.SearchModels
|
||||
{
|
||||
public class MaterialSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public int? UserId { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.SearchModels
|
||||
{
|
||||
public class OrderSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? UserId { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.SearchModels
|
||||
{
|
||||
public class RoleSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.SearchModels
|
||||
{
|
||||
public class ScopeSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.SearchModels
|
||||
{
|
||||
public class SetSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public int? UserId { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.SearchModels
|
||||
{
|
||||
public class UserSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? RoleId { get; set; }
|
||||
public string? Login { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Password { get; set; }
|
||||
}
|
||||
}
|
21
FurnitureAssembly/FurnitureAssemblyContracts/StorageContracts/IFurnitureModuleStorage.cs
Normal file
21
FurnitureAssembly/FurnitureAssemblyContracts/StorageContracts/IFurnitureModuleStorage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.StorageContracts
|
||||
{
|
||||
public interface IFurnitureModuleStorage
|
||||
{
|
||||
List<FurnitureModuleViewModel> GetFullList();
|
||||
List<FurnitureModuleViewModel> GetFilteredList(FurnitureModuleSearchModel model);
|
||||
FurnitureModuleViewModel? GetElement(FurnitureModuleSearchModel model);
|
||||
FurnitureModuleViewModel? Insert(FurnitureModuleBindingModel model);
|
||||
FurnitureModuleViewModel? Update(FurnitureModuleBindingModel model);
|
||||
FurnitureModuleViewModel? Delete(FurnitureModuleBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.StorageContracts
|
||||
{
|
||||
public interface IFurnitureStorage
|
||||
{
|
||||
List<FurnitureViewModel> GetFullList();
|
||||
List<FurnitureViewModel> GetFilteredList(FurnitureSearchModel model);
|
||||
FurnitureViewModel? GetElement(FurnitureSearchModel model);
|
||||
FurnitureViewModel? Insert(FurnitureBindingModel model);
|
||||
FurnitureViewModel? Update(FurnitureBindingModel model);
|
||||
FurnitureViewModel? Delete(FurnitureBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.StorageContracts
|
||||
{
|
||||
public interface IMaterialStorage
|
||||
{
|
||||
List<MaterialViewModel> GetFullList();
|
||||
List<MaterialViewModel> GetFilteredList(MaterialSearchModel model);
|
||||
MaterialViewModel? GetElement(MaterialSearchModel model);
|
||||
MaterialViewModel? Insert(MaterialBindingModel model);
|
||||
MaterialViewModel? Update(MaterialBindingModel model);
|
||||
MaterialViewModel? Delete(MaterialBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.StorageContracts
|
||||
{
|
||||
public interface IOrderStorage
|
||||
{
|
||||
List<OrderViewModel> GetFullList();
|
||||
List<OrderViewModel> GetFilteredList(OrderSearchModel model);
|
||||
OrderViewModel? GetElement(OrderSearchModel model);
|
||||
OrderViewModel? Insert(OrderBindingModel model);
|
||||
OrderViewModel? Update(OrderBindingModel model);
|
||||
OrderViewModel? Delete(OrderBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.StorageContracts
|
||||
{
|
||||
public interface IRoleStorage
|
||||
{
|
||||
List<RoleViewModel> GetFullList();
|
||||
List<RoleViewModel> GetFilteredList(RoleSearchModel model);
|
||||
RoleViewModel? GetElement(RoleSearchModel model);
|
||||
RoleViewModel? Insert(RoleBindingModel model);
|
||||
RoleViewModel? Update(RoleBindingModel model);
|
||||
RoleViewModel? Delete(RoleBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.StorageContracts
|
||||
{
|
||||
public interface IScopeStorage
|
||||
{
|
||||
List<ScopeViewModel> GetFullList();
|
||||
List<ScopeViewModel> GetFilteredList(ScopeSearchModel model);
|
||||
ScopeViewModel? GetElement(ScopeSearchModel model);
|
||||
ScopeViewModel? Insert(ScopeBindingModel model);
|
||||
ScopeViewModel? Update(ScopeBindingModel model);
|
||||
ScopeViewModel? Delete(ScopeBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.StorageContracts
|
||||
{
|
||||
public interface ISetStorage
|
||||
{
|
||||
List<SetViewModel> GetFullList();
|
||||
List<SetViewModel> GetFilteredList(SetSearchModel model);
|
||||
SetViewModel? GetElement(SetSearchModel model);
|
||||
SetViewModel? Insert(SetBindingModel model);
|
||||
SetViewModel? Update(SetBindingModel model);
|
||||
SetViewModel? Delete(SetBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.StorageContracts
|
||||
{
|
||||
public interface IUserStorage
|
||||
{
|
||||
List<UserViewModel> GetFullList();
|
||||
List<UserViewModel> GetFilteredList(UserSearchModel model);
|
||||
UserViewModel? GetElement(UserSearchModel model);
|
||||
UserViewModel? Insert(UserBindingModel model);
|
||||
UserViewModel? Update(UserBindingModel model);
|
||||
UserViewModel? Delete(UserBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace FurnitureAssemblyContracts.ViewModels
|
||||
{
|
||||
public class FurnitureModuleViewModel : IFurnitureModuleModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название модуля")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[DisplayName("Цена модуля")]
|
||||
public double Cost { get; set; }
|
||||
[DisplayName("Дата создания")]
|
||||
public DateTime DateCreate { get; set; }
|
||||
public int UserId { get; set; }
|
||||
[DisplayName("Изготовитель")]
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
public Dictionary<int, (IFurnitureModel, int)> FurnitureModuleFurnitures { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.ViewModels
|
||||
{
|
||||
public class FurnitureViewModel : IFurnitureModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название изделия")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[DisplayName("Цена изделия")]
|
||||
public double Cost { get; set; }
|
||||
[DisplayName("Дата создания")]
|
||||
public DateTime DateCreate { get; set; }
|
||||
public Dictionary<int, (IMaterialModel, int)> FurnitureMaterials { get; set; } = new();
|
||||
public int UserId { get; set; }
|
||||
[DisplayName("Изготовитель")]
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.ViewModels
|
||||
{
|
||||
public class MaterialViewModel : IMaterialModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название материала")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[DisplayName("Стоимость материала")]
|
||||
public double Cost { get; set; }
|
||||
public int ScopeId { get; set; }
|
||||
[DisplayName("Область применения")]
|
||||
public string ScopeName { get; set; } = string.Empty;
|
||||
public int UserId { get; set; }
|
||||
[DisplayName("Изготовитель")]
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
using FurnitureAssemblyDataModels.Enums;
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.ViewModels
|
||||
{
|
||||
public class OrderViewModel : IOrderModel
|
||||
{
|
||||
[DisplayName("Номер")]
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Имя заказчика")]
|
||||
public string CustomerName { get; set; } = string.Empty;
|
||||
[DisplayName("Тип оплаты")]
|
||||
public PaymentType PaymentType { get; set; } = PaymentType.Неизвестен;
|
||||
public int SetId { get; set; }
|
||||
[DisplayName("Гарнитур")]
|
||||
public string SetName { get; set; } = string.Empty;
|
||||
[DisplayName("Дата создания")]
|
||||
public DateTime DateCreate { get; set; }
|
||||
[DisplayName("Сумма")]
|
||||
public double Sum { get; set; }
|
||||
public int UserId { get; set; }
|
||||
[DisplayName("Менеджер")]
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.ViewModels
|
||||
{
|
||||
public class ReportOrdersViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public DateTime DateCreate { get; set; }
|
||||
public string SetName { get; set; } = string.Empty;
|
||||
public List<(string Name, double Cost)> FurnitureModules { get; set; } = new();
|
||||
public int TotalCount { get; set; }
|
||||
public double Sum { get; set; }
|
||||
}
|
||||
}
|
15
FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ReportSetFurnitureModuleViewModel.cs
Normal file
15
FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ReportSetFurnitureModuleViewModel.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.ViewModels
|
||||
{
|
||||
public class ReportSetFurnitureModuleViewModel
|
||||
{
|
||||
public string SetName { get; set; } = string.Empty;
|
||||
public int TotalCount { get; set; }
|
||||
public List<(string FurnitureModule, int Count)> FurnitureModules { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.ViewModels
|
||||
{
|
||||
public class RoleViewModel : IRoleModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название роли")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.ViewModels
|
||||
{
|
||||
public class ScopeViewModel : IScopeModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название области применения")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.ViewModels
|
||||
{
|
||||
public class SetViewModel : ISetModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название гарнитура")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[DisplayName("Стоимость гарнитура")]
|
||||
public double Cost { get; set; }
|
||||
[DisplayName("Дата создания")]
|
||||
public DateTime DateCreate { get; set; }
|
||||
public int UserId { get; set; }
|
||||
[DisplayName("Менеджер")]
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
public Dictionary<int, (IFurnitureModuleModel, int)> SetFurnitureModules { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.ViewModels
|
||||
{
|
||||
public class UserViewModel : IUserModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Пароль")]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
[DisplayName("Логин (эл. почта)")]
|
||||
public string Login { get; set; } = string.Empty;
|
||||
[DisplayName("ФИО пользователя")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public int RoleId { get; set; }
|
||||
[DisplayName("Роль пользователя")]
|
||||
public string RoleName { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDataModels.Enums
|
||||
{
|
||||
public enum PaymentType
|
||||
{
|
||||
Неизвестен = -1,
|
||||
Наличными = 0,
|
||||
Картой = 1,
|
||||
Смешанный = 2
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
13
FurnitureAssembly/FurnitureAssemblyDataModels/IId.cs
Normal file
13
FurnitureAssembly/FurnitureAssemblyDataModels/IId.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDataModels
|
||||
{
|
||||
public interface IId
|
||||
{
|
||||
int Id { get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDataModels.Models
|
||||
{
|
||||
public interface IFurnitureModel : IId
|
||||
{
|
||||
string Name { get; }
|
||||
double Cost { get; }
|
||||
DateTime DateCreate { get; }
|
||||
Dictionary<int, (IMaterialModel, int)> FurnitureMaterials { get; }
|
||||
int UserId { get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDataModels.Models
|
||||
{
|
||||
public interface IFurnitureModuleModel : IId
|
||||
{
|
||||
string Name { get; }
|
||||
double Cost { get; }
|
||||
DateTime DateCreate { get; }
|
||||
int UserId { get; }
|
||||
Dictionary<int, (IFurnitureModel, int)> FurnitureModuleFurnitures { get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Formats.Asn1.AsnWriter;
|
||||
|
||||
namespace FurnitureAssemblyDataModels.Models
|
||||
{
|
||||
public interface IMaterialModel : IId
|
||||
{
|
||||
string Name { get; }
|
||||
double Cost { get; }
|
||||
int ScopeId { get; }
|
||||
int UserId { get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
using FurnitureAssemblyDataModels.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDataModels.Models
|
||||
{
|
||||
public interface IOrderModel : IId
|
||||
{
|
||||
string CustomerName { get; }
|
||||
PaymentType PaymentType { get; }
|
||||
int SetId { get; }
|
||||
int UserId { get; }
|
||||
double Sum { get; }
|
||||
DateTime DateCreate { get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDataModels.Models
|
||||
{
|
||||
public interface IRoleModel : IId
|
||||
{
|
||||
string Name { get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDataModels.Models
|
||||
{
|
||||
public interface IScopeModel : IId
|
||||
{
|
||||
string Name { get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDataModels.Models
|
||||
{
|
||||
public interface ISetModel : IId
|
||||
{
|
||||
string Name { get; }
|
||||
double Cost { get; }
|
||||
DateTime DateCreate { get; }
|
||||
int UserId { get; }
|
||||
Dictionary<int, (IFurnitureModuleModel, int)> SetFurnitureModules { get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDataModels.Models
|
||||
{
|
||||
public interface IUserModel : IId
|
||||
{
|
||||
string Login { get; }
|
||||
string Password { get; }
|
||||
string Name { get; }
|
||||
int RoleId { get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
using FurnitureAssemblyDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement
|
||||
{
|
||||
public class FurnitureAssemblyDatabase : DbContext
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseNpgsql("Host=zyzf.space;Port=5434;Database=kursach;Username=postgres;Password=kursach");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
public virtual DbSet<Set> Sets { get; set; }
|
||||
public virtual DbSet<SetFurnitureModule> SetFurnitureModules { get; set; }
|
||||
public virtual DbSet<FurnitureModule> FurnitureModules { get; set; }
|
||||
public virtual DbSet<FurnitureModuleFurniture> FurnitureModuleFurnitures { get; set; }
|
||||
public virtual DbSet<Furniture> Furnitures { get; set; }
|
||||
public virtual DbSet<FurnitureMaterial> FurnitureMaterials { get; set; }
|
||||
public virtual DbSet<Material> Materials { get; set; }
|
||||
public virtual DbSet<Role> Roles { get; set; }
|
||||
public virtual DbSet<Scope> Scopes { get; set; }
|
||||
public virtual DbSet<User> Users { get; set; }
|
||||
public virtual DbSet<Order> Orders { get; set; }
|
||||
}
|
||||
}
|
9
FurnitureAssembly/FurnitureAssemblyDatabaseImplement/FurnitureAssemblyDatabaseImplement.csproj
Normal file
9
FurnitureAssembly/FurnitureAssemblyDatabaseImplement/FurnitureAssemblyDatabaseImplement.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
119
FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Implements/FurnitureModuleStorage.cs
Normal file
119
FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Implements/FurnitureModuleStorage.cs
Normal file
@ -0,0 +1,119 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.StorageContracts;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
{
|
||||
public class FurnitureModuleStorage : IFurnitureModuleStorage
|
||||
{
|
||||
public List<FurnitureModuleViewModel> GetFullList()
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
return context.FurnitureModules
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Furnitures)
|
||||
.ThenInclude(x => x.Furniture).ToList()
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
public List<FurnitureModuleViewModel> GetFilteredList(FurnitureModuleSearchModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
if (!string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
return context.FurnitureModules
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Furnitures)
|
||||
.ThenInclude(x => x.Furniture)
|
||||
.Where(x => x.Name.Contains(model.Name)).ToList()
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
else if (model.UserId.HasValue)
|
||||
{
|
||||
return context.FurnitureModules
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Furnitures)
|
||||
.ThenInclude(x => x.Furniture)
|
||||
.Where(x => x.UserId == model.UserId)
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new();
|
||||
}
|
||||
}
|
||||
public FurnitureModuleViewModel? GetElement(FurnitureModuleSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Name) &&
|
||||
!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
return context.FurnitureModules
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Furnitures)
|
||||
.ThenInclude(x => x.Furniture)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Name) && x.Name == model.Name) || (model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
public FurnitureModuleViewModel? Insert(FurnitureModuleBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
var newFurnitureModule = FurnitureModule.Create(context, model);
|
||||
if (newFurnitureModule == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.FurnitureModules.Add(newFurnitureModule);
|
||||
context.SaveChanges();
|
||||
return newFurnitureModule.GetViewModel;
|
||||
}
|
||||
public FurnitureModuleViewModel? Update(FurnitureModuleBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var furnitureModule = context.FurnitureModules.FirstOrDefault(rec =>
|
||||
rec.Id == model.Id);
|
||||
if (furnitureModule == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
furnitureModule.Update(model);
|
||||
context.SaveChanges();
|
||||
furnitureModule.UpdateFurnitures(context, model);
|
||||
transaction.Commit();
|
||||
return furnitureModule.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public FurnitureModuleViewModel? Delete(FurnitureModuleBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
var element = context.FurnitureModules
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Furnitures)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.FurnitureModules.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,117 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.StorageContracts;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
{
|
||||
public class FurnitureStorage : IFurnitureStorage
|
||||
{
|
||||
public List<FurnitureViewModel> GetFullList()
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
return context.Furnitures
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Materials)
|
||||
.ThenInclude(x => x.Material).ToList()
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
public List<FurnitureViewModel> GetFilteredList(FurnitureSearchModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
if (!string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
return context.Furnitures
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Materials)
|
||||
.ThenInclude(x => x.Material)
|
||||
.Where(x => x.Name.Contains(model.Name)).ToList()
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
else if (model.UserId.HasValue)
|
||||
{
|
||||
return context.Furnitures
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Materials)
|
||||
.ThenInclude(x => x.Material)
|
||||
.Where(x => x.UserId == model.UserId)
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new();
|
||||
}
|
||||
}
|
||||
public FurnitureViewModel? GetElement(FurnitureSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Name) &&
|
||||
!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
return context.Furnitures.Include(x => x.User)
|
||||
.Include(x => x.Materials).ThenInclude(x => x.Material)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Name) && x.Name == model.Name) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
public FurnitureViewModel? Insert(FurnitureBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
var newFurniture = Furniture.Create(context, model);
|
||||
if (newFurniture == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Furnitures.Add(newFurniture);
|
||||
context.SaveChanges();
|
||||
return newFurniture.GetViewModel;
|
||||
}
|
||||
public FurnitureViewModel? Update(FurnitureBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var furniture = context.Furnitures
|
||||
.Include(x => x.User)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (furniture == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
furniture.Update(model);
|
||||
context.SaveChanges();
|
||||
furniture.UpdateMaterials(context, model);
|
||||
transaction.Commit();
|
||||
return furniture.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public FurnitureViewModel? Delete(FurnitureBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
var element = context.Furnitures
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Materials)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Furnitures.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.StorageContracts;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
{
|
||||
public class MaterialStorage : IMaterialStorage
|
||||
{
|
||||
public List<MaterialViewModel> GetFullList()
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
return context.Materials
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Scope)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<MaterialViewModel> GetFilteredList(MaterialSearchModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
if (!string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
return context.Materials
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Scope)
|
||||
.Where(x => x.Name.Contains(model.Name))
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
else if (model.UserId.HasValue)
|
||||
{
|
||||
return context.Materials
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Scope)
|
||||
.Where(x => x.UserId == model.UserId)
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new();
|
||||
}
|
||||
}
|
||||
public MaterialViewModel? GetElement(MaterialSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
return context.Materials
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Scope)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Name) && x.Name == model.Name) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
public MaterialViewModel? Insert(MaterialBindingModel model)
|
||||
{
|
||||
var newMaterial = Material.Create(model);
|
||||
if (newMaterial == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
context.Materials.Add(newMaterial);
|
||||
context.SaveChanges();
|
||||
return newMaterial.GetViewModel;
|
||||
}
|
||||
public MaterialViewModel? Update(MaterialBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
var material = context.Materials
|
||||
.Include(x => x.User)
|
||||
.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (material == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
material.Update(model);
|
||||
context.SaveChanges();
|
||||
return material.GetViewModel;
|
||||
}
|
||||
public MaterialViewModel? Delete(MaterialBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
var element = context.Materials
|
||||
.Include(x => x.User)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Materials.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.StorageContracts;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using FurnitureAssemblyDatabaseImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
{
|
||||
public class OrderStorage : IOrderStorage
|
||||
{
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
var element = context.Orders.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
var deletedElement = context.Orders
|
||||
.Include(x => x.Set)
|
||||
.Include(x => x.User)
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
context.Orders.Remove(element);
|
||||
context.SaveChanges();
|
||||
return deletedElement;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
return context.Orders
|
||||
.Include(x => x.Set)
|
||||
.Include(x => x.User)
|
||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Set)
|
||||
.Include(x => x.User)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.DateFrom != null && model.DateTo != null)
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Set)
|
||||
.Include(x => x.User)
|
||||
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.UserId.HasValue)
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Set)
|
||||
.Include(x => x.User)
|
||||
.Where(x => x.UserId == model.UserId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new();
|
||||
}
|
||||
}
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
return context.Orders
|
||||
.Include(x => x.Set)
|
||||
.Include(x => x.User)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
{
|
||||
var newOrder = Order.Create(model);
|
||||
if (newOrder == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
context.Orders.Add(newOrder);
|
||||
context.SaveChanges();
|
||||
return context.Orders
|
||||
.Include(x => x.Set)
|
||||
.Include(x => x.User)
|
||||
.FirstOrDefault(x => x.Id == newOrder.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
var order = context.Orders.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (order == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
order.Update(model);
|
||||
context.SaveChanges();
|
||||
return context.Orders
|
||||
.Include(x => x.Set)
|
||||
.Include(x => x.User)
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.StorageContracts;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
{
|
||||
public class ScopeStorage : IScopeStorage
|
||||
{
|
||||
public List<ScopeViewModel> GetFullList()
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
return context.Scopes
|
||||
.Include(x => x.Materials)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<ScopeViewModel> GetFilteredList(ScopeSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
if (!string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
return context.Scopes
|
||||
.Include(x => x.Materials)
|
||||
.Where(x => x.Name.Contains(model.Name))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return new();
|
||||
}
|
||||
public ScopeViewModel? GetElement(ScopeSearchModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.Scopes
|
||||
.FirstOrDefault(x => (x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
return context.Scopes
|
||||
.FirstOrDefault(x => (x.Name == model.Name))
|
||||
?.GetViewModel;
|
||||
}
|
||||
return new();
|
||||
}
|
||||
public ScopeViewModel? Insert(ScopeBindingModel model)
|
||||
{
|
||||
var newScope = Scope.Create(model);
|
||||
if (newScope == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
context.Scopes.Add(newScope);
|
||||
context.SaveChanges();
|
||||
return newScope.GetViewModel;
|
||||
}
|
||||
public ScopeViewModel? Update(ScopeBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
var scope = context.Scopes
|
||||
.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (scope == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
scope.Update(model);
|
||||
context.SaveChanges();
|
||||
return scope.GetViewModel;
|
||||
}
|
||||
public ScopeViewModel? Delete(ScopeBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
var element = context.Scopes
|
||||
.Include(x => x.Materials)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Scopes.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.StorageContracts;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
{
|
||||
public class SetStorage : ISetStorage
|
||||
{
|
||||
public List<SetViewModel> GetFullList()
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
return context.Sets
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.FurnitureModules)
|
||||
.ThenInclude(x => x.FurnitureModule).ToList()
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
public List<SetViewModel> GetFilteredList(SetSearchModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
if (!string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
return context.Sets
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.FurnitureModules)
|
||||
.ThenInclude(x => x.FurnitureModule)
|
||||
.Where(x => x.Name.Contains(model.Name)).ToList()
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
else if (model.UserId.HasValue)
|
||||
{
|
||||
return context.Sets
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.FurnitureModules)
|
||||
.ThenInclude(x => x.FurnitureModule)
|
||||
.Where(x => x.UserId == model.UserId)
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new();
|
||||
}
|
||||
}
|
||||
public SetViewModel? GetElement(SetSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Name) &&
|
||||
!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
return context.Sets
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.FurnitureModules)
|
||||
.ThenInclude(x => x.FurnitureModule)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Name) && x.Name == model.Name) || (model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
public SetViewModel? Insert(SetBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
var newSet = Set.Create(context, model);
|
||||
if (newSet == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Sets.Add(newSet);
|
||||
context.SaveChanges();
|
||||
return newSet.GetViewModel;
|
||||
}
|
||||
public SetViewModel? Update(SetBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var set = context.Sets
|
||||
.Include(x => x.User)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (set == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
set.Update(model);
|
||||
context.SaveChanges();
|
||||
set.UpdateFurnitureModules(context, model);
|
||||
transaction.Commit();
|
||||
return set.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public SetViewModel? Delete(SetBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
var element = context.Sets
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.FurnitureModules)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Sets.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.StorageContracts;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
{
|
||||
public class UserStorage : IUserStorage
|
||||
{
|
||||
public UserViewModel? Delete(UserBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
var element = context.Users
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
var deletedElement = context.Users
|
||||
.Include(x => x.Sets)
|
||||
.Include(x => x.Orders)
|
||||
.Include(x => x.FurnitureModules)
|
||||
.Include(x => x.Furnitures)
|
||||
.Include(x => x.Materials)
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
context.Users.Remove(element);
|
||||
context.SaveChanges();
|
||||
return deletedElement;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public UserViewModel? GetElement(UserSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
return context.Users
|
||||
.Include(x => x.Sets)
|
||||
.Include(x => x.Orders)
|
||||
.Include(x => x.FurnitureModules)
|
||||
.Include(x => x.Furnitures)
|
||||
.Include(x => x.Materials)
|
||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
public List<UserViewModel> GetFilteredList(UserSearchModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
if (!string.IsNullOrEmpty(model.Login))
|
||||
{
|
||||
return context.Users
|
||||
.Include(x => x.Sets)
|
||||
.Include(x => x.Orders)
|
||||
.Include(x => x.FurnitureModules)
|
||||
.Include(x => x.Furnitures)
|
||||
.Include(x => x.Materials)
|
||||
.Where(x => x.Login.Contains(model.Login))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return new();
|
||||
}
|
||||
public List<UserViewModel> GetFullList()
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
return context.Users
|
||||
.Include(x => x.Sets)
|
||||
.Include(x => x.Orders)
|
||||
.Include(x => x.FurnitureModules)
|
||||
.Include(x => x.Furnitures)
|
||||
.Include(x => x.Materials)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public UserViewModel? Insert(UserBindingModel model)
|
||||
{
|
||||
var newUser = User.Create(model);
|
||||
if (newUser == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
context.Users.Add(newUser);
|
||||
context.SaveChanges();
|
||||
return context.Users
|
||||
.Include(x => x.Sets)
|
||||
.Include(x => x.Orders)
|
||||
.Include(x => x.FurnitureModules)
|
||||
.Include(x => x.Furnitures)
|
||||
.Include(x => x.Materials)
|
||||
.FirstOrDefault(x => x.Id == newUser.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
public UserViewModel? Update(UserBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
var user = context.Users.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (user == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
user.Update(model);
|
||||
context.SaveChanges();
|
||||
return context.Users
|
||||
.Include(x => x.Sets)
|
||||
.Include(x => x.Orders)
|
||||
.Include(x => x.FurnitureModules)
|
||||
.Include(x => x.Furnitures)
|
||||
.Include(x => x.Materials)
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
508
FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Migrations/20230406130140_Init.Designer.cs
generated
Normal file
508
FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Migrations/20230406130140_Init.Designer.cs
generated
Normal file
@ -0,0 +1,508 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using FurnitureAssembly_WorkerDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FurnitureAssembly_WorkerDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(FurnitureAssemblyDatabase))]
|
||||
[Migration("20230406130140_Init")]
|
||||
partial class Init
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Furniture", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Furnitures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.FurnitureMaterial", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("FurnitureId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("MaterialId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("FurnitureId");
|
||||
|
||||
b.HasIndex("MaterialId");
|
||||
|
||||
b.ToTable("FurnitureMaterials");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.FurnitureModule", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("FurnitureModules");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.FurnitureModuleFurniture", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("FurnitureId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("FurnitureModuleId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("FurnitureId");
|
||||
|
||||
b.HasIndex("FurnitureModuleId");
|
||||
|
||||
b.ToTable("FurnitureModuleFurnitures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Material", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("ScopeId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ScopeId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Materials");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("CustomerName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("PaymentType")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("SetId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("SetId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Role", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Roles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Scope", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Scopes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Set", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Sets");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.SetFurnitureModule", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("FurnitureModuleId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("SetId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("FurnitureModuleId");
|
||||
|
||||
b.HasIndex("SetId");
|
||||
|
||||
b.ToTable("SetFurnitureModules");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Login")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("RoleId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Furniture", b =>
|
||||
{
|
||||
b.HasOne("FurnitureAssembly_WorkerDatabaseImplement.Models.User", "User")
|
||||
.WithMany("Furnitures")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.FurnitureMaterial", b =>
|
||||
{
|
||||
b.HasOne("FurnitureAssembly_WorkerDatabaseImplement.Models.Furniture", "Furniture")
|
||||
.WithMany("Materials")
|
||||
.HasForeignKey("FurnitureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FurnitureAssembly_WorkerDatabaseImplement.Models.Material", "Material")
|
||||
.WithMany("FurnitureMaterials")
|
||||
.HasForeignKey("MaterialId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Furniture");
|
||||
|
||||
b.Navigation("Material");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.FurnitureModule", b =>
|
||||
{
|
||||
b.HasOne("FurnitureAssembly_WorkerDatabaseImplement.Models.User", "User")
|
||||
.WithMany("FurnitureModules")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.FurnitureModuleFurniture", b =>
|
||||
{
|
||||
b.HasOne("FurnitureAssembly_WorkerDatabaseImplement.Models.Furniture", "Furniture")
|
||||
.WithMany()
|
||||
.HasForeignKey("FurnitureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FurnitureAssembly_WorkerDatabaseImplement.Models.FurnitureModule", "FurnitureModule")
|
||||
.WithMany("Furnitures")
|
||||
.HasForeignKey("FurnitureModuleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Furniture");
|
||||
|
||||
b.Navigation("FurnitureModule");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Material", b =>
|
||||
{
|
||||
b.HasOne("FurnitureAssembly_WorkerDatabaseImplement.Models.Scope", "Scope")
|
||||
.WithMany("Materials")
|
||||
.HasForeignKey("ScopeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FurnitureAssembly_WorkerDatabaseImplement.Models.User", "User")
|
||||
.WithMany("Materials")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Scope");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("FurnitureAssembly_WorkerDatabaseImplement.Models.Set", "Set")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("SetId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FurnitureAssembly_WorkerDatabaseImplement.Models.User", "User")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Set");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Set", b =>
|
||||
{
|
||||
b.HasOne("FurnitureAssembly_WorkerDatabaseImplement.Models.User", "User")
|
||||
.WithMany("Sets")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.SetFurnitureModule", b =>
|
||||
{
|
||||
b.HasOne("FurnitureAssembly_WorkerDatabaseImplement.Models.FurnitureModule", "FurnitureModule")
|
||||
.WithMany("Sets")
|
||||
.HasForeignKey("FurnitureModuleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FurnitureAssembly_WorkerDatabaseImplement.Models.Set", "Set")
|
||||
.WithMany("FurnitureModules")
|
||||
.HasForeignKey("SetId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("FurnitureModule");
|
||||
|
||||
b.Navigation("Set");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.HasOne("FurnitureAssembly_WorkerDatabaseImplement.Models.Role", "Role")
|
||||
.WithMany("Users")
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Role");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Furniture", b =>
|
||||
{
|
||||
b.Navigation("Materials");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.FurnitureModule", b =>
|
||||
{
|
||||
b.Navigation("Furnitures");
|
||||
|
||||
b.Navigation("Sets");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Material", b =>
|
||||
{
|
||||
b.Navigation("FurnitureMaterials");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Role", b =>
|
||||
{
|
||||
b.Navigation("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Scope", b =>
|
||||
{
|
||||
b.Navigation("Materials");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Set", b =>
|
||||
{
|
||||
b.Navigation("FurnitureModules");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.Navigation("FurnitureModules");
|
||||
|
||||
b.Navigation("Furnitures");
|
||||
|
||||
b.Navigation("Materials");
|
||||
|
||||
b.Navigation("Orders");
|
||||
|
||||
b.Navigation("Sets");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
376
FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Migrations/20230406130140_Init.cs
Normal file
376
FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Migrations/20230406130140_Init.cs
Normal file
@ -0,0 +1,376 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Init : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Roles",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Name = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Roles", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Scopes",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Name = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Scopes", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Users",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Login = table.Column<string>(type: "text", nullable: false),
|
||||
Password = table.Column<string>(type: "text", nullable: false),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
RoleId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Users", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Users_Roles_RoleId",
|
||||
column: x => x.RoleId,
|
||||
principalTable: "Roles",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "FurnitureModules",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
Cost = table.Column<double>(type: "double precision", nullable: false),
|
||||
DateCreate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
UserId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_FurnitureModules", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_FurnitureModules_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Furnitures",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
Cost = table.Column<double>(type: "double precision", nullable: false),
|
||||
DateCreate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
UserId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Furnitures", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Furnitures_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Materials",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
Cost = table.Column<double>(type: "double precision", nullable: false),
|
||||
ScopeId = table.Column<int>(type: "integer", nullable: false),
|
||||
UserId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Materials", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Materials_Scopes_ScopeId",
|
||||
column: x => x.ScopeId,
|
||||
principalTable: "Scopes",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Materials_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Sets",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
Cost = table.Column<double>(type: "double precision", nullable: false),
|
||||
DateCreate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
UserId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Sets", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Sets_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "FurnitureModuleFurnitures",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
FurnitureModuleId = table.Column<int>(type: "integer", nullable: false),
|
||||
FurnitureId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_FurnitureModuleFurnitures", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_FurnitureModuleFurnitures_FurnitureModules_FurnitureModuleId",
|
||||
column: x => x.FurnitureModuleId,
|
||||
principalTable: "FurnitureModules",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_FurnitureModuleFurnitures_Furnitures_FurnitureId",
|
||||
column: x => x.FurnitureId,
|
||||
principalTable: "Furnitures",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "FurnitureMaterials",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
FurnitureId = table.Column<int>(type: "integer", nullable: false),
|
||||
MaterialId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_FurnitureMaterials", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_FurnitureMaterials_Furnitures_FurnitureId",
|
||||
column: x => x.FurnitureId,
|
||||
principalTable: "Furnitures",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_FurnitureMaterials_Materials_MaterialId",
|
||||
column: x => x.MaterialId,
|
||||
principalTable: "Materials",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Orders",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
CustomerName = table.Column<string>(type: "text", nullable: false),
|
||||
PaymentType = table.Column<int>(type: "integer", nullable: false),
|
||||
SetId = table.Column<int>(type: "integer", nullable: false),
|
||||
DateCreate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
Sum = table.Column<double>(type: "double precision", nullable: false),
|
||||
UserId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Sets_SetId",
|
||||
column: x => x.SetId,
|
||||
principalTable: "Sets",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "SetFurnitureModules",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
SetId = table.Column<int>(type: "integer", nullable: false),
|
||||
FurnitureModuleId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_SetFurnitureModules", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_SetFurnitureModules_FurnitureModules_FurnitureModuleId",
|
||||
column: x => x.FurnitureModuleId,
|
||||
principalTable: "FurnitureModules",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_SetFurnitureModules_Sets_SetId",
|
||||
column: x => x.SetId,
|
||||
principalTable: "Sets",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_FurnitureMaterials_FurnitureId",
|
||||
table: "FurnitureMaterials",
|
||||
column: "FurnitureId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_FurnitureMaterials_MaterialId",
|
||||
table: "FurnitureMaterials",
|
||||
column: "MaterialId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_FurnitureModuleFurnitures_FurnitureId",
|
||||
table: "FurnitureModuleFurnitures",
|
||||
column: "FurnitureId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_FurnitureModuleFurnitures_FurnitureModuleId",
|
||||
table: "FurnitureModuleFurnitures",
|
||||
column: "FurnitureModuleId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_FurnitureModules_UserId",
|
||||
table: "FurnitureModules",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Furnitures_UserId",
|
||||
table: "Furnitures",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Materials_ScopeId",
|
||||
table: "Materials",
|
||||
column: "ScopeId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Materials_UserId",
|
||||
table: "Materials",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_SetId",
|
||||
table: "Orders",
|
||||
column: "SetId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_UserId",
|
||||
table: "Orders",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SetFurnitureModules_FurnitureModuleId",
|
||||
table: "SetFurnitureModules",
|
||||
column: "FurnitureModuleId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SetFurnitureModules_SetId",
|
||||
table: "SetFurnitureModules",
|
||||
column: "SetId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Sets_UserId",
|
||||
table: "Sets",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Users_RoleId",
|
||||
table: "Users",
|
||||
column: "RoleId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "FurnitureMaterials");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "FurnitureModuleFurnitures");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Orders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "SetFurnitureModules");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Materials");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Furnitures");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "FurnitureModules");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Sets");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Scopes");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Users");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Roles");
|
||||
}
|
||||
}
|
||||
}
|
505
FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Migrations/FurnitureAssemblyDatabaseModelSnapshot.cs
Normal file
505
FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Migrations/FurnitureAssemblyDatabaseModelSnapshot.cs
Normal file
@ -0,0 +1,505 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using FurnitureAssemblyDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(FurnitureAssemblyDatabase))]
|
||||
partial class FurnitureAssemblyDatabaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Furniture", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Furnitures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.FurnitureMaterial", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("FurnitureId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("MaterialId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("FurnitureId");
|
||||
|
||||
b.HasIndex("MaterialId");
|
||||
|
||||
b.ToTable("FurnitureMaterials");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.FurnitureModule", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("FurnitureModules");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.FurnitureModuleFurniture", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("FurnitureId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("FurnitureModuleId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("FurnitureId");
|
||||
|
||||
b.HasIndex("FurnitureModuleId");
|
||||
|
||||
b.ToTable("FurnitureModuleFurnitures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Material", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("ScopeId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ScopeId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Materials");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("CustomerName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("PaymentType")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("SetId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("SetId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Role", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Roles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Scope", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Scopes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Set", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Sets");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.SetFurnitureModule", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("FurnitureModuleId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("SetId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("FurnitureModuleId");
|
||||
|
||||
b.HasIndex("SetId");
|
||||
|
||||
b.ToTable("SetFurnitureModules");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Login")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("RoleId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Furniture", b =>
|
||||
{
|
||||
b.HasOne("FurnitureAssembly_WorkerDatabaseImplement.Models.User", "User")
|
||||
.WithMany("Furnitures")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.FurnitureMaterial", b =>
|
||||
{
|
||||
b.HasOne("FurnitureAssembly_WorkerDatabaseImplement.Models.Furniture", "Furniture")
|
||||
.WithMany("Materials")
|
||||
.HasForeignKey("FurnitureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FurnitureAssembly_WorkerDatabaseImplement.Models.Material", "Material")
|
||||
.WithMany("FurnitureMaterials")
|
||||
.HasForeignKey("MaterialId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Furniture");
|
||||
|
||||
b.Navigation("Material");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.FurnitureModule", b =>
|
||||
{
|
||||
b.HasOne("FurnitureAssembly_WorkerDatabaseImplement.Models.User", "User")
|
||||
.WithMany("FurnitureModules")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.FurnitureModuleFurniture", b =>
|
||||
{
|
||||
b.HasOne("FurnitureAssembly_WorkerDatabaseImplement.Models.Furniture", "Furniture")
|
||||
.WithMany()
|
||||
.HasForeignKey("FurnitureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FurnitureAssembly_WorkerDatabaseImplement.Models.FurnitureModule", "FurnitureModule")
|
||||
.WithMany("Furnitures")
|
||||
.HasForeignKey("FurnitureModuleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Furniture");
|
||||
|
||||
b.Navigation("FurnitureModule");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Material", b =>
|
||||
{
|
||||
b.HasOne("FurnitureAssembly_WorkerDatabaseImplement.Models.Scope", "Scope")
|
||||
.WithMany("Materials")
|
||||
.HasForeignKey("ScopeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FurnitureAssembly_WorkerDatabaseImplement.Models.User", "User")
|
||||
.WithMany("Materials")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Scope");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("FurnitureAssembly_WorkerDatabaseImplement.Models.Set", "Set")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("SetId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FurnitureAssembly_WorkerDatabaseImplement.Models.User", "User")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Set");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Set", b =>
|
||||
{
|
||||
b.HasOne("FurnitureAssembly_WorkerDatabaseImplement.Models.User", "User")
|
||||
.WithMany("Sets")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.SetFurnitureModule", b =>
|
||||
{
|
||||
b.HasOne("FurnitureAssembly_WorkerDatabaseImplement.Models.FurnitureModule", "FurnitureModule")
|
||||
.WithMany("Sets")
|
||||
.HasForeignKey("FurnitureModuleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FurnitureAssembly_WorkerDatabaseImplement.Models.Set", "Set")
|
||||
.WithMany("FurnitureModules")
|
||||
.HasForeignKey("SetId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("FurnitureModule");
|
||||
|
||||
b.Navigation("Set");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.HasOne("FurnitureAssembly_WorkerDatabaseImplement.Models.Role", "Role")
|
||||
.WithMany("Users")
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Role");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Furniture", b =>
|
||||
{
|
||||
b.Navigation("Materials");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.FurnitureModule", b =>
|
||||
{
|
||||
b.Navigation("Furnitures");
|
||||
|
||||
b.Navigation("Sets");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Material", b =>
|
||||
{
|
||||
b.Navigation("FurnitureMaterials");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Role", b =>
|
||||
{
|
||||
b.Navigation("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Scope", b =>
|
||||
{
|
||||
b.Navigation("Materials");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.Set", b =>
|
||||
{
|
||||
b.Navigation("FurnitureModules");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssembly_WorkerDatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.Navigation("FurnitureModules");
|
||||
|
||||
b.Navigation("Furnitures");
|
||||
|
||||
b.Navigation("Materials");
|
||||
|
||||
b.Navigation("Orders");
|
||||
|
||||
b.Navigation("Sets");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Models
|
||||
{
|
||||
public class Furniture : IFurnitureModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public double Cost { get; set; }
|
||||
[Required]
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
[Required]
|
||||
public int UserId { get; set; }
|
||||
public virtual User User { get; set; }
|
||||
public Dictionary<int, (IMaterialModel, int)>? _furnitureMaterials = null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IMaterialModel, int)> FurnitureMaterials
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_furnitureMaterials == null)
|
||||
{
|
||||
_furnitureMaterials = Materials
|
||||
.ToDictionary(recPC => recPC.MaterialId, recPC =>
|
||||
(recPC.Material as IMaterialModel, recPC.Count));
|
||||
}
|
||||
return _furnitureMaterials;
|
||||
}
|
||||
}
|
||||
[ForeignKey("FurnitureId")]
|
||||
public virtual List<FurnitureMaterial> Materials { get; set; } = new();
|
||||
public static Furniture Create(FurnitureAssemblyDatabase context, FurnitureBindingModel model)
|
||||
{
|
||||
return new Furniture()
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
Cost = model.Cost,
|
||||
UserId = model.UserId,
|
||||
DateCreate = model.DateCreate,
|
||||
Materials = model.FurnitureMaterials.Select(x => new FurnitureMaterial
|
||||
{
|
||||
Material = context.Materials.First(y => y.Id == x.Key),
|
||||
Count = x.Value.Item2
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
public void Update(FurnitureBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Name = model.Name;
|
||||
Cost = model.Cost;
|
||||
}
|
||||
public FurnitureViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
Cost = Cost,
|
||||
UserId = UserId,
|
||||
UserName = User.Name,
|
||||
DateCreate = DateCreate,
|
||||
FurnitureMaterials = FurnitureMaterials
|
||||
};
|
||||
public void UpdateMaterials(FurnitureAssemblyDatabase context, FurnitureBindingModel model)
|
||||
{
|
||||
var furnitureMaterials = context.FurnitureMaterials.Where(rec =>
|
||||
rec.FurnitureId == model.Id).ToList();
|
||||
if (furnitureMaterials != null && furnitureMaterials.Count > 0)
|
||||
{ // удалили те, которых нет в модели
|
||||
context.FurnitureMaterials.RemoveRange(furnitureMaterials.Where(rec
|
||||
=> !model.FurnitureMaterials.ContainsKey(rec.MaterialId)));
|
||||
context.SaveChanges();
|
||||
// обновили количество у существующих записей
|
||||
foreach (var updateMaterial in furnitureMaterials)
|
||||
{
|
||||
updateMaterial.Count = model.FurnitureMaterials[updateMaterial.MaterialId].Item2;
|
||||
model.FurnitureMaterials.Remove(updateMaterial.MaterialId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
var furniture = context.Furnitures.First(x => x.Id == Id);
|
||||
foreach (var pc in model.FurnitureMaterials)
|
||||
{
|
||||
context.FurnitureMaterials.Add(new FurnitureMaterial
|
||||
{
|
||||
Furniture = furniture,
|
||||
Material = context.Materials.First(x => x.Id == pc.Key),
|
||||
Count = pc.Value.Item2
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_furnitureMaterials = null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Models
|
||||
{
|
||||
public class FurnitureMaterial
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public int FurnitureId { get; set; }
|
||||
[Required]
|
||||
public int MaterialId { get; set; }
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
public virtual Furniture Furniture { get; set; } = new();
|
||||
public virtual Material Material { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Models
|
||||
{
|
||||
public class FurnitureModule : IFurnitureModuleModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public double Cost { get; set; }
|
||||
[Required]
|
||||
public DateTime DateCreate { get; set; }
|
||||
[Required]
|
||||
public int UserId { get; set; }
|
||||
public virtual User User { get; set; }
|
||||
public Dictionary<int, (IFurnitureModel, int)>? _furnitureModuleFurnitures = null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IFurnitureModel, int)> FurnitureModuleFurnitures
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_furnitureModuleFurnitures == null)
|
||||
{
|
||||
_furnitureModuleFurnitures = Furnitures
|
||||
.ToDictionary(recPC => recPC.FurnitureId, recPC =>
|
||||
(recPC.Furniture as IFurnitureModel, recPC.Count));
|
||||
}
|
||||
return _furnitureModuleFurnitures;
|
||||
}
|
||||
}
|
||||
[ForeignKey("FurnitureModuleId")]
|
||||
public virtual List<FurnitureModuleFurniture> Furnitures { get; set; } = new();
|
||||
[ForeignKey("FurnitureModuleId")]
|
||||
public virtual List<SetFurnitureModule> Sets { get; set; } = new();
|
||||
public static FurnitureModule Create(FurnitureAssemblyDatabase context, FurnitureModuleBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new FurnitureModule()
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
Cost = model.Cost,
|
||||
DateCreate = model.DateCreate,
|
||||
UserId = model.UserId,
|
||||
Furnitures = model.FurnitureModuleFurnitures.Select(x => new FurnitureModuleFurniture
|
||||
{
|
||||
Furniture = context.Furnitures.First(y => y.Id == x.Key),
|
||||
Count = x.Value.Item2
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
public void Update(FurnitureModuleBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Name = model.Name;
|
||||
Cost = model.Cost;
|
||||
}
|
||||
public FurnitureModuleViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
Cost = Cost,
|
||||
DateCreate = DateCreate,
|
||||
UserId = UserId,
|
||||
UserName = User.Name,
|
||||
FurnitureModuleFurnitures = FurnitureModuleFurnitures
|
||||
};
|
||||
public void UpdateFurnitures(FurnitureAssemblyDatabase context, FurnitureModuleBindingModel model)
|
||||
{
|
||||
var furnitureModuleFurnitures = context.FurnitureModuleFurnitures.Where(rec =>
|
||||
rec.FurnitureModuleId == model.Id).ToList();
|
||||
if (furnitureModuleFurnitures != null && furnitureModuleFurnitures.Count > 0)
|
||||
{ // удалили те, которых нет в модели
|
||||
context.FurnitureModuleFurnitures.RemoveRange(furnitureModuleFurnitures.Where(rec
|
||||
=> !model.FurnitureModuleFurnitures.ContainsKey(rec.FurnitureId)));
|
||||
context.SaveChanges();
|
||||
// обновили количество у существующих записей
|
||||
foreach (var updateFurniture in furnitureModuleFurnitures)
|
||||
{
|
||||
updateFurniture.Count = model.FurnitureModuleFurnitures[updateFurniture.FurnitureId].Item2;
|
||||
model.FurnitureModuleFurnitures.Remove(updateFurniture.FurnitureId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
var furnitureModule = context.FurnitureModules.First(x => x.Id == Id);
|
||||
foreach (var pc in model.FurnitureModuleFurnitures)
|
||||
{
|
||||
context.FurnitureModuleFurnitures.Add(new FurnitureModuleFurniture
|
||||
{
|
||||
FurnitureModule = furnitureModule,
|
||||
Furniture = context.Furnitures.First(x => x.Id == pc.Key),
|
||||
Count = pc.Value.Item2
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_furnitureModuleFurnitures = null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
23
FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Models/FurnitureModuleFurniture.cs
Normal file
23
FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Models/FurnitureModuleFurniture.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Models
|
||||
{
|
||||
public class FurnitureModuleFurniture
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public int FurnitureModuleId { get; set; }
|
||||
[Required]
|
||||
public int FurnitureId { get; set; }
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
public virtual FurnitureModule FurnitureModule { get; set; } = new();
|
||||
public virtual Furniture Furniture { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Models
|
||||
{
|
||||
public class Material : IMaterialModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public double Cost { get; set; }
|
||||
[Required]
|
||||
public int ScopeId { get; set; }
|
||||
public virtual Scope Scope { get; set; }
|
||||
[Required]
|
||||
public int UserId { get; set; }
|
||||
public virtual User User { get; set; }
|
||||
[ForeignKey("MaterialId")]
|
||||
public virtual List<FurnitureMaterial> FurnitureMaterials { get; set; } = new();
|
||||
public static Material? Create(MaterialBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Material()
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
Cost = model.Cost,
|
||||
ScopeId = model.ScopeId,
|
||||
UserId = model.UserId
|
||||
};
|
||||
}
|
||||
public void Update(MaterialBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Name = model.Name;
|
||||
Cost = model.Cost;
|
||||
ScopeId = model.ScopeId;
|
||||
}
|
||||
public MaterialViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
Cost = Cost,
|
||||
ScopeId = ScopeId,
|
||||
ScopeName = Scope.Name,
|
||||
UserId = UserId,
|
||||
UserName = User.Name
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyDataModels.Enums;
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Models
|
||||
{
|
||||
public class Order : IOrderModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public string CustomerName { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public PaymentType PaymentType { get; set; } = PaymentType.Неизвестен;
|
||||
[Required]
|
||||
public int SetId { get; set; }
|
||||
public virtual Set Set { get; set; }
|
||||
[Required]
|
||||
public DateTime DateCreate { get; set; }
|
||||
[Required]
|
||||
public double Sum { get; set; }
|
||||
[Required]
|
||||
public int UserId { get; set; }
|
||||
public virtual User User { get; set; }
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Order()
|
||||
{
|
||||
Id = model.Id,
|
||||
CustomerName = model.CustomerName,
|
||||
PaymentType = model.PaymentType,
|
||||
SetId = model.SetId,
|
||||
Sum = model.Sum,
|
||||
DateCreate = model.DateCreate,
|
||||
UserId = model.UserId
|
||||
};
|
||||
}
|
||||
public void Update(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
CustomerName = model.CustomerName;
|
||||
PaymentType = model.PaymentType;
|
||||
SetId = model.SetId;
|
||||
UserId = model.UserId;
|
||||
}
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
CustomerName = CustomerName,
|
||||
PaymentType = PaymentType,
|
||||
SetId = SetId,
|
||||
SetName = Set.Name,
|
||||
DateCreate = DateCreate,
|
||||
Sum = Sum,
|
||||
UserId = UserId,
|
||||
UserName = User.Name
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Models
|
||||
{
|
||||
public class Role : IRoleModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[ForeignKey("RoleId")]
|
||||
public virtual List<User> Users { get; set; } = new();
|
||||
public static Role? Create(RoleBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Role()
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name
|
||||
};
|
||||
}
|
||||
public void Update(RoleBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Name = model.Name;
|
||||
}
|
||||
public RoleViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Models
|
||||
{
|
||||
public class Scope : IScopeModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[ForeignKey("ScopeId")]
|
||||
public virtual List<Material> Materials { get; set; } = new();
|
||||
public static Scope? Create(ScopeBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Scope()
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name
|
||||
};
|
||||
}
|
||||
public void Update(ScopeBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Name = model.Name;
|
||||
}
|
||||
public ScopeViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Models
|
||||
{
|
||||
public class Set : ISetModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public double Cost { get; set; }
|
||||
[Required]
|
||||
public DateTime DateCreate { get; set; }
|
||||
[Required]
|
||||
public int UserId { get; set; }
|
||||
public virtual User User { get; set; }
|
||||
public Dictionary<int, (IFurnitureModuleModel, int)>? _setFurnitureModules = null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IFurnitureModuleModel, int)> SetFurnitureModules
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_setFurnitureModules == null)
|
||||
{
|
||||
_setFurnitureModules = FurnitureModules
|
||||
.ToDictionary(recPC => recPC.FurnitureModuleId, recPC =>
|
||||
(recPC.FurnitureModule as IFurnitureModuleModel, recPC.Count));
|
||||
}
|
||||
return _setFurnitureModules;
|
||||
}
|
||||
}
|
||||
[ForeignKey("SetId")]
|
||||
public virtual List<SetFurnitureModule> FurnitureModules { get; set; } = new();
|
||||
[ForeignKey("SetId")]
|
||||
public virtual List<Order> Orders { get; set; } = new();
|
||||
public static Set Create(FurnitureAssemblyDatabase context, SetBindingModel model)
|
||||
{
|
||||
return new Set()
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
Cost = model.Cost,
|
||||
DateCreate = model.DateCreate,
|
||||
FurnitureModules = model.SetFurnitureModules.Select(x => new SetFurnitureModule
|
||||
{
|
||||
FurnitureModule = context.FurnitureModules.First(y => y.Id == x.Key),
|
||||
Count = x.Value.Item2
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
public void Update(SetBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Name = model.Name;
|
||||
Cost = model.Cost;
|
||||
}
|
||||
public SetViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
Cost = Cost,
|
||||
DateCreate = DateCreate,
|
||||
UserId = UserId,
|
||||
UserName = User.Name,
|
||||
SetFurnitureModules = SetFurnitureModules
|
||||
};
|
||||
public void UpdateFurnitureModules(FurnitureAssemblyDatabase context, SetBindingModel model)
|
||||
{
|
||||
var setFurnitureModules = context.SetFurnitureModules.Where(rec =>
|
||||
rec.SetId == model.Id).ToList();
|
||||
if (setFurnitureModules != null && setFurnitureModules.Count > 0)
|
||||
{ // удалили те, которых нет в модели
|
||||
context.SetFurnitureModules.RemoveRange(setFurnitureModules.Where(rec
|
||||
=> !model.SetFurnitureModules.ContainsKey(rec.FurnitureModuleId)));
|
||||
context.SaveChanges();
|
||||
// обновили количество у существующих записей
|
||||
foreach (var updateFurnitureModule in setFurnitureModules)
|
||||
{
|
||||
updateFurnitureModule.Count = model.SetFurnitureModules[updateFurnitureModule.FurnitureModuleId].Item2;
|
||||
model.SetFurnitureModules.Remove(updateFurnitureModule.FurnitureModuleId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
var set = context.Sets.First(x => x.Id == Id);
|
||||
foreach (var pc in model.SetFurnitureModules)
|
||||
{
|
||||
context.SetFurnitureModules.Add(new SetFurnitureModule
|
||||
{
|
||||
Set = set,
|
||||
FurnitureModule = context.FurnitureModules.First(x => x.Id == pc.Key),
|
||||
Count = pc.Value.Item2
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_setFurnitureModules = null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Models
|
||||
{
|
||||
public class SetFurnitureModule
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public int SetId { get; set; }
|
||||
[Required]
|
||||
public int FurnitureModuleId { get; set; }
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
public virtual Set Set { get; set; } = new();
|
||||
public virtual FurnitureModule FurnitureModule { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Models
|
||||
{
|
||||
public class User : IUserModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public string Login { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public int RoleId { get; set; }
|
||||
public virtual Role Role { get; set; }
|
||||
[ForeignKey("UserId")]
|
||||
public virtual List<Order> Orders { get; set; } = new();
|
||||
[ForeignKey("UserId")]
|
||||
public virtual List<Set> Sets { get; set; } = new();
|
||||
[ForeignKey("UserId")]
|
||||
public virtual List<FurnitureModule> FurnitureModules { get; set; } = new();
|
||||
[ForeignKey("UserId")]
|
||||
public virtual List<Furniture> Furnitures { get; set; } = new();
|
||||
[ForeignKey("UserId")]
|
||||
public virtual List<Material> Materials { get; set; } = new();
|
||||
public static User? Create(UserBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new User()
|
||||
{
|
||||
Id = model.Id,
|
||||
Login = model.Login,
|
||||
Password = model.Password,
|
||||
Name = model.Name,
|
||||
RoleId = model.RoleId
|
||||
};
|
||||
}
|
||||
public void Update(UserBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Login = model.Login;
|
||||
Password = model.Password;
|
||||
Name = model.Name;
|
||||
RoleId = model.RoleId;
|
||||
}
|
||||
public UserViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Password = Password,
|
||||
Login = Login,
|
||||
Name = Name,
|
||||
RoleId = RoleId,
|
||||
RoleName = Role.Name
|
||||
};
|
||||
}
|
||||
}
|
114
FurnitureAssembly/FurnitureAssembly_StorekeeperBusinessLogic/BusinessLogics/FurnitureLogic.cs
Normal file
114
FurnitureAssembly/FurnitureAssembly_StorekeeperBusinessLogic/BusinessLogics/FurnitureLogic.cs
Normal file
@ -0,0 +1,114 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.BusinessLogicContracts;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.StorageContracts;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssembly_StorekeeperBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class FurnitureLogic: IFurnitureLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IFurnitureStorage _FurnitureStorage;
|
||||
public FurnitureLogic(ILogger<FurnitureLogic> logger, IFurnitureStorage furnitureStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_FurnitureStorage = furnitureStorage;
|
||||
}
|
||||
public List<FurnitureViewModel>? ReadList(FurnitureSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. FurnitureName:{Name}.Id:{Id}", model?.Name, model?.Id);
|
||||
var list = model == null ? _FurnitureStorage.GetFullList() : _FurnitureStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public FurnitureViewModel? ReadElement(FurnitureSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. FurnitureName:{Name}.Id:{Id}", model.Name, model.Id);
|
||||
|
||||
var element = _FurnitureStorage.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(FurnitureBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_FurnitureStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(FurnitureBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_FurnitureStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(FurnitureBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_FurnitureStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(FurnitureBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия продукта",nameof(model.Name));
|
||||
}
|
||||
if (model.Cost <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost));
|
||||
}
|
||||
_logger.LogInformation("Furniture. Name:{Name}. Cost:{Cost}. Id: {Id}", model.Name, model.Cost, model.Id);
|
||||
var element = _FurnitureStorage.GetElement(new FurnitureSearchModel
|
||||
{
|
||||
Name = model.Name
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Изделие с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
113
FurnitureAssembly/FurnitureAssembly_StorekeeperBusinessLogic/BusinessLogics/MaterialLogic.cs
Normal file
113
FurnitureAssembly/FurnitureAssembly_StorekeeperBusinessLogic/BusinessLogics/MaterialLogic.cs
Normal file
@ -0,0 +1,113 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.BusinessLogicContracts;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.StorageContracts;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace FurnitureAssembly_Storekeeper_BusinessLogic.BusinessLogics
|
||||
{
|
||||
public class MaterialLogic : IMaterialLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IMaterialStorage _MaterialStorage;
|
||||
public MaterialLogic(ILogger<MaterialLogic> logger, IMaterialStorage
|
||||
MaterialStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_MaterialStorage = MaterialStorage;
|
||||
}
|
||||
public List<MaterialViewModel>? ReadList(MaterialSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. MaterialName:{Name}.Id:{Id}", model?.Name, model?.Id);
|
||||
var list = model == null ? _MaterialStorage.GetFullList() :
|
||||
_MaterialStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public MaterialViewModel? ReadElement(MaterialSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. MaterialName:{Name}.Id:{Id}", model.Name, model.Id);
|
||||
|
||||
var element = _MaterialStorage.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(MaterialBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_MaterialStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(MaterialBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_MaterialStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(MaterialBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_MaterialStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(MaterialBindingModel model, bool withParams =
|
||||
true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия компонента",
|
||||
nameof(model.Name));
|
||||
}
|
||||
if (model.Cost <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost));
|
||||
}
|
||||
_logger.LogInformation("Material. Name:{Name}. Cost:{ Cost}. Id: {Id}", model.Name, model.Cost, model.Id);
|
||||
var element = _MaterialStorage.GetElement(new MaterialSearchModel
|
||||
{
|
||||
Name = model.Name
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Компонент с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
109
FurnitureAssembly/FurnitureAssembly_StorekeeperBusinessLogic/BusinessLogics/RoleLogic.cs
Normal file
109
FurnitureAssembly/FurnitureAssembly_StorekeeperBusinessLogic/BusinessLogics/RoleLogic.cs
Normal file
@ -0,0 +1,109 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.BusinessLogicContracts;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.StorageContracts;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace FurnitureAssembly_Storekeeper_BusinessLogic.BusinessLogics
|
||||
{
|
||||
public class RoleLogic : IRoleLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IRoleStorage _RoleStorage;
|
||||
public RoleLogic(ILogger<RoleLogic> logger, IRoleStorage
|
||||
RoleStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_RoleStorage = RoleStorage;
|
||||
}
|
||||
public List<RoleViewModel>? ReadList(RoleSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. RoleName:{Name}.Id:{Id}", model?.Name, model?.Id);
|
||||
var list = model == null ? _RoleStorage.GetFullList() :
|
||||
_RoleStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public RoleViewModel? ReadElement(RoleSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. RoleName:{Name}.Id:{Id}", model.Name, model.Id);
|
||||
|
||||
var element = _RoleStorage.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(RoleBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_RoleStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(RoleBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_RoleStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(RoleBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_RoleStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(RoleBindingModel model, bool withParams =
|
||||
true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия роли", nameof(model.Name));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Role. Name:{Name}. Id: {Id}", model.Name, model.Id);
|
||||
var element = _RoleStorage.GetElement(new RoleSearchModel
|
||||
{
|
||||
Name = model.Name
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Роль с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
109
FurnitureAssembly/FurnitureAssembly_StorekeeperBusinessLogic/BusinessLogics/ScopeLogic.cs
Normal file
109
FurnitureAssembly/FurnitureAssembly_StorekeeperBusinessLogic/BusinessLogics/ScopeLogic.cs
Normal file
@ -0,0 +1,109 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.BusinessLogicContracts;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.StorageContracts;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace FurnitureAssembly_Storekeeper_BusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ScopeLogic : IScopeLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IScopeStorage _ScopeStorage;
|
||||
public ScopeLogic(ILogger<ScopeLogic> logger, IScopeStorage
|
||||
ScopeStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_ScopeStorage = ScopeStorage;
|
||||
}
|
||||
public List<ScopeViewModel>? ReadList(ScopeSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. ScopeName:{Name}.Id:{Id}", model?.Name, model?.Id);
|
||||
var list = model == null ? _ScopeStorage.GetFullList() :
|
||||
_ScopeStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public ScopeViewModel? ReadElement(ScopeSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. ScopeName:{Name}.Id:{Id}", model.Name, model.Id);
|
||||
|
||||
var element = _ScopeStorage.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(ScopeBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_ScopeStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(ScopeBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_ScopeStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(ScopeBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_ScopeStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(ScopeBindingModel model, bool withParams =
|
||||
true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия области использования",
|
||||
nameof(model.Name));
|
||||
}
|
||||
_logger.LogInformation("Scope. Name:{Name}. Id: {Id}", model.Name, model.Id);
|
||||
var element = _ScopeStorage.GetElement(new ScopeSearchModel
|
||||
{
|
||||
Name = model.Name
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Область использования с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user