2. Создание моделей и контрактов

This commit is contained in:
Никита Чернышов 2023-04-08 03:39:38 +04:00
parent 760382c989
commit 13e4dddbbe
36 changed files with 588 additions and 172 deletions

View File

@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33213.308
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LawFirm", "LawFirm\LawFirm.csproj", "{599A2ED4-41F4-4D39-8A30-9474710AC617}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LawFirmView", "LawFirm\LawFirmView.csproj", "{599A2ED4-41F4-4D39-8A30-9474710AC617}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LawFirmContracts", "LawFirmContracts\LawFirmContracts.csproj", "{E2306BF5-FCE9-4195-85BF-22C35495A8D0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -15,6 +17,10 @@ Global
{599A2ED4-41F4-4D39-8A30-9474710AC617}.Debug|Any CPU.Build.0 = Debug|Any CPU
{599A2ED4-41F4-4D39-8A30-9474710AC617}.Release|Any CPU.ActiveCfg = Release|Any CPU
{599A2ED4-41F4-4D39-8A30-9474710AC617}.Release|Any CPU.Build.0 = Release|Any CPU
{E2306BF5-FCE9-4195-85BF-22C35495A8D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E2306BF5-FCE9-4195-85BF-22C35495A8D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E2306BF5-FCE9-4195-85BF-22C35495A8D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E2306BF5-FCE9-4195-85BF-22C35495A8D0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -1,39 +0,0 @@
namespace LawFirm
{
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
}
}

View File

@ -1,10 +0,0 @@
namespace LawFirm
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

View File

@ -1,120 +0,0 @@
<?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>

View File

@ -1,4 +1,4 @@
namespace LawFirm
namespace LawFirmView
{
internal static class Program
{
@ -11,7 +11,7 @@ namespace LawFirm
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
Application.Run();
}
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LawFirmContracts.Models;
namespace LawFirmContracts.BindingModels
{
public class CaseBindingModel : ICaseModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public DateTime DateCreated { get; set; } = DateTime.Now;
public int CustomerId { get; set; }
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LawFirmContracts.Models;
namespace LawFirmContracts.BindingModels
{
public class CustomerBindingModel : ICustomerModel
{
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 string Surname { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LawFirmContracts.Models;
namespace LawFirmContracts.BindingModels
{
public class ItemBindingModel : IItemModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public decimal Price { get; set; }
public int PaymentId { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LawFirmContracts.Models;
namespace LawFirmContracts.BindingModels
{
public class PaymentBindingModel : IPaymentModel
{
public int Id { get; set; }
public DateTime DatePayment { get; set; }
public decimal Sum { get; set; }
public int CaseId { get; set; }
}
}

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.BindingModels
{
public class ReportBindingModel
{
public string FileName { get; set; } = string.Empty;
/// <summary>
/// Выбранные работы для отчета по заявкам
/// </summary>
public List<int>? SelectedWorks { get; set; }
/// <summary>
/// Начало периода для отчета по оплатам
/// </summary>
public DateTime? DateFrom { get; set; }
/// <summary>
/// Конец периода для отчета по оплатам
/// </summary>
public DateTime? DateTo { get; set; }
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LawFirmContracts.Models;
namespace LawFirmContracts.BindingModels
{
public class ServiceBindingModel : IServiceModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public decimal Price { get; set; }
public int CaseId { get; set; }
public int ItemId { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LawFirmContracts.BindingModels;
using LawFirmContracts.SearchModels;
using LawFirmContracts.ViewModels;
namespace LawFirmContracts.BusinessLogicsContracts
{
public interface ICaseLogic
{
List<CaseViewModel>? ReadList(CaseSearchModel? model);
CaseViewModel? ReadElement(CaseSearchModel model);
bool Create(CaseBindingModel model);
bool Update(CaseBindingModel model);
bool Delete(CaseBindingModel model);
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LawFirmContracts.BindingModels;
using LawFirmContracts.SearchModels;
using LawFirmContracts.ViewModels;
namespace LawFirmContracts.BusinessLogicsContracts
{
public interface ICustomerLogic
{
List<CustomerViewModel>? ReadList(CustomerSearchModel? model);
CustomerViewModel? ReadElement(CustomerSearchModel model);
bool Create(CustomerBindingModel model);
bool Update(CustomerBindingModel model);
bool Delete(CustomerBindingModel model);
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LawFirmContracts.BindingModels;
using LawFirmContracts.SearchModels;
using LawFirmContracts.ViewModels;
namespace LawFirmContracts.BusinessLogicsContracts
{
public interface IItemLogic
{
List<ItemViewModel>? ReadList(ItemSearchModel? model);
ItemViewModel? ReadElement(ItemSearchModel model);
bool Create(ItemBindingModel model);
bool Update(ItemBindingModel model);
bool Delete(ItemBindingModel model);
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LawFirmContracts.BindingModels;
using LawFirmContracts.SearchModels;
using LawFirmContracts.ViewModels;
namespace LawFirmContracts.BusinessLogicsContracts
{
public interface IPaymentLogic
{
List<PaymentViewModel>? ReadList(PaymentSearchModel? model);
PaymentViewModel? ReadElement(PaymentSearchModel model);
bool Create(PaymentBindingModel model);
bool Update(PaymentBindingModel model);
bool Delete(PaymentBindingModel model);
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LawFirmContracts.BindingModels;
using LawFirmContracts.SearchModels;
using LawFirmContracts.ViewModels;
namespace LawFirmContracts.BusinessLogicsContracts
{
public interface IServiceLogic
{
List<ServiceViewModel>? ReadList(ServiceSearchModel? model);
ServiceViewModel? ReadElement(ServiceSearchModel model);
bool Create(ServiceBindingModel model);
bool Update(ServiceBindingModel model);
bool Delete(ServiceBindingModel model);
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.Id
{
public interface IId
{
/// <summary>
/// Id
/// </summary>
int Id { get; }
}
}

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Folder Include="StorageContracts\" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LawFirmContracts.Id;
namespace LawFirmContracts.Models
{
/// <summary>
/// Дело
/// </summary>
public interface ICaseModel : IId
{
/// <summary>
/// Описание
/// </summary>
string Name { get; }
/// <summary>
/// Дата создания
/// </summary>
DateTime DateCreated { get; }
/// <summary>
/// Id клиента
/// </summary>
int CustomerId { get; }
}
}

View File

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LawFirmContracts.Id;
namespace LawFirmContracts.Models
{
public interface ICustomerModel : IId
{
/// <summary>
/// Логин
/// </summary>
string Login { get; }
/// <summary>
/// Пароль
/// </summary>
string Password { get; }
/// <summary>
/// Имя
/// </summary>
string Name { get; }
/// <summary>
/// Фамилия
/// </summary>
string Surname { get; }
}
}

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LawFirmContracts.Id;
namespace LawFirmContracts.Models
{
public interface IItemModel : IId
{
/// <summary>
/// Наименование
/// </summary>
string Name { get; }
/// <summary>
/// Цена
/// </summary>
decimal Price { get; }
/// <summary>
/// Id оплаты
/// </summary>
int PaymentId { get; }
}
}

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LawFirmContracts.Id;
namespace LawFirmContracts.Models
{
/// <summary>
/// Оплата
/// </summary>
public interface IPaymentModel : IId
{
/// <summary>
/// Дата оплаты
/// </summary>
DateTime DatePayment { get; }
/// <summary>
/// Сумма оплаты
/// </summary>
decimal Sum { get; }
/// <summary>
/// Id дела
/// </summary>
int CaseId { get; }
}
}

View File

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LawFirmContracts.Id;
namespace LawFirmContracts.Models
{
public interface IServiceModel : IId
{
/// <summary>
/// Наименование
/// </summary>
string Name { get; }
/// <summary>
/// Цена
/// </summary>
decimal Price { get; }
/// <summary>
/// Id статьи затрат
/// </summary>
int ItemId { get; }
/// <summary>
/// Id дела
/// </summary>
int CaseId { get; }
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.SearchModels
{
public class CaseSearchModel
{
public int? Id { get; set; }
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.SearchModels
{
public class CustomerSearchModel
{
public int? Id { get; set; }
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.SearchModels
{
public class ItemSearchModel
{
public int? Id { get; set; }
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.SearchModels
{
public class PaymentSearchModel
{
public int? Id { get; set; }
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.SearchModels
{
public class ServiceSearchModel
{
public int? Id { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using LawFirmContracts.Models;
namespace LawFirmContracts.ViewModels
{
public class CaseViewModel : ICaseModel
{
public int Id { get; set; }
[DisplayName("Наименование дела")]
public string Name { get; set; } = string.Empty;
[DisplayName("Дата создания")]
public DateTime DateCreated { get; set; } = DateTime.Now;
public int CustomerId { get; set; }
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using LawFirmContracts.Models;
namespace LawFirmContracts.ViewModels
{
public class CustomerViewModel : ICustomerModel
{
public int Id { get; set; }
[DisplayName("Логин")]
public string Login { get; set; } = string.Empty;
[DisplayName("Пароль")]
public string Password { get; set; } = string.Empty;
[DisplayName("Имя")]
public string Name { get; set; } = string.Empty;
[DisplayName("Фамилия")]
public string Surname { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using LawFirmContracts.Models;
namespace LawFirmContracts.ViewModels
{
public class ItemViewModel : IItemModel
{
public int Id { get; set; }
[DisplayName("Наименование")]
public string Name { get; set; } = string.Empty;
[DisplayName("Цена")]
public decimal Price { get; set; }
public int PaymentId { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using LawFirmContracts.Models;
namespace LawFirmContracts.ViewModels
{
public class PaymentViewModel : IPaymentModel
{
public int Id { get; set; }
[DisplayName("Дата оплаты")]
public DateTime DatePayment { get; set; }
[DisplayName("Сумма")]
public decimal Sum { get; set; }
public int CaseId { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.ViewModels
{
/// <summary>
/// Модель для получения всех дел для отчета
/// </summary>
public class ReportCasesViewModel
{
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.ViewModels
{
/// <summary>
/// Модель для получения всех услуг для отчета
/// </summary>
public class ReportLawServicesViewModel
{
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using LawFirmContracts.Models;
namespace LawFirmContracts.ViewModels
{
public class ServiceViewModel : IServiceModel
{
public int Id { get; set; }
[DisplayName("Наименование")]
public string Name { get; set; } = string.Empty;
[DisplayName("Стоимость услуги")]
public decimal Price { get; set; }
public int CaseId { get; set; }
public int ItemId { get; set; }
}
}