Compare commits
2 Commits
6543543d80
...
7ec384130a
Author | SHA1 | Date | |
---|---|---|---|
7ec384130a | |||
75fc3820b9 |
25
VetClinic/EmployeeView/EmployeeView.csproj
Normal file
25
VetClinic/EmployeeView/EmployeeView.csproj
Normal file
@ -0,0 +1,25 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="ReportViewerCore.WinForms" Version="15.1.17" />
|
||||
<PackageReference Include="Unity" Version="5.11.10" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
39
VetClinic/EmployeeView/Form1.Designer.cs
generated
Normal file
39
VetClinic/EmployeeView/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,39 @@
|
||||
namespace EmployeeView
|
||||
{
|
||||
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
VetClinic/EmployeeView/Form1.cs
Normal file
10
VetClinic/EmployeeView/Form1.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace EmployeeView
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
120
VetClinic/EmployeeView/Form1.resx
Normal file
120
VetClinic/EmployeeView/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>
|
17
VetClinic/EmployeeView/Program.cs
Normal file
17
VetClinic/EmployeeView/Program.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace EmployeeView
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
@ -3,10 +3,25 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.3.32922.545
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VetClinicView", "VetClinicView\VetClinicView.csproj", "{278BCF5A-EAE2-41FF-A5FC-5376AB7FE6E2}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientView", "VetClinicView\ClientView.csproj", "{278BCF5A-EAE2-41FF-A5FC-5376AB7FE6E2}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E3827255-F30E-4DD8-A18E-A542280F631F} = {E3827255-F30E-4DD8-A18E-A542280F631F}
|
||||
{F5FF371F-B183-4C35-9840-2DDA4F28135E} = {F5FF371F-B183-4C35-9840-2DDA4F28135E}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VetClinicBusinessLogic", "VetClinicBusinessLogic\VetClinicBusinessLogic.csproj", "{E3827255-F30E-4DD8-A18E-A542280F631F}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmployeeView", "EmployeeView\EmployeeView.csproj", "{B7AE7431-8989-43E3-A72E-AFFDF0861364}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E3827255-F30E-4DD8-A18E-A542280F631F} = {E3827255-F30E-4DD8-A18E-A542280F631F}
|
||||
{F5FF371F-B183-4C35-9840-2DDA4F28135E} = {F5FF371F-B183-4C35-9840-2DDA4F28135E}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VetClinicDatabaseImplement", "VetClinicDatabaseImplement\VetClinicDatabaseImplement.csproj", "{F5FF371F-B183-4C35-9840-2DDA4F28135E}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E3827255-F30E-4DD8-A18E-A542280F631F} = {E3827255-F30E-4DD8-A18E-A542280F631F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -21,6 +36,14 @@ Global
|
||||
{E3827255-F30E-4DD8-A18E-A542280F631F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E3827255-F30E-4DD8-A18E-A542280F631F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E3827255-F30E-4DD8-A18E-A542280F631F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B7AE7431-8989-43E3-A72E-AFFDF0861364}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B7AE7431-8989-43E3-A72E-AFFDF0861364}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B7AE7431-8989-43E3-A72E-AFFDF0861364}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B7AE7431-8989-43E3-A72E-AFFDF0861364}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F5FF371F-B183-4C35-9840-2DDA4F28135E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F5FF371F-B183-4C35-9840-2DDA4F28135E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F5FF371F-B183-4C35-9840-2DDA4F28135E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F5FF371F-B183-4C35-9840-2DDA4F28135E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicBusinessLogic.BindingModels;
|
||||
using VetClinicBusinessLogic.ViewModels;
|
||||
|
@ -6,4 +6,13 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="PDFsharp-MigraDoc-GDI" Version="1.50.5147" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
111
VetClinic/VetClinicDatabaseImplement/Implement/ClientStorage.cs
Normal file
111
VetClinic/VetClinicDatabaseImplement/Implement/ClientStorage.cs
Normal file
@ -0,0 +1,111 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicBusinessLogic.BindingModels;
|
||||
using VetClinicBusinessLogic.Interfaces;
|
||||
using VetClinicBusinessLogic.ViewModels;
|
||||
using VetClinicDatabaseImplement.Models;
|
||||
|
||||
namespace VetClinicDatabaseImplement.Implement
|
||||
{
|
||||
public class ClientStorage: IClientStorage
|
||||
{
|
||||
public List<ClientViewModel> GetFullList()
|
||||
{
|
||||
using var context = new VetClinicDatabase();
|
||||
return context.Clients
|
||||
.Select(CreateModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<ClientViewModel> GetFilteredList(ClientBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new VetClinicDatabase();
|
||||
return context.Clients
|
||||
.Where(rec => rec.Name.Contains(model.Name))
|
||||
.Select(CreateModel)
|
||||
.ToList();
|
||||
}
|
||||
public ClientViewModel GetElement(ClientBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new VetClinicDatabase();
|
||||
var client = context.Clients
|
||||
.FirstOrDefault(rec => rec.Phone == model.Phone);
|
||||
if (client == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return client.Password == model.Password ? CreateModel(client) : null;
|
||||
}
|
||||
public void Insert(ClientBindingModel model)
|
||||
{
|
||||
using var context = new VetClinicDatabase();
|
||||
Client element = context.Clients.FirstOrDefault(rec => rec.Phone ==
|
||||
model.Phone);
|
||||
if (element != null)
|
||||
{
|
||||
throw new Exception("Телефон уже зарегистрирован");
|
||||
}
|
||||
context.Clients.Add(CreateModel(model, new Client()));
|
||||
context.SaveChanges();
|
||||
}
|
||||
public void Update(ClientBindingModel model)
|
||||
{
|
||||
using var context = new VetClinicDatabase();
|
||||
var element = context.Clients.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Элемент не найден");
|
||||
}
|
||||
CreateModel(model, element);
|
||||
context.SaveChanges();
|
||||
}
|
||||
public void Delete(ClientBindingModel model)
|
||||
{
|
||||
using var context = new VetClinicDatabase();
|
||||
Client element = context.Clients.FirstOrDefault(rec => rec.Id ==
|
||||
model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Clients.Remove(element);
|
||||
context.SaveChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Элемент не найден");
|
||||
}
|
||||
}
|
||||
private static Client CreateModel(ClientBindingModel model, Client
|
||||
client)
|
||||
{
|
||||
client.Password = model.Password;
|
||||
client.Mail = model.Email;
|
||||
client.Name = model.Name;
|
||||
client.Pet = model.Pet;
|
||||
client.Phone = model.Phone;
|
||||
client.PetName = model.PetName;
|
||||
return client;
|
||||
}
|
||||
private static ClientViewModel CreateModel(Client client)
|
||||
{
|
||||
return new ClientViewModel
|
||||
{
|
||||
Id = client.Id,
|
||||
Name = client.Name,
|
||||
Email = client.Mail,
|
||||
Pet = client.Pet,
|
||||
PetName = client.PetName,
|
||||
Phone = client.Phone
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicBusinessLogic.BindingModels;
|
||||
using VetClinicBusinessLogic.Interfaces;
|
||||
using VetClinicBusinessLogic.ViewModels;
|
||||
using VetClinicDatabaseImplement.Models;
|
||||
|
||||
|
||||
namespace VetClinicDatabaseImplement.Implement
|
||||
{
|
||||
public class EmployeeStorage : IEmployeeStorage
|
||||
{
|
||||
public List<EmployeeViewModel> GetFullList()
|
||||
{
|
||||
using var context = new VetClinicDatabase();
|
||||
return context.Employees
|
||||
.Select(CreateModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<EmployeeViewModel> GetFilteredList(EmployeeBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new VetClinicDatabase();
|
||||
return context.Employees
|
||||
.Where(rec => rec.Name.Contains(model.Name))
|
||||
.Select(CreateModel)
|
||||
.ToList();
|
||||
}
|
||||
public EmployeeViewModel GetElement(EmployeeBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new VetClinicDatabase();
|
||||
var employee = context.Employees
|
||||
.FirstOrDefault(rec => rec.Phone == model.Phone);
|
||||
if (employee == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return employee.Password == model.Password ? CreateModel(employee) : null;
|
||||
}
|
||||
public void Insert(EmployeeBindingModel model)
|
||||
{
|
||||
using var context = new VetClinicDatabase();
|
||||
Employee element = context.Employees.FirstOrDefault(rec => rec.Phone ==
|
||||
model.Phone);
|
||||
if (element != null)
|
||||
{
|
||||
throw new Exception("Телефон уже зарегистрирован");
|
||||
}
|
||||
context.Employees.Add(CreateModel(model, new Employee()));
|
||||
context.SaveChanges();
|
||||
}
|
||||
public void Update(EmployeeBindingModel model)
|
||||
{
|
||||
using var context = new VetClinicDatabase();
|
||||
var element = context.Employees.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Элемент не найден");
|
||||
}
|
||||
CreateModel(model, element);
|
||||
context.SaveChanges();
|
||||
}
|
||||
public void Delete(EmployeeBindingModel model)
|
||||
{
|
||||
using var context = new VetClinicDatabase();
|
||||
Employee element = context.Employees.FirstOrDefault(rec => rec.Id ==
|
||||
model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Employees.Remove(element);
|
||||
context.SaveChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Элемент не найден");
|
||||
}
|
||||
}
|
||||
private static Employee CreateModel(EmployeeBindingModel model, Employee
|
||||
employee)
|
||||
{
|
||||
employee.Password = model.Password;
|
||||
employee.Name = model.Name;
|
||||
employee.Mail = model.Email;
|
||||
employee.Specialization = model.Specialization;
|
||||
employee.Phone = model.Phone;
|
||||
return employee;
|
||||
}
|
||||
private static EmployeeViewModel CreateModel(Employee employee)
|
||||
{
|
||||
return new EmployeeViewModel
|
||||
{
|
||||
Id = employee.Id,
|
||||
Email = employee.Mail,
|
||||
Name = employee.Name,
|
||||
Specialization = employee.Specialization,
|
||||
Phone = employee.Phone
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
145
VetClinic/VetClinicDatabaseImplement/Implement/PaymentStorage.cs
Normal file
145
VetClinic/VetClinicDatabaseImplement/Implement/PaymentStorage.cs
Normal file
@ -0,0 +1,145 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicBusinessLogic.BindingModels;
|
||||
using VetClinicBusinessLogic.Interfaces;
|
||||
using VetClinicBusinessLogic.ViewModels;
|
||||
using VetClinicDatabaseImplement.Models;
|
||||
|
||||
namespace VetClinicDatabaseImplement.Implement
|
||||
{
|
||||
public class PaymentStorage : IPaymentStorage
|
||||
{
|
||||
public List<PaymentViewModel> GetFullList()
|
||||
{
|
||||
var context = new VetClinicDatabase();
|
||||
return context.Payments.Include(rec => rec.Visit)
|
||||
.Select(CreateViewModel)
|
||||
.OrderBy(x => x.DateOfPayment)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<PaymentViewModel> GetFilteredList(PaymentBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var context = new VetClinicDatabase();
|
||||
var list = context.Payments.Where(rec => rec.VisitsId == model.VisitId)
|
||||
.OrderBy(x => x.DateOfPayment)
|
||||
.Include(rec => rec.Visit);
|
||||
return list
|
||||
.Select(rec => new PaymentViewModel
|
||||
{
|
||||
DateOfPayment = rec.DateOfPayment,
|
||||
Id = rec.Id,
|
||||
Remains = rec.Remains,
|
||||
Sum = rec.Sum,
|
||||
VisitId = rec.VisitsId
|
||||
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
||||
public PaymentViewModel GetElement(PaymentBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var context = new VetClinicDatabase();
|
||||
{
|
||||
var payment = context.Payments.Include(rec => rec.Visit)
|
||||
.FirstOrDefault(rec => rec.VisitsId == model.VisitId);
|
||||
return payment != null ?
|
||||
new PaymentViewModel
|
||||
{
|
||||
DateOfPayment = payment.DateOfPayment,
|
||||
Id = payment.Id,
|
||||
Remains = payment.Visit.Sum,
|
||||
Sum = payment.Sum,
|
||||
VisitId = payment.VisitsId
|
||||
} :
|
||||
null;
|
||||
}
|
||||
}
|
||||
public PaymentViewModel GetElementFirstLast(PaymentDateBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var context = new VetClinicDatabase();
|
||||
{
|
||||
return new PaymentViewModel()
|
||||
{
|
||||
Remains = context.Payments.Include(rec => rec.Visit)
|
||||
.Where(x => x.DateOfPayment > model.DateFrom || x.DateOfPayment < model.DateTo).Sum(x => x.Sum)
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void Insert(PaymentBindingModel model)
|
||||
{
|
||||
var context = new VetClinicDatabase();
|
||||
context.Payments.Add(CreateModel(model, new Payment()));
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
public void Update(PaymentBindingModel model)
|
||||
{
|
||||
var context = new VetClinicDatabase();
|
||||
var element = context.Payments.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Оплата не найдена");
|
||||
}
|
||||
CreateModel(model, element);
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
|
||||
public void Delete(PaymentBindingModel model)
|
||||
{
|
||||
var context = new VetClinicDatabase();
|
||||
|
||||
Payment element = context.Payments.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Payments.Remove(element);
|
||||
context.SaveChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Оплата не найдена");
|
||||
}
|
||||
}
|
||||
|
||||
private PaymentViewModel CreateViewModel(Payment payment)
|
||||
{
|
||||
return new PaymentViewModel
|
||||
{
|
||||
DateOfPayment = payment.DateOfPayment,
|
||||
Id = payment.Id,
|
||||
Remains = payment.Visit.Sum,
|
||||
Sum = payment.Sum,
|
||||
VisitId = payment.VisitsId
|
||||
};
|
||||
}
|
||||
|
||||
private Payment CreateModel(PaymentBindingModel model, Payment payment)
|
||||
{
|
||||
payment.DateOfPayment = model.DateOfPayment;
|
||||
payment.Id = model.Id;
|
||||
payment.Remains = model.Remains;
|
||||
payment.Sum = model.Sum;
|
||||
payment.VisitsId = model.VisitId;
|
||||
return payment;
|
||||
}
|
||||
}
|
||||
}
|
107
VetClinic/VetClinicDatabaseImplement/Implement/ServiceStorage.cs
Normal file
107
VetClinic/VetClinicDatabaseImplement/Implement/ServiceStorage.cs
Normal file
@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicBusinessLogic.BindingModels;
|
||||
using VetClinicBusinessLogic.Interfaces;
|
||||
using VetClinicBusinessLogic.ViewModels;
|
||||
using VetClinicDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace VetClinicDatabaseImplement.Implement
|
||||
{
|
||||
public class ServiceStorage : IServiceStorage
|
||||
{
|
||||
public List<ServiceViewModel> GetFullList()
|
||||
{
|
||||
using var context = new VetClinicDatabase();
|
||||
return context.Services
|
||||
.Include(rec => rec.VisitServices)
|
||||
.ThenInclude(rec => rec.Visit)
|
||||
.Select(CreateModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<ServiceViewModel> GetFilteredList(ServiceBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new VetClinicDatabase();
|
||||
return context.Services
|
||||
.Where(rec => rec.Name.Contains(model.Name))
|
||||
.Include(rec => rec.VisitServices)
|
||||
.ThenInclude(rec => rec.Visit)
|
||||
.Select(CreateModel)
|
||||
.ToList();
|
||||
}
|
||||
public ServiceViewModel GetElement(ServiceBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new VetClinicDatabase();
|
||||
var service = context.Services
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (service == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return CreateModel(service);
|
||||
}
|
||||
public void Insert(ServiceBindingModel model)
|
||||
{
|
||||
using var context = new VetClinicDatabase();
|
||||
|
||||
context.Services.Add(CreateModel(model, new Service()));
|
||||
context.SaveChanges();
|
||||
}
|
||||
public void Update(ServiceBindingModel model)
|
||||
{
|
||||
using var context = new VetClinicDatabase();
|
||||
var element = context.Services.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Элемент не найден");
|
||||
}
|
||||
CreateModel(model, element);
|
||||
context.SaveChanges();
|
||||
}
|
||||
public void Delete(ServiceBindingModel model)
|
||||
{
|
||||
using var context = new VetClinicDatabase();
|
||||
Service element = context.Services.FirstOrDefault(rec => rec.Id ==
|
||||
model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Services.Remove(element);
|
||||
context.SaveChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Элемент не найден");
|
||||
}
|
||||
}
|
||||
private static Service CreateModel(ServiceBindingModel model, Service
|
||||
service)
|
||||
{
|
||||
service.Cost = model.Cost;
|
||||
service.Name = model.Name;
|
||||
return service;
|
||||
}
|
||||
private static ServiceViewModel CreateModel(Service service)
|
||||
{
|
||||
return new ServiceViewModel
|
||||
{
|
||||
Id = service.Id,
|
||||
Cost = service.Cost,
|
||||
Name = service.Name,
|
||||
VisitServices = service.VisitServices
|
||||
.ToDictionary(recPC => recPC.VisitId,
|
||||
recPC => recPC.Visit.DateVisit)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
200
VetClinic/VetClinicDatabaseImplement/Implement/VisitStorage.cs
Normal file
200
VetClinic/VetClinicDatabaseImplement/Implement/VisitStorage.cs
Normal file
@ -0,0 +1,200 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicBusinessLogic.BindingModels;
|
||||
using VetClinicBusinessLogic.Interfaces;
|
||||
using VetClinicBusinessLogic.ViewModels;
|
||||
using VetClinicDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
|
||||
namespace VetClinicDatabaseImplement.Implement
|
||||
{
|
||||
public class VisitStorage : IVisitStorage
|
||||
{
|
||||
public List<VisitViewModel> GetFullList()
|
||||
{
|
||||
using var context = new VetClinicDatabase();
|
||||
return context.Visits
|
||||
.Include(rec => rec.VisitServices)
|
||||
.ThenInclude(rec => rec.Service)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Employee)
|
||||
.Select(CreateModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<VisitViewModel> GetFilteredList(VisitBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new VetClinicDatabase();
|
||||
return context.Visits.Include(rec => rec.VisitServices)
|
||||
.ThenInclude(rec => rec.Service)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Employee).Where(rec => rec.ClientId == model.ClientId)
|
||||
.Select(CreateModel)
|
||||
|
||||
.ToList();
|
||||
}
|
||||
public List<VisitViewModel> GetFilteredListEmployee(VisitBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new VetClinicDatabase();
|
||||
return context.Visits.Include(rec => rec.VisitServices)
|
||||
.ThenInclude(rec => rec.Service)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Employee).Where(rec => rec.EmployeeId == model.EmployeeId)
|
||||
.Select(CreateModel)
|
||||
|
||||
.ToList();
|
||||
}
|
||||
public List<VisitViewModel> GetFilteredListDate(VisitBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new VetClinicDatabase();
|
||||
return context.Visits.Include(rec => rec.VisitServices)
|
||||
.ThenInclude(rec => rec.Service)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Employee).Where(rec => rec.Id.Equals(model.Id) || rec.DateVisit >= model.DateFrom && rec.DateVisit <= model.DateTo)
|
||||
.Select(CreateModel)
|
||||
|
||||
.ToList();
|
||||
}
|
||||
public VisitViewModel GetElement(VisitBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new VetClinicDatabase();
|
||||
var visit = context.Visits
|
||||
.Include(rec => rec.VisitServices)
|
||||
.ThenInclude(rec => rec.Service)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Employee)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id)
|
||||
;
|
||||
if (visit == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return CreateModel(visit);
|
||||
}
|
||||
public void Insert(VisitBindingModel model)
|
||||
{
|
||||
using var context = new VetClinicDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
CreateModel(model, new Visit(), context);
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public void Update(VisitBindingModel model)
|
||||
{
|
||||
using var context = new VetClinicDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var element = context.Visits.FirstOrDefault(rec => rec.Id ==
|
||||
model.Id);
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Элемент не найден");
|
||||
}
|
||||
CreateModel(model, element, context);
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public void Delete(VisitBindingModel model)
|
||||
{
|
||||
using var context = new VetClinicDatabase();
|
||||
Visit element = context.Visits.FirstOrDefault(rec => rec.Id ==
|
||||
model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Visits.Remove(element);
|
||||
context.SaveChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Элемент не найден");
|
||||
}
|
||||
}
|
||||
private static Visit CreateModel(VisitBindingModel model, Visit visit,
|
||||
VetClinicDatabase context)
|
||||
{
|
||||
visit.DateVisit = model.VisitsDate;
|
||||
visit.ClientId = model.ClientId;
|
||||
visit.EmployeeId = model.EmployeeId;
|
||||
visit.Sum = model.Sum;
|
||||
if (visit.Id == 0)
|
||||
{
|
||||
context.Visits.Add(visit);
|
||||
context.SaveChanges();
|
||||
}
|
||||
if (model.Id != 0)
|
||||
{
|
||||
var visitServices = context.VisitServices.Where(rec =>
|
||||
rec.VisitId == model.Id).ToList();
|
||||
// удалили те, которых нет в модели
|
||||
context.VisitServices.RemoveRange(visitServices.Where(rec =>
|
||||
!model.VisitServices.ContainsKey(rec.VisitId)).ToList());
|
||||
context.SaveChanges();
|
||||
context.SaveChanges();
|
||||
}
|
||||
// добавили новые
|
||||
foreach (var pc in model.VisitServices)
|
||||
{
|
||||
context.VisitServices.Add(new VisitService
|
||||
{
|
||||
VisitId = visit.Id,
|
||||
ServiceId = pc.Key,
|
||||
});
|
||||
var temp = context.VisitServices;
|
||||
context.SaveChanges();
|
||||
}
|
||||
return visit;
|
||||
}
|
||||
private static VisitViewModel CreateModel(Visit visit)
|
||||
{
|
||||
return new VisitViewModel
|
||||
{
|
||||
Id = visit.Id,
|
||||
ClientName = visit.Client.Name,
|
||||
EmployeeName = visit?.Employee?.Name,
|
||||
ClientId = visit.ClientId,
|
||||
EmployeeId = visit?.EmployeeId,
|
||||
Sum = visit.Sum,
|
||||
VisitsDate = visit.DateVisit,
|
||||
VisitServices = visit.VisitServices
|
||||
.ToDictionary(recPC => recPC.ServiceId,
|
||||
recPC => recPC.Service?.Name)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,310 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using VetClinicDatabaseImplement;
|
||||
|
||||
namespace VetClinicDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(VetClinicDatabase))]
|
||||
partial class VetClinicDatabaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128)
|
||||
.HasAnnotation("ProductVersion", "5.0.15")
|
||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
||||
|
||||
modelBuilder.Entity("VetClinicDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
||||
|
||||
b.Property<string>("Mail")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Pet")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PetName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Phone")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
||||
|
||||
b.Property<string>("Mail")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Phone")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Specialization")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Employees");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDatabaseImplement.Models.Expense", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<decimal>("Sum")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Expenses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDatabaseImplement.Models.Payment", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
||||
|
||||
b.Property<DateTime>("DateOfPayment")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<decimal>("Remains")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.Property<decimal>("Sum")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.Property<int?>("VisitId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("VisitsId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("VisitId");
|
||||
|
||||
b.ToTable("Payments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDatabaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
||||
|
||||
b.Property<decimal>("Cost")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Services");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDatabaseImplement.Models.ServiceExpense", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
||||
|
||||
b.Property<int>("ExpenseId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ExpenseId");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.ToTable("ServiceExpense");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDatabaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateVisit")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int?>("EmployeeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("Sum")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.ToTable("Visits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDatabaseImplement.Models.VisitService", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("VisitId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.HasIndex("VisitId");
|
||||
|
||||
b.ToTable("VisitServices");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDatabaseImplement.Models.Payment", b =>
|
||||
{
|
||||
b.HasOne("VetClinicDatabaseImplement.Models.Visit", "Visit")
|
||||
.WithMany("Payment")
|
||||
.HasForeignKey("VisitId");
|
||||
|
||||
b.Navigation("Visit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDatabaseImplement.Models.ServiceExpense", b =>
|
||||
{
|
||||
b.HasOne("VetClinicDatabaseImplement.Models.Expense", "Expense")
|
||||
.WithMany("ServiceExpenses")
|
||||
.HasForeignKey("ExpenseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("VetClinicDatabaseImplement.Models.Service", "Service")
|
||||
.WithMany()
|
||||
.HasForeignKey("ServiceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Expense");
|
||||
|
||||
b.Navigation("Service");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDatabaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.HasOne("VetClinicDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany("Visits")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("VetClinicDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany()
|
||||
.HasForeignKey("EmployeeId");
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDatabaseImplement.Models.VisitService", b =>
|
||||
{
|
||||
b.HasOne("VetClinicDatabaseImplement.Models.Service", "Service")
|
||||
.WithMany("VisitServices")
|
||||
.HasForeignKey("ServiceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("VetClinicDatabaseImplement.Models.Visit", "Visit")
|
||||
.WithMany("VisitServices")
|
||||
.HasForeignKey("VisitId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Service");
|
||||
|
||||
b.Navigation("Visit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Navigation("Visits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDatabaseImplement.Models.Expense", b =>
|
||||
{
|
||||
b.Navigation("ServiceExpenses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDatabaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.Navigation("VisitServices");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDatabaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.Navigation("Payment");
|
||||
|
||||
b.Navigation("VisitServices");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
186
VetClinic/VetClinicDatabaseImplement/Migrations/init2.cs
Normal file
186
VetClinic/VetClinicDatabaseImplement/Migrations/init2.cs
Normal file
@ -0,0 +1,186 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
|
||||
namespace VetClinicDatabaseImplement.Migrations
|
||||
{
|
||||
public partial class init2 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Clients",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
Phone = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
Pet = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
PetName = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Clients", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Employees",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Phone = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
Specialization = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Employees", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Services",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
Cost = table.Column<decimal>(type: "decimal(18,2)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Services", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Expenses",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Sum = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
||||
ServiceId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Expenses", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Expenses_Services_ServiceId",
|
||||
column: x => x.ServiceId,
|
||||
principalTable: "Services",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Visits",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
DateVisit = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
Remains = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
||||
EmployeeId = table.Column<int>(type: "int", nullable: true),
|
||||
ServiceId = table.Column<int>(type: "int", nullable: false),
|
||||
ClientId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Visits", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Visits_Clients_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Visits_Employees_EmployeeId",
|
||||
column: x => x.EmployeeId,
|
||||
principalTable: "Employees",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_Visits_Services_ServiceId",
|
||||
column: x => x.ServiceId,
|
||||
principalTable: "Services",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Payments",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
VisitsId = table.Column<int>(type: "int", nullable: false),
|
||||
Sum = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
||||
DateOfPayment = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
VisitId = table.Column<int>(type: "int", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Payments", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Payments_Visits_VisitId",
|
||||
column: x => x.VisitId,
|
||||
principalTable: "Visits",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Expenses_ServiceId",
|
||||
table: "Expenses",
|
||||
column: "ServiceId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Payments_VisitId",
|
||||
table: "Payments",
|
||||
column: "VisitId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Visits_ClientId",
|
||||
table: "Visits",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Visits_EmployeeId",
|
||||
table: "Visits",
|
||||
column: "EmployeeId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Visits_ServiceId",
|
||||
table: "Visits",
|
||||
column: "ServiceId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Expenses");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Payments");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Visits");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Clients");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Employees");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Services");
|
||||
}
|
||||
}
|
||||
}
|
120
VetClinic/VetClinicDatabaseImplement/Migrations/mail.cs
Normal file
120
VetClinic/VetClinicDatabaseImplement/Migrations/mail.cs
Normal file
@ -0,0 +1,120 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
|
||||
namespace VetClinicDatabaseImplement.Migrations
|
||||
{
|
||||
public partial class mail : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Expenses_Services_ServiceId",
|
||||
table: "Expenses");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Expenses_ServiceId",
|
||||
table: "Expenses");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ServiceId",
|
||||
table: "Expenses");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Name",
|
||||
table: "Expenses",
|
||||
type: "nvarchar(max)",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Mail",
|
||||
table: "Employees",
|
||||
type: "nvarchar(max)",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Mail",
|
||||
table: "Clients",
|
||||
type: "nvarchar(max)",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ServiceExpense",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ExpenseId = table.Column<int>(type: "int", nullable: false),
|
||||
ServiceId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ServiceExpense", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ServiceExpense_Expenses_ExpenseId",
|
||||
column: x => x.ExpenseId,
|
||||
principalTable: "Expenses",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ServiceExpense_Services_ServiceId",
|
||||
column: x => x.ServiceId,
|
||||
principalTable: "Services",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ServiceExpense_ExpenseId",
|
||||
table: "ServiceExpense",
|
||||
column: "ExpenseId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ServiceExpense_ServiceId",
|
||||
table: "ServiceExpense",
|
||||
column: "ServiceId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "ServiceExpense");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Name",
|
||||
table: "Expenses");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Mail",
|
||||
table: "Employees");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Mail",
|
||||
table: "Clients");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ServiceId",
|
||||
table: "Expenses",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Expenses_ServiceId",
|
||||
table: "Expenses",
|
||||
column: "ServiceId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Expenses_Services_ServiceId",
|
||||
table: "Expenses",
|
||||
column: "ServiceId",
|
||||
principalTable: "Services",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VetClinicDatabaseImplement.Migrations
|
||||
{
|
||||
public partial class manyToMany : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Visits_Services_ServiceId",
|
||||
table: "Visits");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Visits_ServiceId",
|
||||
table: "Visits");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "VisitServices",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
VisitId = table.Column<int>(type: "int", nullable: false),
|
||||
ServiceId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_VisitServices", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_VisitServices_Services_ServiceId",
|
||||
column: x => x.ServiceId,
|
||||
principalTable: "Services",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_VisitServices_Visits_VisitId",
|
||||
column: x => x.VisitId,
|
||||
principalTable: "Visits",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_VisitServices_ServiceId",
|
||||
table: "VisitServices",
|
||||
column: "ServiceId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_VisitServices_VisitId",
|
||||
table: "VisitServices",
|
||||
column: "VisitId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "VisitServices");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Visits_ServiceId",
|
||||
table: "Visits",
|
||||
column: "ServiceId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Visits_Services_ServiceId",
|
||||
table: "Visits",
|
||||
column: "ServiceId",
|
||||
principalTable: "Services",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
}
|
||||
}
|
40
VetClinic/VetClinicDatabaseImplement/Migrations/payment.cs
Normal file
40
VetClinic/VetClinicDatabaseImplement/Migrations/payment.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
|
||||
namespace VetClinicDatabaseImplement.Migrations
|
||||
{
|
||||
public partial class payment : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "Remains",
|
||||
table: "Visits",
|
||||
newName: "Sum");
|
||||
|
||||
migrationBuilder.AddColumn<decimal>(
|
||||
name: "Remains",
|
||||
table: "Payments",
|
||||
type: "decimal(18,2)",
|
||||
nullable: false,
|
||||
defaultValue: 0m);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Remains",
|
||||
table: "Payments");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "Sum",
|
||||
table: "Visits",
|
||||
newName: "Remains");
|
||||
}
|
||||
}
|
||||
}
|
24
VetClinic/VetClinicDatabaseImplement/Models/Client.cs
Normal file
24
VetClinic/VetClinicDatabaseImplement/Models/Client.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using VetClinicBusinessLogic.Enums;
|
||||
using VetClinicDatabaseImplement.Models;
|
||||
|
||||
namespace VetClinicDatabaseImplement.Models
|
||||
{
|
||||
public class Client
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Phone { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string Mail { get; set; }
|
||||
public string Pet { get; set; }
|
||||
public string PetName { get; set; }
|
||||
public List<Visit> Visits { get; set; }
|
||||
}
|
||||
}
|
19
VetClinic/VetClinicDatabaseImplement/Models/Employee.cs
Normal file
19
VetClinic/VetClinicDatabaseImplement/Models/Employee.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VetClinicDatabaseImplement.Models
|
||||
{
|
||||
public class Employee
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Phone { get; set; }
|
||||
public string Mail { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Specialization { get; set; }
|
||||
List<Visit> Visits { get; set; }
|
||||
}
|
||||
}
|
18
VetClinic/VetClinicDatabaseImplement/Models/Expense.cs
Normal file
18
VetClinic/VetClinicDatabaseImplement/Models/Expense.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace VetClinicDatabaseImplement.Models
|
||||
{
|
||||
public class Expense
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public decimal Sum { get; set; }
|
||||
public List<ServiceExpense> ServiceExpenses { get; set; }
|
||||
}
|
||||
}
|
20
VetClinic/VetClinicDatabaseImplement/Models/Payment.cs
Normal file
20
VetClinic/VetClinicDatabaseImplement/Models/Payment.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace VetClinicDatabaseImplement.Models
|
||||
{
|
||||
public class Payment
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int VisitsId { get; set; }
|
||||
public decimal Sum { get; set; }
|
||||
public decimal Remains { get; set; }
|
||||
public DateTime DateOfPayment { get; set; }
|
||||
public Visit Visit { get; set; }
|
||||
}
|
||||
}
|
19
VetClinic/VetClinicDatabaseImplement/Models/Service.cs
Normal file
19
VetClinic/VetClinicDatabaseImplement/Models/Service.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
|
||||
namespace VetClinicDatabaseImplement.Models
|
||||
{
|
||||
public class Service
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public decimal Cost { get; set; }
|
||||
public List<VisitService> VisitServices { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VetClinicDatabaseImplement.Models
|
||||
{
|
||||
public class ServiceExpense
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int ExpenseId { get; set; }
|
||||
public int ServiceId { get; set; }
|
||||
public Expense Expense { get; set; }
|
||||
public Service Service { get; set; }
|
||||
}
|
||||
}
|
24
VetClinic/VetClinicDatabaseImplement/Models/Visit.cs
Normal file
24
VetClinic/VetClinicDatabaseImplement/Models/Visit.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace VetClinicDatabaseImplement.Models
|
||||
{
|
||||
public class Visit
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public DateTime DateVisit { get; set; }
|
||||
public decimal Sum { get; set; }
|
||||
public int? EmployeeId { get; set; }
|
||||
public int ServiceId { get; set; }
|
||||
public int ClientId { get; set; }
|
||||
public Employee Employee { get; set; }
|
||||
public List<VisitService> VisitServices { get; set; }
|
||||
public Client Client { get; set; }
|
||||
public virtual List<Payment> Payment { get; set; }
|
||||
}
|
||||
}
|
17
VetClinic/VetClinicDatabaseImplement/Models/VisitService.cs
Normal file
17
VetClinic/VetClinicDatabaseImplement/Models/VisitService.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VetClinicDatabaseImplement.Models
|
||||
{
|
||||
public class VisitService
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int VisitId { get; set; }
|
||||
public int ServiceId { get; set; }
|
||||
public Service Service { get; set; }
|
||||
public Visit Visit { get; set; }
|
||||
}
|
||||
}
|
30
VetClinic/VetClinicDatabaseImplement/VetClinicDatabase.cs
Normal file
30
VetClinic/VetClinicDatabaseImplement/VetClinicDatabase.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace VetClinicDatabaseImplement
|
||||
{
|
||||
public class VetClinicDatabase : DbContext
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-KG5V1L9\SQLEXPRESS;Initial Catalog=VetClinicDB;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
|
||||
}
|
||||
public virtual DbSet<Client> Clients { set; get; }
|
||||
public virtual DbSet<VisitService> VisitServices { set; get; }
|
||||
public virtual DbSet<Employee> Employees { set; get; }
|
||||
public virtual DbSet<Payment> Payments { set; get; }
|
||||
public virtual DbSet<Expense> Expenses { set; get; }
|
||||
public virtual DbSet<Visit> Visits { set; get; }
|
||||
public virtual DbSet<Service> Services { set; get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\VetClinicBusinessLogic\VetClinicBusinessLogic.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
20
VetClinic/VetClinicView/ClientView.csproj
Normal file
20
VetClinic/VetClinicView/ClientView.csproj
Normal file
@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="ReportViewerCore.WinForms" Version="15.1.17" />
|
||||
<PackageReference Include="Unity" Version="5.11.10" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -1,11 +0,0 @@
|
||||
<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>
|
Loading…
x
Reference in New Issue
Block a user