Compare commits

...

No commits in common. "main" and "master" have entirely different histories.
main ... master

100 changed files with 7800 additions and 42 deletions

63
.gitattributes vendored Normal file
View File

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

41
.gitignore vendored
View File

@ -1,8 +1,7 @@
# ---> VisualStudio
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
@ -30,6 +29,7 @@ x86/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
@ -91,7 +91,6 @@ StyleCopReport.xml
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.vspscc
*.vssscc
.builds
@ -295,17 +294,6 @@ node_modules/
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
*.vbp
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
*.dsw
*.dsp
# Visual Studio 6 technical files
*.ncb
*.aps
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
@ -362,9 +350,6 @@ ASALocalRun/
# Local History for Visual Studio
.localhistory/
# Visual Studio History (VSHistory) files
.vshistory/
# BeatPulse healthcheck temp database
healthchecksdb
@ -376,25 +361,3 @@ MigrationBackup/
# Fody - auto-generated XML schema
FodyWeavers.xsd
# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp
# JetBrains Rider
*.sln.iml

49
CarRent.sln Normal file
View File

@ -0,0 +1,49 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33205.214
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CarRentDataModels", "CarRentDataModels\CarRentDataModels.csproj", "{13406975-DD8C-416F-BCF7-A86C3FA9F019}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CarRentContracts", "CarRentContracts\CarRentContracts.csproj", "{442821E8-C13E-4FC8-92FB-43F59BCD60B2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CarRentBusinessLogic", "CarRentBusinessLogic\CarRentBusinessLogic.csproj", "{BE1510F5-BC13-45DF-AD5E-09D22D29F316}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CarRentDatabase", "CarRentDatabase\CarRentDatabase.csproj", "{01667A54-719D-414B-B05F-1B3693971136}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CarRent", "CarRent\CarRent.csproj", "{19934FD6-266C-4824-8FC8-4895095C3EDF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{13406975-DD8C-416F-BCF7-A86C3FA9F019}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{13406975-DD8C-416F-BCF7-A86C3FA9F019}.Debug|Any CPU.Build.0 = Debug|Any CPU
{13406975-DD8C-416F-BCF7-A86C3FA9F019}.Release|Any CPU.ActiveCfg = Release|Any CPU
{13406975-DD8C-416F-BCF7-A86C3FA9F019}.Release|Any CPU.Build.0 = Release|Any CPU
{442821E8-C13E-4FC8-92FB-43F59BCD60B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{442821E8-C13E-4FC8-92FB-43F59BCD60B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{442821E8-C13E-4FC8-92FB-43F59BCD60B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{442821E8-C13E-4FC8-92FB-43F59BCD60B2}.Release|Any CPU.Build.0 = Release|Any CPU
{BE1510F5-BC13-45DF-AD5E-09D22D29F316}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BE1510F5-BC13-45DF-AD5E-09D22D29F316}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BE1510F5-BC13-45DF-AD5E-09D22D29F316}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BE1510F5-BC13-45DF-AD5E-09D22D29F316}.Release|Any CPU.Build.0 = Release|Any CPU
{01667A54-719D-414B-B05F-1B3693971136}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{01667A54-719D-414B-B05F-1B3693971136}.Debug|Any CPU.Build.0 = Debug|Any CPU
{01667A54-719D-414B-B05F-1B3693971136}.Release|Any CPU.ActiveCfg = Release|Any CPU
{01667A54-719D-414B-B05F-1B3693971136}.Release|Any CPU.Build.0 = Release|Any CPU
{19934FD6-266C-4824-8FC8-4895095C3EDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{19934FD6-266C-4824-8FC8-4895095C3EDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{19934FD6-266C-4824-8FC8-4895095C3EDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{19934FD6-266C-4824-8FC8-4895095C3EDF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AE678595-7C9E-4E34-8C48-0D6CF953DBAC}
EndGlobalSection
EndGlobal

25
CarRent/CarRent.csproj Normal file
View 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.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CarRentBusinessLogic\CarRentBusinessLogic.csproj" />
<ProjectReference Include="..\CarRentContracts\CarRentContracts.csproj" />
<ProjectReference Include="..\CarRentDatabase\CarRentDatabase.csproj" />
</ItemGroup>
</Project>

127
CarRent/FormAddReview.Designer.cs generated Normal file
View File

@ -0,0 +1,127 @@
namespace CarRent
{
partial class FormAddReview
{
/// <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.label1 = new System.Windows.Forms.Label();
this.textBoxReviewText = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.numericUpDown = new System.Windows.Forms.NumericUpDown();
this.buttonAddReview = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown)).BeginInit();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(83, 15);
this.label1.TabIndex = 0;
this.label1.Text = "Новый отзыв:";
//
// textBoxReviewText
//
this.textBoxReviewText.Location = new System.Drawing.Point(12, 27);
this.textBoxReviewText.Multiline = true;
this.textBoxReviewText.Name = "textBoxReviewText";
this.textBoxReviewText.Size = new System.Drawing.Size(157, 116);
this.textBoxReviewText.TabIndex = 1;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 146);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(76, 15);
this.label2.TabIndex = 2;
this.label2.Text = "Оценка(1-5):";
//
// numericUpDown
//
this.numericUpDown.Location = new System.Drawing.Point(12, 164);
this.numericUpDown.Name = "numericUpDown";
this.numericUpDown.Size = new System.Drawing.Size(157, 23);
this.numericUpDown.TabIndex = 3;
this.numericUpDown.Value = new decimal(new int[] {
5,
0,
0,
0});
//
// buttonAddReview
//
this.buttonAddReview.Location = new System.Drawing.Point(12, 193);
this.buttonAddReview.Name = "buttonAddReview";
this.buttonAddReview.Size = new System.Drawing.Size(75, 23);
this.buttonAddReview.TabIndex = 4;
this.buttonAddReview.Text = "Добавить";
this.buttonAddReview.UseVisualStyleBackColor = true;
this.buttonAddReview.Click += new System.EventHandler(this.buttonAddReview_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(94, 193);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 5;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// FormAddReview
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(179, 226);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonAddReview);
this.Controls.Add(this.numericUpDown);
this.Controls.Add(this.label2);
this.Controls.Add(this.textBoxReviewText);
this.Controls.Add(this.label1);
this.Name = "FormAddReview";
this.Text = "Новый отзыв";
this.Load += new System.EventHandler(this.FormAddReview_Load);
((System.ComponentModel.ISupportInitialize)(this.numericUpDown)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Label label1;
private TextBox textBoxReviewText;
private Label label2;
private NumericUpDown numericUpDown;
private Button buttonAddReview;
private Button buttonCancel;
}
}

99
CarRent/FormAddReview.cs Normal file
View File

@ -0,0 +1,99 @@
using CarRentBusinessLogic.BusinessLogics;
using CarRentContracts.BindingModels;
using CarRentContracts.BusinessLogicContracts;
using CarRentContracts.SearchModels;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CarRent
{
public partial class FormAddReview : Form
{
private readonly IRentalLogic _rentalLogic;
private int? _id;
public int Id { set { _id = value; } }
public FormAddReview(IRentalLogic rentalLogic)
{
InitializeComponent();
_rentalLogic = rentalLogic;
numericUpDown.Value = 5;
numericUpDown.Maximum = 5;
numericUpDown.Minimum = 1;
}
private void FormAddReview_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
try
{
var view = _rentalLogic.ReadElement(new RentalSearchModel { Id = _id.Value });
if (view != null && (view.ReviewRating >= 1 || view.ReviewRating <= 5))
{
textBoxReviewText.Text = view.ReviewText;
numericUpDown.Value = Convert.ToDecimal(view.ReviewRating);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void buttonAddReview_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxReviewText.Text))
{
MessageBox.Show("Введите текст отзыва", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (numericUpDown.Value < 1 || numericUpDown.Value > 5)
{
MessageBox.Show("Укажите корректную оценку", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
try
{
var model = new RentalBindingModel
{
Id = _id ?? 0,
ReviewRating = Convert.ToInt32(numericUpDown.Value),
ReviewText = textBoxReviewText.Text,
};
var operationResult = _id.HasValue && _id != 0 ? _rentalLogic.Update(model) : throw new Exception("Проблема с отзывом к аренде");
if (!operationResult)
{
throw new Exception("Ошибка при сохранеии.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<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>

115
CarRent/FormBranches.Designer.cs generated Normal file
View File

@ -0,0 +1,115 @@
namespace CarRent
{
partial class FormBranches
{
/// <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.buttonUpdate = new System.Windows.Forms.Button();
this.buttonDelete = new System.Windows.Forms.Button();
this.buttonChange = new System.Windows.Forms.Button();
this.buttonAdd = new System.Windows.Forms.Button();
this.dataGridView = new System.Windows.Forms.DataGridView();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// buttonUpdate
//
this.buttonUpdate.Location = new System.Drawing.Point(592, 99);
this.buttonUpdate.Name = "buttonUpdate";
this.buttonUpdate.Size = new System.Drawing.Size(75, 23);
this.buttonUpdate.TabIndex = 9;
this.buttonUpdate.Text = "Обновить";
this.buttonUpdate.UseVisualStyleBackColor = true;
this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
//
// buttonDelete
//
this.buttonDelete.Location = new System.Drawing.Point(592, 70);
this.buttonDelete.Name = "buttonDelete";
this.buttonDelete.Size = new System.Drawing.Size(75, 23);
this.buttonDelete.TabIndex = 8;
this.buttonDelete.Text = "Удалить";
this.buttonDelete.UseVisualStyleBackColor = true;
this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click);
//
// buttonChange
//
this.buttonChange.Location = new System.Drawing.Point(592, 41);
this.buttonChange.Name = "buttonChange";
this.buttonChange.Size = new System.Drawing.Size(75, 23);
this.buttonChange.TabIndex = 7;
this.buttonChange.Text = "Изменить";
this.buttonChange.UseVisualStyleBackColor = true;
this.buttonChange.Click += new System.EventHandler(this.buttonChange_Click);
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(592, 12);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(75, 23);
this.buttonAdd.TabIndex = 6;
this.buttonAdd.Text = "Создать";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
//
// dataGridView
//
this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Location = new System.Drawing.Point(12, 12);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowTemplate.Height = 25;
this.dataGridView.Size = new System.Drawing.Size(574, 426);
this.dataGridView.TabIndex = 5;
//
// FormBranches
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(674, 450);
this.Controls.Add(this.buttonUpdate);
this.Controls.Add(this.buttonDelete);
this.Controls.Add(this.buttonChange);
this.Controls.Add(this.buttonAdd);
this.Controls.Add(this.dataGridView);
this.Name = "FormBranches";
this.Text = "Список филиалов";
this.Load += new System.EventHandler(this.FormBranches_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private Button buttonUpdate;
private Button buttonDelete;
private Button buttonChange;
private Button buttonAdd;
private DataGridView dataGridView;
}
}

111
CarRent/FormBranches.cs Normal file
View File

@ -0,0 +1,111 @@
using CarRentBusinessLogic.BusinessLogics;
using CarRentContracts.BindingModels;
using CarRentContracts.BusinessLogicContracts;
using ClientRentBusinessLogic.BusinessLogics;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CarRent
{
public partial class FormBranches : Form
{
private readonly IBranchLogic _branchLogic;
public FormBranches(IBranchLogic branchLogic)
{
InitializeComponent();
_branchLogic = branchLogic;
}
private void LoadData()
{
try
{
var list = _branchLogic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
}
}
catch (Exception ex)
{ }
}
private void FormBranches_Load(object sender, EventArgs e)
{
LoadData();
}
private void buttonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateBranch));
if (service is FormCreateBranch form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void buttonChange_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateBranch));
if (service is FormCreateBranch form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void buttonDelete_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
try
{
if (!_branchLogic.Delete(new BranchBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении.");
}
LoadData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void buttonUpdate_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

60
CarRent/FormBranches.resx Normal file
View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

114
CarRent/FormCars.Designer.cs generated Normal file
View File

@ -0,0 +1,114 @@
namespace CarRent
{
partial class FormCars
{
/// <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.buttonUpdate = new System.Windows.Forms.Button();
this.buttonDelete = new System.Windows.Forms.Button();
this.buttonChange = new System.Windows.Forms.Button();
this.buttonAdd = new System.Windows.Forms.Button();
this.dataGridView = new System.Windows.Forms.DataGridView();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// buttonUpdate
//
this.buttonUpdate.Location = new System.Drawing.Point(592, 99);
this.buttonUpdate.Name = "buttonUpdate";
this.buttonUpdate.Size = new System.Drawing.Size(75, 23);
this.buttonUpdate.TabIndex = 9;
this.buttonUpdate.Text = "Обновить";
this.buttonUpdate.UseVisualStyleBackColor = true;
this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
//
// buttonDelete
//
this.buttonDelete.Location = new System.Drawing.Point(592, 70);
this.buttonDelete.Name = "buttonDelete";
this.buttonDelete.Size = new System.Drawing.Size(75, 23);
this.buttonDelete.TabIndex = 8;
this.buttonDelete.Text = "Удалить";
this.buttonDelete.UseVisualStyleBackColor = true;
this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click);
//
// buttonChange
//
this.buttonChange.Location = new System.Drawing.Point(592, 41);
this.buttonChange.Name = "buttonChange";
this.buttonChange.Size = new System.Drawing.Size(75, 23);
this.buttonChange.TabIndex = 7;
this.buttonChange.Text = "Изменить";
this.buttonChange.UseVisualStyleBackColor = true;
this.buttonChange.Click += new System.EventHandler(this.buttonChange_Click);
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(592, 12);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(75, 23);
this.buttonAdd.TabIndex = 6;
this.buttonAdd.Text = "Создать";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
//
// dataGridView
//
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Location = new System.Drawing.Point(12, 12);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowTemplate.Height = 25;
this.dataGridView.Size = new System.Drawing.Size(574, 426);
this.dataGridView.TabIndex = 5;
//
// FormCars
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(676, 450);
this.Controls.Add(this.buttonUpdate);
this.Controls.Add(this.buttonDelete);
this.Controls.Add(this.buttonChange);
this.Controls.Add(this.buttonAdd);
this.Controls.Add(this.dataGridView);
this.Name = "FormCars";
this.Text = "Список автомобилей";
this.Load += new System.EventHandler(this.FormCars_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private Button buttonUpdate;
private Button buttonDelete;
private Button buttonChange;
private Button buttonAdd;
private DataGridView dataGridView;
}
}

111
CarRent/FormCars.cs Normal file
View File

@ -0,0 +1,111 @@
using CarRentBusinessLogic.BusinessLogics;
using CarRentContracts.BindingModels;
using CarRentContracts.BusinessLogicContracts;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CarRent
{
public partial class FormCars : Form
{
ICarLogic _carLogic;
public FormCars(ICarLogic carLogic)
{
InitializeComponent();
_carLogic = carLogic;
}
private void LoadData()
{
try
{
var list = _carLogic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["BranchId"].Visible = false;
}
}
catch (Exception ex)
{ }
}
private void buttonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateCar));
if (service is FormCreateCar form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void buttonChange_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateCar));
if (service is FormCreateCar form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void buttonDelete_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
try
{
if (!_carLogic.Delete(new CarBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении.");
}
LoadData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void buttonUpdate_Click(object sender, EventArgs e)
{
LoadData();
}
private void FormCars_Load(object sender, EventArgs e)
{
LoadData();
}
}
}

60
CarRent/FormCars.resx Normal file
View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

114
CarRent/FormClients.Designer.cs generated Normal file
View File

@ -0,0 +1,114 @@
namespace CarRent
{
partial class FormClients
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dataGridView = new System.Windows.Forms.DataGridView();
this.buttonAdd = new System.Windows.Forms.Button();
this.buttonChange = new System.Windows.Forms.Button();
this.buttonDelete = new System.Windows.Forms.Button();
this.buttonUpdate = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// dataGridView
//
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Location = new System.Drawing.Point(12, 12);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowTemplate.Height = 25;
this.dataGridView.Size = new System.Drawing.Size(574, 426);
this.dataGridView.TabIndex = 0;
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(592, 12);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(75, 23);
this.buttonAdd.TabIndex = 1;
this.buttonAdd.Text = "Создать";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
//
// buttonChange
//
this.buttonChange.Location = new System.Drawing.Point(592, 41);
this.buttonChange.Name = "buttonChange";
this.buttonChange.Size = new System.Drawing.Size(75, 23);
this.buttonChange.TabIndex = 2;
this.buttonChange.Text = "Изменить";
this.buttonChange.UseVisualStyleBackColor = true;
this.buttonChange.Click += new System.EventHandler(this.buttonChange_Click);
//
// buttonDelete
//
this.buttonDelete.Location = new System.Drawing.Point(592, 70);
this.buttonDelete.Name = "buttonDelete";
this.buttonDelete.Size = new System.Drawing.Size(75, 23);
this.buttonDelete.TabIndex = 3;
this.buttonDelete.Text = "Удалить";
this.buttonDelete.UseVisualStyleBackColor = true;
this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click);
//
// buttonUpdate
//
this.buttonUpdate.Location = new System.Drawing.Point(592, 99);
this.buttonUpdate.Name = "buttonUpdate";
this.buttonUpdate.Size = new System.Drawing.Size(75, 23);
this.buttonUpdate.TabIndex = 4;
this.buttonUpdate.Text = "Обновить";
this.buttonUpdate.UseVisualStyleBackColor = true;
this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
//
// FormClients
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(681, 450);
this.Controls.Add(this.buttonUpdate);
this.Controls.Add(this.buttonDelete);
this.Controls.Add(this.buttonChange);
this.Controls.Add(this.buttonAdd);
this.Controls.Add(this.dataGridView);
this.Name = "FormClients";
this.Text = "Список клиентов";
this.Load += new System.EventHandler(this.FormClients_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Button buttonAdd;
private Button buttonChange;
private Button buttonDelete;
private Button buttonUpdate;
}
}

110
CarRent/FormClients.cs Normal file
View File

@ -0,0 +1,110 @@
using CarRentBusinessLogic.BusinessLogics;
using CarRentContracts.BindingModels;
using CarRentContracts.BusinessLogicContracts;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CarRent
{
public partial class FormClients : Form
{
private readonly IClientLogic _clientLogic;
public FormClients(IClientLogic clientLogic)
{
InitializeComponent();
_clientLogic = clientLogic;
}
private void LoadData()
{
try
{
var list = _clientLogic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
}
}
catch (Exception ex)
{ }
}
private void FormClients_Load(object sender, EventArgs e)
{
LoadData();
}
private void buttonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateClient));
if (service is FormCreateClient form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void buttonChange_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateClient));
if (service is FormCreateClient form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void buttonDelete_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
try
{
if (!_clientLogic.Delete(new ClientBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении.");
}
LoadData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void buttonUpdate_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

60
CarRent/FormClients.resx Normal file
View File

@ -0,0 +1,60 @@
<root>
<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>

156
CarRent/FormCreateBranch.Designer.cs generated Normal file
View File

@ -0,0 +1,156 @@
namespace CarRent
{
partial class FormCreateBranch
{
/// <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.textBoxPhoneNumber = new System.Windows.Forms.TextBox();
this.textBoxAddress = new System.Windows.Forms.TextBox();
this.textBoxName = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonAdd = new System.Windows.Forms.Button();
this.buttonTestAdd = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// textBoxPhoneNumber
//
this.textBoxPhoneNumber.Location = new System.Drawing.Point(12, 115);
this.textBoxPhoneNumber.Name = "textBoxPhoneNumber";
this.textBoxPhoneNumber.Size = new System.Drawing.Size(145, 23);
this.textBoxPhoneNumber.TabIndex = 25;
//
// textBoxAddress
//
this.textBoxAddress.Location = new System.Drawing.Point(12, 71);
this.textBoxAddress.Name = "textBoxAddress";
this.textBoxAddress.Size = new System.Drawing.Size(145, 23);
this.textBoxAddress.TabIndex = 24;
//
// textBoxName
//
this.textBoxName.Location = new System.Drawing.Point(12, 27);
this.textBoxName.Name = "textBoxName";
this.textBoxName.Size = new System.Drawing.Size(145, 23);
this.textBoxName.TabIndex = 23;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(12, 97);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(104, 15);
this.label3.TabIndex = 22;
this.label3.Text = "Номер телефона:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 53);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(43, 15);
this.label2.TabIndex = 21;
this.label2.Text = "Адрес:";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(62, 15);
this.label1.TabIndex = 20;
this.label1.Text = "Название:";
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(176, 114);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 27;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(176, 71);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(75, 23);
this.buttonAdd.TabIndex = 26;
this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
//
// buttonTestAdd
//
this.buttonTestAdd.Location = new System.Drawing.Point(176, 11);
this.buttonTestAdd.Name = "buttonTestAdd";
this.buttonTestAdd.Size = new System.Drawing.Size(75, 54);
this.buttonTestAdd.TabIndex = 28;
this.buttonTestAdd.Text = "Добавить 1000 филиалов";
this.buttonTestAdd.UseVisualStyleBackColor = true;
this.buttonTestAdd.Click += new System.EventHandler(this.buttonTestAdd_Click);
//
// FormCreateBranch
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(263, 155);
this.Controls.Add(this.buttonTestAdd);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonAdd);
this.Controls.Add(this.textBoxPhoneNumber);
this.Controls.Add(this.textBoxAddress);
this.Controls.Add(this.textBoxName);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FormCreateBranch";
this.Text = "Добавление филиала";
this.Load += new System.EventHandler(this.FormCreateBranch_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private TextBox textBoxPhoneNumber;
private TextBox textBoxAddress;
private TextBox textBoxName;
private Label label3;
private Label label2;
private Label label1;
private Button buttonCancel;
private Button buttonAdd;
private Button buttonTestAdd;
}
}

116
CarRent/FormCreateBranch.cs Normal file
View File

@ -0,0 +1,116 @@
using CarRentBusinessLogic.BusinessLogics;
using CarRentContracts.BindingModels;
using CarRentContracts.BusinessLogicContracts;
using CarRentContracts.SearchModels;
using ClientRentBusinessLogic.BusinessLogics;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CarRent
{
public partial class FormCreateBranch : Form
{
private readonly IBranchLogic _branchLogic;
private int? _id;
public int Id { set { _id = value; } }
public FormCreateBranch(IBranchLogic branchLogic)
{
InitializeComponent();
_branchLogic = branchLogic;
}
private void buttonAdd_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxName.Text))
{
MessageBox.Show("Введите название филиала", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(textBoxPhoneNumber.Text))
{
MessageBox.Show("Введите номер телефона филиала", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(textBoxAddress.Text))
{
MessageBox.Show("Введите адрес филиала", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
try
{
var model = new BranchBindingModel
{
Id = _id ?? 0,
Name = textBoxName.Text,
PhoneNumber = textBoxPhoneNumber.Text,
Address = textBoxAddress.Text,
};
var operationResult = _id.HasValue ? _branchLogic.Update(model) : _branchLogic.Create(model);
if (!operationResult)
{
throw new Exception("Ошибка при сохранеии.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void FormCreateBranch_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
try
{
var view = _branchLogic.ReadElement(new BranchSearchModel { Id = _id.Value });
if (view != null)
{
textBoxName.Text = view.Name;
textBoxPhoneNumber.Text = view.PhoneNumber;
textBoxAddress.Text = view.Address;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void buttonTestAdd_Click(object sender, EventArgs e)
{
try
{
_branchLogic.BranchInsertList(1000);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<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>

243
CarRent/FormCreateCar.Designer.cs generated Normal file
View File

@ -0,0 +1,243 @@
namespace CarRent
{
partial class FormCreateCar
{
/// <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.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.textBoxBrand = new System.Windows.Forms.TextBox();
this.textBoxModel = new System.Windows.Forms.TextBox();
this.textBoxColor = new System.Windows.Forms.TextBox();
this.textBoxLicensePlate = new System.Windows.Forms.TextBox();
this.textBoxRentalCost = new System.Windows.Forms.TextBox();
this.comboBoxBranch = new System.Windows.Forms.ComboBox();
this.buttonAdd = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.dateTimePicker = new System.Windows.Forms.DateTimePicker();
this.buttonTestAdd = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(95, 15);
this.label1.TabIndex = 0;
this.label1.Text = "Производитель:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 53);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(53, 15);
this.label2.TabIndex = 1;
this.label2.Text = "Модель:";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(12, 97);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(78, 15);
this.label3.TabIndex = 2;
this.label3.Text = "Год выпуска:";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(12, 141);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(36, 15);
this.label4.TabIndex = 3;
this.label4.Text = "Цвет:";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(12, 185);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(48, 15);
this.label5.TabIndex = 4;
this.label5.Text = "Номер:";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(12, 229);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(145, 15);
this.label6.TabIndex = 5;
this.label6.Text = "Стоимость аренды в час:";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(12, 273);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(53, 15);
this.label7.TabIndex = 6;
this.label7.Text = "Филиал:";
//
// textBoxBrand
//
this.textBoxBrand.Location = new System.Drawing.Point(12, 27);
this.textBoxBrand.Name = "textBoxBrand";
this.textBoxBrand.Size = new System.Drawing.Size(145, 23);
this.textBoxBrand.TabIndex = 7;
//
// textBoxModel
//
this.textBoxModel.Location = new System.Drawing.Point(12, 71);
this.textBoxModel.Name = "textBoxModel";
this.textBoxModel.Size = new System.Drawing.Size(145, 23);
this.textBoxModel.TabIndex = 8;
//
// textBoxColor
//
this.textBoxColor.Location = new System.Drawing.Point(12, 159);
this.textBoxColor.Name = "textBoxColor";
this.textBoxColor.Size = new System.Drawing.Size(145, 23);
this.textBoxColor.TabIndex = 10;
//
// textBoxLicensePlate
//
this.textBoxLicensePlate.Location = new System.Drawing.Point(12, 203);
this.textBoxLicensePlate.Name = "textBoxLicensePlate";
this.textBoxLicensePlate.Size = new System.Drawing.Size(145, 23);
this.textBoxLicensePlate.TabIndex = 11;
//
// textBoxRentalCost
//
this.textBoxRentalCost.Location = new System.Drawing.Point(12, 247);
this.textBoxRentalCost.Name = "textBoxRentalCost";
this.textBoxRentalCost.Size = new System.Drawing.Size(145, 23);
this.textBoxRentalCost.TabIndex = 12;
//
// comboBoxBranch
//
this.comboBoxBranch.FormattingEnabled = true;
this.comboBoxBranch.Location = new System.Drawing.Point(12, 291);
this.comboBoxBranch.Name = "comboBoxBranch";
this.comboBoxBranch.Size = new System.Drawing.Size(145, 23);
this.comboBoxBranch.TabIndex = 13;
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(180, 247);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(75, 23);
this.buttonAdd.TabIndex = 14;
this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(180, 290);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 15;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// dateTimePicker
//
this.dateTimePicker.Location = new System.Drawing.Point(12, 115);
this.dateTimePicker.Name = "dateTimePicker";
this.dateTimePicker.Size = new System.Drawing.Size(145, 23);
this.dateTimePicker.TabIndex = 16;
//
// buttonTestAdd
//
this.buttonTestAdd.Location = new System.Drawing.Point(180, 185);
this.buttonTestAdd.Name = "buttonTestAdd";
this.buttonTestAdd.Size = new System.Drawing.Size(75, 54);
this.buttonTestAdd.TabIndex = 29;
this.buttonTestAdd.Text = "Добавить 1000 машин";
this.buttonTestAdd.UseVisualStyleBackColor = true;
this.buttonTestAdd.Click += new System.EventHandler(this.buttonTestAdd_Click);
//
// FormCreateCar
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(267, 323);
this.Controls.Add(this.buttonTestAdd);
this.Controls.Add(this.dateTimePicker);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonAdd);
this.Controls.Add(this.comboBoxBranch);
this.Controls.Add(this.textBoxRentalCost);
this.Controls.Add(this.textBoxLicensePlate);
this.Controls.Add(this.textBoxColor);
this.Controls.Add(this.textBoxModel);
this.Controls.Add(this.textBoxBrand);
this.Controls.Add(this.label7);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "FormCreateCar";
this.Text = "Добавление автомобиля";
this.Load += new System.EventHandler(this.FormCreateCar_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Label label1;
private Label label2;
private Label label3;
private Label label4;
private Label label5;
private Label label6;
private Label label7;
private TextBox textBoxBrand;
private TextBox textBoxModel;
private TextBox textBoxColor;
private TextBox textBoxLicensePlate;
private TextBox textBoxRentalCost;
private ComboBox comboBoxBranch;
private Button buttonAdd;
private Button buttonCancel;
private DateTimePicker dateTimePicker;
private Button buttonTestAdd;
}
}

158
CarRent/FormCreateCar.cs Normal file
View File

@ -0,0 +1,158 @@
using CarRentBusinessLogic.BusinessLogics;
using CarRentContracts.BindingModels;
using CarRentContracts.BusinessLogicContracts;
using CarRentContracts.SearchModels;
using ClientRentBusinessLogic.BusinessLogics;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CarRent
{
public partial class FormCreateCar : Form
{
private readonly ICarLogic _carLogic;
private readonly IBranchLogic _branchLogic;
private int? _id;
public int Id { set { _id = value; } }
public FormCreateCar(ICarLogic carLogic,
IBranchLogic branchLogic)
{
InitializeComponent();
_carLogic = carLogic;
_branchLogic = branchLogic;
}
private void LoadData()
{
try
{
var list = _branchLogic.ReadList(null);
if (list != null)
{
comboBoxBranch.DisplayMember = "Name";
comboBoxBranch.ValueMember = "Id";
comboBoxBranch.DataSource = list;
comboBoxBranch.SelectedItem = null;
}
}
catch (Exception ex)
{ }
}
private void buttonAdd_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxBrand.Text))
{
MessageBox.Show("Введите производителя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(textBoxColor.Text))
{
MessageBox.Show("Введите цвет автомобиля", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(textBoxLicensePlate.Text))
{
MessageBox.Show("Введите номер автомобиля", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(textBoxModel.Text))
{
MessageBox.Show("Введите модель автомобиля", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(textBoxRentalCost.Text))
{
MessageBox.Show("Введите стоимость часовой аренды автомобиля", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(comboBoxBranch.Text))
{
MessageBox.Show("Выберите филиал, в котором находится автомобиль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
try
{
var model = new CarBindingModel
{
Id = _id ?? 0,
Brand = textBoxBrand.Text,
Model = textBoxModel.Text,
YearOfManuf = DateTime.SpecifyKind(dateTimePicker.Value, DateTimeKind.Utc),
Color = textBoxColor.Text,
LicensePlate = textBoxLicensePlate.Text,
RentalCostPerHour = Convert.ToDouble(textBoxRentalCost.Text),
BranchId = Convert.ToInt32(comboBoxBranch.SelectedValue),
};
var operationResult = _id.HasValue ? _carLogic.Update(model) : _carLogic.Create(model);
if (!operationResult)
{
throw new Exception("Ошибка при сохранеии.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void FormCreateCar_Load(object sender, EventArgs e)
{
LoadData();
if (_id.HasValue)
{
try
{
var view = _carLogic.ReadElement(new CarSearchModel { Id = _id.Value });
if (view != null)
{
textBoxBrand.Text = view.Brand;
textBoxColor.Text = view.Color;
textBoxLicensePlate.Text = view.LicensePlate;
textBoxModel.Text = view.Model;
textBoxRentalCost.Text = view.RentalCostPerHour.ToString();
dateTimePicker.Value = view.YearOfManuf;
comboBoxBranch.SelectedIndex = view.BranchId;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void buttonTestAdd_Click(object sender, EventArgs e)
{
try
{
_carLogic.CarInsertList(1000, _branchLogic.ReadList(null));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<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>

199
CarRent/FormCreateClient.Designer.cs generated Normal file
View File

@ -0,0 +1,199 @@
namespace CarRent
{
partial class FormCreateClient
{
/// <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.textBoxDriveLicense = new System.Windows.Forms.TextBox();
this.textBoxEmail = new System.Windows.Forms.TextBox();
this.textBoxPhoneNumber = new System.Windows.Forms.TextBox();
this.textBoxSurname = new System.Windows.Forms.TextBox();
this.textBoxName = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonAdd = new System.Windows.Forms.Button();
this.buttonTestAdd = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// textBoxDriveLicense
//
this.textBoxDriveLicense.Location = new System.Drawing.Point(12, 203);
this.textBoxDriveLicense.Name = "textBoxDriveLicense";
this.textBoxDriveLicense.Size = new System.Drawing.Size(145, 23);
this.textBoxDriveLicense.TabIndex = 21;
//
// textBoxEmail
//
this.textBoxEmail.Location = new System.Drawing.Point(12, 159);
this.textBoxEmail.Name = "textBoxEmail";
this.textBoxEmail.Size = new System.Drawing.Size(145, 23);
this.textBoxEmail.TabIndex = 20;
//
// textBoxPhoneNumber
//
this.textBoxPhoneNumber.Location = new System.Drawing.Point(12, 115);
this.textBoxPhoneNumber.Name = "textBoxPhoneNumber";
this.textBoxPhoneNumber.Size = new System.Drawing.Size(145, 23);
this.textBoxPhoneNumber.TabIndex = 19;
//
// textBoxSurname
//
this.textBoxSurname.Location = new System.Drawing.Point(12, 71);
this.textBoxSurname.Name = "textBoxSurname";
this.textBoxSurname.Size = new System.Drawing.Size(145, 23);
this.textBoxSurname.TabIndex = 18;
//
// textBoxName
//
this.textBoxName.Location = new System.Drawing.Point(12, 27);
this.textBoxName.Name = "textBoxName";
this.textBoxName.Size = new System.Drawing.Size(145, 23);
this.textBoxName.TabIndex = 17;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(12, 185);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(121, 15);
this.label5.TabIndex = 16;
this.label5.Text = "Водительские права:";
this.label5.Click += new System.EventHandler(this.label5_Click);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(12, 141);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(44, 15);
this.label4.TabIndex = 15;
this.label4.Text = "E-mail:";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(12, 97);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(104, 15);
this.label3.TabIndex = 14;
this.label3.Text = "Номер телефона:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 53);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(61, 15);
this.label2.TabIndex = 13;
this.label2.Text = "Фамилия:";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(34, 15);
this.label1.TabIndex = 12;
this.label1.Text = "Имя:";
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(176, 201);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 23;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(176, 158);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(75, 23);
this.buttonAdd.TabIndex = 22;
this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
//
// buttonTestAdd
//
this.buttonTestAdd.Location = new System.Drawing.Point(176, 97);
this.buttonTestAdd.Name = "buttonTestAdd";
this.buttonTestAdd.Size = new System.Drawing.Size(75, 54);
this.buttonTestAdd.TabIndex = 30;
this.buttonTestAdd.Text = "Добавить 50 клиентов";
this.buttonTestAdd.UseVisualStyleBackColor = true;
this.buttonTestAdd.Click += new System.EventHandler(this.buttonTestAdd_Click);
//
// FormCreateClient
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(263, 237);
this.Controls.Add(this.buttonTestAdd);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonAdd);
this.Controls.Add(this.textBoxDriveLicense);
this.Controls.Add(this.textBoxEmail);
this.Controls.Add(this.textBoxPhoneNumber);
this.Controls.Add(this.textBoxSurname);
this.Controls.Add(this.textBoxName);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "FormCreateClient";
this.Text = "Добавление клиента";
this.Load += new System.EventHandler(this.FormCreateClient_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private TextBox textBoxDriveLicense;
private TextBox textBoxEmail;
private TextBox textBoxPhoneNumber;
private TextBox textBoxSurname;
private TextBox textBoxName;
private Label label5;
private Label label4;
private Label label3;
private Label label2;
private Label label1;
private Button buttonCancel;
private Button buttonAdd;
private Button buttonTestAdd;
}
}

134
CarRent/FormCreateClient.cs Normal file
View File

@ -0,0 +1,134 @@
using CarRentBusinessLogic.BusinessLogics;
using CarRentContracts.BindingModels;
using CarRentContracts.BusinessLogicContracts;
using CarRentContracts.SearchModels;
using Microsoft.EntityFrameworkCore.Metadata;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CarRent
{
public partial class FormCreateClient : Form
{
private readonly IClientLogic _clientLogic;
private int? _id;
public int Id { set { _id = value; } }
public FormCreateClient(IClientLogic clientLogic)
{
InitializeComponent();
_clientLogic = clientLogic;
}
private void label5_Click(object sender, EventArgs e)
{
}
private void buttonAdd_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxName.Text))
{
MessageBox.Show("Введите имя клиента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(textBoxPhoneNumber.Text))
{
MessageBox.Show("Введите номер телефона клиента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(textBoxSurname.Text))
{
MessageBox.Show("Введите фамилию клиента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(textBoxEmail.Text))
{
MessageBox.Show("Введите E-mail клиента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(textBoxDriveLicense.Text))
{
MessageBox.Show("Введите водительские права клиента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
try
{
var model = new ClientBindingModel
{
Id = _id ?? 0,
Name = textBoxName.Text,
PhoneNumber = textBoxPhoneNumber.Text,
Surname = textBoxSurname.Text,
Email = textBoxEmail.Text,
DriveLicenseNumber = textBoxDriveLicense.Text,
};
var operationResult = _id.HasValue ? _clientLogic.Update(model) : _clientLogic.Create(model);
if (!operationResult)
{
throw new Exception("Ошибка при сохранеии.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void FormCreateClient_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
try
{
var view = _clientLogic.ReadElement(new ClientSearchModel { Id = _id.Value });
if (view != null)
{
textBoxName.Text = view.Name;
textBoxPhoneNumber.Text = view.PhoneNumber;
textBoxEmail.Text = view.Email;
textBoxDriveLicense.Text = view.DriveLicenseNumber;
textBoxSurname.Text = view.Surname;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void buttonTestAdd_Click(object sender, EventArgs e)
{
try
{
_clientLogic.ClientInsertList(50);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<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>

191
CarRent/FormCreateRental.Designer.cs generated Normal file
View File

@ -0,0 +1,191 @@
namespace CarRent
{
partial class FormCreateRental
{
/// <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.comboBoxClient = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.comboBoxCar = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label();
this.dateTimePickerStart = new System.Windows.Forms.DateTimePicker();
this.dateTimePickerEnd = new System.Windows.Forms.DateTimePicker();
this.label4 = new System.Windows.Forms.Label();
this.textBoxCost = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonAdd = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// comboBoxClient
//
this.comboBoxClient.FormattingEnabled = true;
this.comboBoxClient.Location = new System.Drawing.Point(12, 27);
this.comboBoxClient.Name = "comboBoxClient";
this.comboBoxClient.Size = new System.Drawing.Size(121, 23);
this.comboBoxClient.TabIndex = 0;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(49, 15);
this.label1.TabIndex = 1;
this.label1.Text = "Клиент:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 53);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(79, 15);
this.label2.TabIndex = 3;
this.label2.Text = "Автомобиль:";
//
// comboBoxCar
//
this.comboBoxCar.FormattingEnabled = true;
this.comboBoxCar.Location = new System.Drawing.Point(12, 71);
this.comboBoxCar.Name = "comboBoxCar";
this.comboBoxCar.Size = new System.Drawing.Size(121, 23);
this.comboBoxCar.TabIndex = 2;
this.comboBoxCar.SelectedIndexChanged += new System.EventHandler(this.comboBoxCar_SelectedIndexChanged);
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(12, 97);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(121, 15);
this.label3.TabIndex = 5;
this.label3.Text = "Дата начала аренды:";
//
// dateTimePickerStart
//
this.dateTimePickerStart.Location = new System.Drawing.Point(12, 115);
this.dateTimePickerStart.Name = "dateTimePickerStart";
this.dateTimePickerStart.Size = new System.Drawing.Size(121, 23);
this.dateTimePickerStart.TabIndex = 6;
this.dateTimePickerStart.ValueChanged += new System.EventHandler(this.dateTimePickerStart_ValueChanged);
//
// dateTimePickerEnd
//
this.dateTimePickerEnd.Location = new System.Drawing.Point(12, 159);
this.dateTimePickerEnd.Name = "dateTimePickerEnd";
this.dateTimePickerEnd.Size = new System.Drawing.Size(121, 23);
this.dateTimePickerEnd.TabIndex = 8;
this.dateTimePickerEnd.ValueChanged += new System.EventHandler(this.dateTimePickerEnd_ValueChanged);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(12, 141);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(142, 15);
this.label4.TabIndex = 7;
this.label4.Text = "Дата окончания аренды:";
//
// textBoxCost
//
this.textBoxCost.Location = new System.Drawing.Point(12, 203);
this.textBoxCost.Name = "textBoxCost";
this.textBoxCost.ReadOnly = true;
this.textBoxCost.Size = new System.Drawing.Size(121, 23);
this.textBoxCost.TabIndex = 9;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(12, 185);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(107, 15);
this.label5.TabIndex = 10;
this.label5.Text = "Общая стоимость";
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(155, 202);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 25;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(155, 159);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(75, 23);
this.buttonAdd.TabIndex = 24;
this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
//
// FormCreateRental
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(240, 247);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonAdd);
this.Controls.Add(this.label5);
this.Controls.Add(this.textBoxCost);
this.Controls.Add(this.dateTimePickerEnd);
this.Controls.Add(this.label4);
this.Controls.Add(this.dateTimePickerStart);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.comboBoxCar);
this.Controls.Add(this.label1);
this.Controls.Add(this.comboBoxClient);
this.Name = "FormCreateRental";
this.Text = "Новая сделка";
this.Load += new System.EventHandler(this.FormCreateRental_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private ComboBox comboBoxClient;
private Label label1;
private Label label2;
private ComboBox comboBoxCar;
private Label label3;
private DateTimePicker dateTimePickerStart;
private DateTimePicker dateTimePickerEnd;
private Label label4;
private TextBox textBoxCost;
private Label label5;
private Button buttonCancel;
private Button buttonAdd;
}
}

169
CarRent/FormCreateRental.cs Normal file
View File

@ -0,0 +1,169 @@
using CarRentBusinessLogic.BusinessLogics;
using CarRentContracts.BindingModels;
using CarRentContracts.BusinessLogicContracts;
using CarRentContracts.SearchModels;
using CarRentContracts.ViewModels;
using CarRentDatabase.Models;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CarRent
{
public partial class FormCreateRental : Form
{
private readonly ICarLogic _carLogic;
private readonly IClientLogic _clientLogic;
private readonly IRentalLogic _rentalLogic;
private int? _id;
public int Id { set { _id = value; } }
public FormCreateRental(ICarLogic carLogic,
IClientLogic clientLogic,
IRentalLogic rentalLogic)
{
InitializeComponent();
_carLogic = carLogic;
_clientLogic = clientLogic;
_rentalLogic = rentalLogic;
dateTimePickerStart.Format = DateTimePickerFormat.Time;
dateTimePickerEnd.Format = DateTimePickerFormat.Time;
}
private void LoadData()
{
try
{
var listClients = _clientLogic.ReadList(null);
var listCars = _carLogic.ReadList(null);
if (listClients != null)
{
comboBoxClient.DisplayMember = "Name";
comboBoxClient.ValueMember = "Id";
comboBoxClient.DataSource = listClients;
comboBoxClient.SelectedItem = null;
}
if (listCars != null)
{
comboBoxCar.DisplayMember = "LicensePlate";
comboBoxCar.ValueMember = "Id";
comboBoxCar.DataSource = listCars;
comboBoxCar.SelectedItem = null;
}
}
catch (Exception ex)
{ }
}
private void buttonAdd_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(comboBoxCar.Text))
{
MessageBox.Show("Выберите автомобиль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(comboBoxClient.Text))
{
MessageBox.Show("Выберите клиента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (dateTimePickerStart.Value > dateTimePickerEnd.Value)
{
MessageBox.Show("Выберите корректную дату", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
try
{
var model = new RentalBindingModel
{
Id = _id ?? 0,
StartDate = DateTime.SpecifyKind(dateTimePickerStart.Value, DateTimeKind.Utc),
EndDate = DateTime.SpecifyKind(dateTimePickerEnd.Value, DateTimeKind.Utc),
RentalCost = Convert.ToInt32(Math.Round(Convert.ToDouble(textBoxCost.Text))),
ClientId = Convert.ToInt32(comboBoxClient.SelectedValue),
CarId = Convert.ToInt32(comboBoxCar.SelectedValue),
};
var operationResult = _id.HasValue ? _rentalLogic.Update(model) : _rentalLogic.Create(model);
if (!operationResult)
{
throw new Exception("Ошибка при сохранеии.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void FormCreateRental_Load(object sender, EventArgs e)
{
LoadData();
if (_id.HasValue)
{
try
{
var view = _rentalLogic.ReadElement(new RentalSearchModel { Id = _id.Value });
if (view != null)
{
comboBoxClient.SelectedValue = view.ClientId;
comboBoxCar.SelectedValue = view.CarId;
dateTimePickerStart.Value = view.StartDate;
dateTimePickerEnd.Value = view.EndDate ?? DateTime.Now;
textBoxCost.Text = Math.Round(view.RentalCost, 2).ToString();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void dateTimePickerStart_ValueChanged(object sender, EventArgs e)
{
if (dateTimePickerStart.Value > dateTimePickerEnd.Value) return;
var tempCar = comboBoxCar.SelectedItem;
textBoxCost.Text = Math.Round((dateTimePickerEnd.Value.
Subtract(dateTimePickerStart.Value).
TotalHours * ((CarViewModel)tempCar)?.RentalCostPerHour) ?? 0, 2).ToString();
}
private void dateTimePickerEnd_ValueChanged(object sender, EventArgs e)
{
if (dateTimePickerStart.Value > dateTimePickerEnd.Value) return;
var tempCar = comboBoxCar.SelectedItem;
textBoxCost.Text = Math.Round((dateTimePickerEnd.Value.
Subtract(dateTimePickerStart.Value).
TotalHours * ((CarViewModel)tempCar)?.RentalCostPerHour) ?? 0, 2).ToString();
}
private void comboBoxCar_SelectedIndexChanged(object sender, EventArgs e)
{
if (dateTimePickerStart.Value > dateTimePickerEnd.Value) return;
var tempCar = comboBoxCar.SelectedItem;
textBoxCost.Text = Math.Round((dateTimePickerEnd.Value.
Subtract(dateTimePickerStart.Value).
TotalHours * ((CarViewModel)tempCar)?.RentalCostPerHour) ?? 0, 2).ToString();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<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>

209
CarRent/FormRentals.Designer.cs generated Normal file
View File

@ -0,0 +1,209 @@
namespace CarRent
{
partial class FormRentals
{
/// <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.buttonUpdate = new System.Windows.Forms.Button();
this.buttonAdd = new System.Windows.Forms.Button();
this.dataGridView = new System.Windows.Forms.DataGridView();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.филиалыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.автомобилиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.тестыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.comboBoxClientsEmail = new System.Windows.Forms.ComboBox();
this.buttonAddReview = new System.Windows.Forms.Button();
this.buttonDelete = new System.Windows.Forms.Button();
this.buttonChange = new System.Windows.Forms.Button();
this.buttonAllClear = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// buttonUpdate
//
this.buttonUpdate.Location = new System.Drawing.Point(950, 91);
this.buttonUpdate.Name = "buttonUpdate";
this.buttonUpdate.Size = new System.Drawing.Size(75, 23);
this.buttonUpdate.TabIndex = 13;
this.buttonUpdate.Text = "Обновить";
this.buttonUpdate.UseVisualStyleBackColor = true;
this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(950, 62);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(75, 23);
this.buttonAdd.TabIndex = 12;
this.buttonAdd.Text = "Создать";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
//
// dataGridView
//
this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Location = new System.Drawing.Point(12, 33);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowTemplate.Height = 25;
this.dataGridView.Size = new System.Drawing.Size(912, 411);
this.dataGridView.TabIndex = 11;
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.филиалыToolStripMenuItem,
this.автомобилиToolStripMenuItem,
this.клиентыToolStripMenuItem,
this.тестыToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(1060, 24);
this.menuStrip1.TabIndex = 10;
this.menuStrip1.Text = "menuStrip1";
//
// филиалыToolStripMenuItem
//
this.филиалыToolStripMenuItem.Name = "филиалыToolStripMenuItem";
this.филиалыToolStripMenuItem.Size = new System.Drawing.Size(71, 20);
this.филиалыToolStripMenuItem.Text = "Филиалы";
this.филиалыToolStripMenuItem.Click += new System.EventHandler(this.филиалыToolStripMenuItem_Click);
//
// автомобилиToolStripMenuItem
//
this.автомобилиToolStripMenuItem.Name = "автомобилиToolStripMenuItem";
this.автомобилиToolStripMenuItem.Size = new System.Drawing.Size(89, 20);
this.автомобилиToolStripMenuItem.Text = "Автомобили";
this.автомобилиToolStripMenuItem.Click += new System.EventHandler(this.автомобилиToolStripMenuItem_Click);
//
// клиентыToolStripMenuItem
//
this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(67, 20);
this.клиентыToolStripMenuItem.Text = "Клиенты";
this.клиентыToolStripMenuItem.Click += new System.EventHandler(this.клиентыToolStripMenuItem_Click);
//
// тестыToolStripMenuItem
//
this.тестыToolStripMenuItem.Name = естыToolStripMenuItem";
this.тестыToolStripMenuItem.Size = new System.Drawing.Size(51, 20);
this.тестыToolStripMenuItem.Text = "Тесты";
this.тестыToolStripMenuItem.Click += new System.EventHandler(this.testsToolStripMenuItem_Click);
//
// comboBoxClientsEmail
//
this.comboBoxClientsEmail.FormattingEnabled = true;
this.comboBoxClientsEmail.Location = new System.Drawing.Point(930, 33);
this.comboBoxClientsEmail.Name = "comboBoxClientsEmail";
this.comboBoxClientsEmail.Size = new System.Drawing.Size(121, 23);
this.comboBoxClientsEmail.TabIndex = 14;
this.comboBoxClientsEmail.SelectedIndexChanged += new System.EventHandler(this.comboBoxClientsEmail_SelectedIndexChanged);
//
// buttonAddReview
//
this.buttonAddReview.Location = new System.Drawing.Point(950, 193);
this.buttonAddReview.Name = "buttonAddReview";
this.buttonAddReview.Size = new System.Drawing.Size(75, 44);
this.buttonAddReview.TabIndex = 15;
this.buttonAddReview.Text = "Добавить отзыв";
this.buttonAddReview.UseVisualStyleBackColor = true;
this.buttonAddReview.Click += new System.EventHandler(this.buttonAddReview_Click);
//
// buttonDelete
//
this.buttonDelete.Location = new System.Drawing.Point(950, 148);
this.buttonDelete.Name = "buttonDelete";
this.buttonDelete.Size = new System.Drawing.Size(75, 23);
this.buttonDelete.TabIndex = 16;
this.buttonDelete.Text = "Удалить";
this.buttonDelete.UseVisualStyleBackColor = true;
this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click);
//
// buttonChange
//
this.buttonChange.Location = new System.Drawing.Point(950, 119);
this.buttonChange.Name = "buttonChange";
this.buttonChange.Size = new System.Drawing.Size(75, 23);
this.buttonChange.TabIndex = 17;
this.buttonChange.Text = "Изменить";
this.buttonChange.UseVisualStyleBackColor = true;
this.buttonChange.Click += new System.EventHandler(this.buttonChange_Click);
//
// buttonAllClear
//
this.buttonAllClear.Location = new System.Drawing.Point(930, 400);
this.buttonAllClear.Name = "buttonAllClear";
this.buttonAllClear.Size = new System.Drawing.Size(121, 44);
this.buttonAllClear.TabIndex = 18;
this.buttonAllClear.Text = "Очистить все таблицы";
this.buttonAllClear.UseVisualStyleBackColor = true;
this.buttonAllClear.Click += new System.EventHandler(this.buttonAllClear_Click);
//
// FormRentals
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1060, 450);
this.Controls.Add(this.buttonAllClear);
this.Controls.Add(this.buttonChange);
this.Controls.Add(this.buttonDelete);
this.Controls.Add(this.buttonAddReview);
this.Controls.Add(this.comboBoxClientsEmail);
this.Controls.Add(this.buttonUpdate);
this.Controls.Add(this.buttonAdd);
this.Controls.Add(this.dataGridView);
this.Controls.Add(this.menuStrip1);
this.Name = "FormRentals";
this.Text = "Аренда автомобилей";
this.Load += new System.EventHandler(this.FormRentals_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Button buttonUpdate;
private Button buttonAdd;
private DataGridView dataGridView;
private MenuStrip menuStrip1;
private ToolStripMenuItem филиалыToolStripMenuItem;
private ToolStripMenuItem автомобилиToolStripMenuItem;
private ToolStripMenuItem клиентыToolStripMenuItem;
private ComboBox comboBoxClientsEmail;
private Button buttonAddReview;
private ToolStripMenuItem тестыToolStripMenuItem;
private Button buttonDelete;
private Button buttonChange;
private Button buttonAllClear;
}
}

217
CarRent/FormRentals.cs Normal file
View File

@ -0,0 +1,217 @@
using CarRentContracts.BindingModels;
using CarRentContracts.BusinessLogicContracts;
using CarRentContracts.SearchModels;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CarRent
{
public partial class FormRentals : Form
{
private readonly IRentalLogic _rentalLogic;
private readonly IClientLogic _clientLogic;
private readonly IBranchLogic _branchLogic;
private readonly ICarLogic _carLogic;
public FormRentals(IRentalLogic rentalLogic,
IClientLogic clientLogic,
IBranchLogic branchLogic,
ICarLogic carLogic)
{
InitializeComponent();
_rentalLogic = rentalLogic;
_clientLogic = clientLogic;
_branchLogic = branchLogic;
_carLogic = carLogic;
}
private void LoadData()
{
try
{
var list = _rentalLogic.ReadList(null);
var listClients = _clientLogic.ReadList(null);
if (listClients != null)
{
comboBoxClientsEmail.DisplayMember = "Email";
comboBoxClientsEmail.ValueMember = "Id";
comboBoxClientsEmail.DataSource = listClients;
comboBoxClientsEmail.SelectedItem = null;
}
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["ClientId"].Visible = false;
dataGridView.Columns["CarId"].Visible = false;
dataGridView.Columns["Id"].Visible = false;
}
}
catch (Exception ex)
{}
}
private void LoadData(int id)
{
var list = _rentalLogic.ReadList(new RentalSearchModel
{
ClientId = id,
});
dataGridView.DataSource = list;
dataGridView.Columns["ClientId"].Visible = false;
dataGridView.Columns["CarId"].Visible = false;
dataGridView.Columns["Id"].Visible = false;
}
private void филиалыToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormBranches));
if (service is FormBranches form)
{
form.ShowDialog();
LoadData();
}
}
private void автомобилиToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCars));
if (service is FormCars form)
{
form.ShowDialog();
LoadData();
}
}
private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
if (service is FormClients form)
{
form.ShowDialog();
LoadData();
}
}
private void buttonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateRental));
if (service is FormCreateRental form)
{
form.ShowDialog();
LoadData();
}
}
private void buttonUpdate_Click(object sender, EventArgs e)
{
LoadData();
}
private void FormRentals_Load(object sender, EventArgs e)
{
LoadData();
}
private void buttonAddReview_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormAddReview));
if (service is FormAddReview form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
form.ShowDialog();
LoadData();
}
}
}
private void testsToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormTests));
if (service is FormTests form)
{
form.ShowDialog();
LoadData();
}
}
private void comboBoxClientsEmail_SelectedIndexChanged(object sender, EventArgs e)
{
LoadData(Convert.ToInt32(comboBoxClientsEmail.SelectedValue));
}
private void buttonChange_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateRental));
if (service is FormCreateRental form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void buttonDelete_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
try
{
if (!_rentalLogic.Delete(new RentalBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении.");
}
LoadData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void buttonAllClear_Click(object sender, EventArgs e)
{
try
{
_clientLogic.ClearEntity();
_branchLogic.ClearEntity();
_carLogic.ClearEntity();
_rentalLogic.ClearEntity();
}
catch (Exception ex) { }
}
}
}

63
CarRent/FormRentals.resx Normal file
View File

@ -0,0 +1,63 @@
<root>
<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>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

228
CarRent/FormTests.Designer.cs generated Normal file
View File

@ -0,0 +1,228 @@
namespace CarRent
{
partial class FormTests
{
/// <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.buttonInsertTest = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.textBoxInsertTime = new System.Windows.Forms.TextBox();
this.buttonReadTest = new System.Windows.Forms.Button();
this.textBoxReadTime = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.numericUpDownInsert = new System.Windows.Forms.NumericUpDown();
this.numericUpDownRead = new System.Windows.Forms.NumericUpDown();
this.buttonJoinQuery = new System.Windows.Forms.Button();
this.numericUpDownJoin = new System.Windows.Forms.NumericUpDown();
this.textBoxJoin = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownInsert)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownRead)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownJoin)).BeginInit();
this.SuspendLayout();
//
// buttonInsertTest
//
this.buttonInsertTest.Location = new System.Drawing.Point(12, 12);
this.buttonInsertTest.Name = "buttonInsertTest";
this.buttonInsertTest.Size = new System.Drawing.Size(75, 56);
this.buttonInsertTest.TabIndex = 0;
this.buttonInsertTest.Text = "Тест вставки заказов";
this.buttonInsertTest.UseVisualStyleBackColor = true;
this.buttonInsertTest.Click += new System.EventHandler(this.buttonInsertTest_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(104, 12);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(156, 15);
this.label1.TabIndex = 1;
this.label1.Text = "Введите кол-во элементов:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(104, 53);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(146, 15);
this.label2.TabIndex = 3;
this.label2.Text = "Итоговое время запроса:";
//
// textBoxInsertTime
//
this.textBoxInsertTime.Location = new System.Drawing.Point(266, 50);
this.textBoxInsertTime.Name = "textBoxInsertTime";
this.textBoxInsertTime.ReadOnly = true;
this.textBoxInsertTime.Size = new System.Drawing.Size(100, 23);
this.textBoxInsertTime.TabIndex = 4;
//
// buttonReadTest
//
this.buttonReadTest.Location = new System.Drawing.Point(12, 106);
this.buttonReadTest.Name = "buttonReadTest";
this.buttonReadTest.Size = new System.Drawing.Size(75, 56);
this.buttonReadTest.TabIndex = 5;
this.buttonReadTest.Text = "Тест чтения заказов";
this.buttonReadTest.UseVisualStyleBackColor = true;
this.buttonReadTest.Click += new System.EventHandler(this.buttonReadTest_Click);
//
// textBoxReadTime
//
this.textBoxReadTime.Location = new System.Drawing.Point(266, 144);
this.textBoxReadTime.Name = "textBoxReadTime";
this.textBoxReadTime.ReadOnly = true;
this.textBoxReadTime.Size = new System.Drawing.Size(100, 23);
this.textBoxReadTime.TabIndex = 9;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(104, 147);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(146, 15);
this.label3.TabIndex = 8;
this.label3.Text = "Итоговое время запроса:";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(104, 106);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(156, 15);
this.label4.TabIndex = 6;
this.label4.Text = "Введите кол-во элементов:";
//
// numericUpDownInsert
//
this.numericUpDownInsert.Location = new System.Drawing.Point(266, 10);
this.numericUpDownInsert.Name = "numericUpDownInsert";
this.numericUpDownInsert.Size = new System.Drawing.Size(100, 23);
this.numericUpDownInsert.TabIndex = 10;
//
// numericUpDownRead
//
this.numericUpDownRead.Location = new System.Drawing.Point(266, 104);
this.numericUpDownRead.Name = "numericUpDownRead";
this.numericUpDownRead.Size = new System.Drawing.Size(100, 23);
this.numericUpDownRead.TabIndex = 11;
//
// buttonJoinQuery
//
this.buttonJoinQuery.Location = new System.Drawing.Point(12, 197);
this.buttonJoinQuery.Name = "buttonJoinQuery";
this.buttonJoinQuery.Size = new System.Drawing.Size(75, 74);
this.buttonJoinQuery.TabIndex = 12;
this.buttonJoinQuery.Text = "Тест сложного чтения (Join)";
this.buttonJoinQuery.UseVisualStyleBackColor = true;
this.buttonJoinQuery.Click += new System.EventHandler(this.buttonJoinQuery_Click);
//
// numericUpDownJoin
//
this.numericUpDownJoin.Location = new System.Drawing.Point(266, 195);
this.numericUpDownJoin.Name = "numericUpDownJoin";
this.numericUpDownJoin.Size = new System.Drawing.Size(100, 23);
this.numericUpDownJoin.TabIndex = 16;
//
// textBoxJoin
//
this.textBoxJoin.Location = new System.Drawing.Point(266, 235);
this.textBoxJoin.Name = "textBoxJoin";
this.textBoxJoin.ReadOnly = true;
this.textBoxJoin.Size = new System.Drawing.Size(100, 23);
this.textBoxJoin.TabIndex = 15;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(104, 238);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(146, 15);
this.label5.TabIndex = 14;
this.label5.Text = "Итоговое время запроса:";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(104, 197);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(156, 15);
this.label6.TabIndex = 13;
this.label6.Text = "Введите кол-во элементов:";
//
// FormTests
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(383, 286);
this.Controls.Add(this.numericUpDownJoin);
this.Controls.Add(this.textBoxJoin);
this.Controls.Add(this.label5);
this.Controls.Add(this.label6);
this.Controls.Add(this.buttonJoinQuery);
this.Controls.Add(this.numericUpDownRead);
this.Controls.Add(this.numericUpDownInsert);
this.Controls.Add(this.textBoxReadTime);
this.Controls.Add(this.label3);
this.Controls.Add(this.label4);
this.Controls.Add(this.buttonReadTest);
this.Controls.Add(this.textBoxInsertTime);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.buttonInsertTest);
this.Name = "FormTests";
this.Text = "Тесты запросов к бд";
((System.ComponentModel.ISupportInitialize)(this.numericUpDownInsert)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownRead)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownJoin)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Button buttonInsertTest;
private Label label1;
private Label label2;
private TextBox textBoxInsertTime;
private Button buttonReadTest;
private TextBox textBoxReadTime;
private Label label3;
private Label label4;
private NumericUpDown numericUpDownInsert;
private NumericUpDown numericUpDownRead;
private Button buttonJoinQuery;
private NumericUpDown numericUpDownJoin;
private TextBox textBoxJoin;
private Label label5;
private Label label6;
}
}

79
CarRent/FormTests.cs Normal file
View File

@ -0,0 +1,79 @@
using CarRentContracts.BusinessLogicContracts;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CarRent
{
public partial class FormTests : Form
{
private readonly IRentalLogic _rentalLogic;
private readonly IClientLogic _clientLogic;
private readonly ICarLogic _carLogic;
public FormTests(IRentalLogic rentalLogic,
IClientLogic clientLogic,
ICarLogic carLogic)
{
InitializeComponent();
_rentalLogic = rentalLogic;
_clientLogic = clientLogic;
_carLogic = carLogic;
numericUpDownInsert.Minimum = 0;
numericUpDownInsert.Maximum = 1000000;
numericUpDownRead.Minimum = 0;
numericUpDownRead.Maximum = 1000000;
numericUpDownJoin.Minimum = 0;
numericUpDownJoin.Maximum = 1000000;
}
private void buttonInsertTest_Click(object sender, EventArgs e)
{
try
{
var result = _rentalLogic.TestInsertList(Convert.ToInt32(numericUpDownInsert.Value),
_clientLogic.ReadList(null) ?? new(),
_carLogic.ReadList(null) ?? new());
textBoxInsertTime.Text = result;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonReadTest_Click(object sender, EventArgs e)
{
try
{
var result = _rentalLogic.TestReadList(Convert.ToInt32(numericUpDownInsert.Value));
textBoxReadTime.Text = result;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonJoinQuery_Click(object sender, EventArgs e)
{
try
{
var result = _rentalLogic.TestJoinReadList(Convert.ToInt32(numericUpDownJoin.Value));
textBoxJoin.Text = result;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

60
CarRent/FormTests.resx Normal file
View File

@ -0,0 +1,60 @@
<root>
<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>

53
CarRent/Program.cs Normal file
View File

@ -0,0 +1,53 @@
using CarRentBusinessLogic.BusinessLogics;
using CarRentContracts.BusinessLogicContracts;
using CarRentContracts.StoragesContracts;
using CarRentDatabase.Implements;
using ClientRentBusinessLogic.BusinessLogics;
using Microsoft.Extensions.DependencyInjection;
using System;
namespace CarRent
{
internal static class Program
{
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
/// <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();
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<FormRentals>());
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddTransient<IBranchStorage, BranchStorage>();
services.AddTransient<ICarStorage, CarStorage>();
services.AddTransient<IRentalStorage, RentalStorage>();
services.AddTransient<IClientStorage, ClientStorage>();
services.AddTransient<IBranchLogic, BranchLogic>();
services.AddTransient<ICarLogic, CarLogic>();
services.AddTransient<IRentalLogic, RentalLogic>();
services.AddTransient<IClientLogic, ClientLogic>();
services.AddTransient<FormRentals>();
services.AddTransient<FormBranches>();
services.AddTransient<FormCars>();
services.AddTransient<FormClients>();
services.AddTransient<FormCreateRental>();
services.AddTransient<FormCreateBranch>();
services.AddTransient<FormCreateCar>();
services.AddTransient<FormCreateClient>();
services.AddTransient<FormAddReview>();
services.AddTransient<FormTests>();
}
}
}

View File

@ -0,0 +1,117 @@
using CarRentContracts.BindingModels;
using CarRentContracts.BusinessLogicContracts;
using CarRentContracts.SearchModels;
using CarRentContracts.StoragesContracts;
using CarRentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentBusinessLogic.BusinessLogics
{
public class BranchLogic : IBranchLogic
{
private readonly IBranchStorage _branchStorage;
public BranchLogic(IBranchStorage branchStorage)
{
_branchStorage = branchStorage;
}
public void BranchInsertList(int num)
{
_branchStorage.BranchInsertList(num);
}
public void ClearEntity()
{
_branchStorage.ClearEntity();
}
public List<BranchViewModel>? ReadList(BranchSearchModel? model)
{
var list = model == null ? _branchStorage.GetFullList() :
_branchStorage.GetFilteredList(model);
if (list == null)
{
return null;
}
return list;
}
public BranchViewModel? ReadElement(BranchSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _branchStorage.GetElement(model);
if (element == null)
{
return null;
}
return element;
}
public bool Create(BranchBindingModel model)
{
CheckModel(model);
if (_branchStorage.Insert(model) == null)
{
return false;
}
return true;
}
public bool Update(BranchBindingModel model)
{
CheckModel(model);
if (_branchStorage.Update(model) == null)
{
return false;
}
return true;
}
public bool Delete(BranchBindingModel model)
{
CheckModel(model, false);
if (_branchStorage.Delete(model) == null)
{
return false;
}
return true;
}
private void CheckModel(BranchBindingModel 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 (string.IsNullOrEmpty(model.Address))
{
throw new ArgumentNullException("Нет адреса филиала",
nameof(model.Address));
}
if (string.IsNullOrEmpty(model.PhoneNumber))
{
throw new ArgumentNullException("Нет номера телефона филиала",
nameof(model.PhoneNumber));
}
var element = _branchStorage.GetElement(
new BranchSearchModel
{
Name = model.Name
}
);
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Филиал с таким названием уже есть");
}
}
}
}

View File

@ -0,0 +1,136 @@
using CarRentContracts.BindingModels;
using CarRentContracts.BusinessLogicContracts;
using CarRentContracts.SearchModels;
using CarRentContracts.StoragesContracts;
using CarRentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentBusinessLogic.BusinessLogics
{
public class CarLogic : ICarLogic
{
private readonly ICarStorage _carStorage;
public CarLogic(ICarStorage CarStorage)
{
_carStorage = CarStorage;
}
public void ClearEntity()
{
_carStorage.ClearEntity();
}
public void CarInsertList(int num, List<BranchViewModel> branches)
{
_carStorage.CarInsertList(num, branches);
}
public List<CarViewModel>? ReadList(CarSearchModel? model)
{
var list = model == null ? _carStorage.GetFullList() :
_carStorage.GetFilteredList(model);
if (list == null)
{
return null;
}
return list;
}
public CarViewModel? ReadElement(CarSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _carStorage.GetElement(model);
if (element == null)
{
return null;
}
return element;
}
public bool Create(CarBindingModel model)
{
CheckModel(model);
if (_carStorage.Insert(model) == null)
{
return false;
}
return true;
}
public bool Update(CarBindingModel model)
{
CheckModel(model);
if (_carStorage.Update(model) == null)
{
return false;
}
return true;
}
public bool Delete(CarBindingModel model)
{
CheckModel(model, false);
if (_carStorage.Delete(model) == null)
{
return false;
}
return true;
}
private void CheckModel(CarBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Brand))
{
throw new ArgumentNullException("Нет производителя авто",
nameof(model.Brand));
}
if (string.IsNullOrEmpty(model.Model))
{
throw new ArgumentNullException("Нет адреса филиала",
nameof(model.Model));
}
if (string.IsNullOrEmpty(model.Color))
{
throw new ArgumentNullException("Нет номера телефона филиала",
nameof(model.Color));
}
if (string.IsNullOrEmpty(model.LicensePlate))
{
throw new ArgumentNullException("Нет номера телефона филиала",
nameof(model.LicensePlate));
}
if(model.RentalCostPerHour < 0)
{
throw new ArgumentNullException("Цена аренды должна быть больше 0",
nameof(model.RentalCostPerHour));
}
if(model.YearOfManuf > DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc))
{
throw new ArgumentNullException("Неверно указана дата выпуска автомобиля",
nameof(model.YearOfManuf));
}
if (model.BranchId < 0)
{
throw new ArgumentNullException("Укажите филиал",
nameof(model.BranchId));
}
var element = _carStorage.GetElement(
new CarSearchModel
{
LicensePlate = model.LicensePlate
}
);
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Автомобиль с таким номером уже есть");
}
}
}
}

View File

@ -0,0 +1,127 @@
using CarRentContracts.BindingModels;
using CarRentContracts.BusinessLogicContracts;
using CarRentContracts.SearchModels;
using CarRentContracts.StoragesContracts;
using CarRentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ClientRentBusinessLogic.BusinessLogics
{
public class ClientLogic : IClientLogic
{
private readonly IClientStorage _clientStorage;
public ClientLogic(IClientStorage ClientStorage)
{
_clientStorage = ClientStorage;
}
public void ClientInsertList(int num)
{
_clientStorage.ClientInsertList(num);
}
public void ClearEntity()
{
_clientStorage.ClearEntity();
}
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
{
var list = model == null ? _clientStorage.GetFullList() :
_clientStorage.GetFilteredList(model);
if (list == null)
{
return null;
}
return list;
}
public ClientViewModel? ReadElement(ClientSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _clientStorage.GetElement(model);
if (element == null)
{
return null;
}
return element;
}
public bool Create(ClientBindingModel model)
{
CheckModel(model);
if (_clientStorage.Insert(model) == null)
{
return false;
}
return true;
}
public bool Update(ClientBindingModel model)
{
CheckModel(model);
if (_clientStorage.Update(model) == null)
{
return false;
}
return true;
}
public bool Delete(ClientBindingModel model)
{
CheckModel(model, false);
if (_clientStorage.Delete(model) == null)
{
return false;
}
return true;
}
private void CheckModel(ClientBindingModel 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 (string.IsNullOrEmpty(model.Surname))
{
throw new ArgumentNullException("Нет фамилии клиента",
nameof(model.Surname));
}
if (string.IsNullOrEmpty(model.PhoneNumber))
{
throw new ArgumentNullException("Нет номера телефона клиента",
nameof(model.PhoneNumber));
}
if (string.IsNullOrEmpty(model.Email))
{
throw new ArgumentNullException("Нет адреса электронной почты клиента",
nameof(model.Email));
}
if (string.IsNullOrEmpty(model.DriveLicenseNumber))
{
throw new ArgumentNullException("Нет водительских прав клиента",
nameof(model.DriveLicenseNumber));
}
var element = _clientStorage.GetElement(
new ClientSearchModel
{
DriveLicenseNumber = model.DriveLicenseNumber
}
);
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Клиент с такими водительскими правами уже есть");
}
}
}
}

View File

@ -0,0 +1,111 @@
using CarRentContracts.BindingModels;
using CarRentContracts.BusinessLogicContracts;
using CarRentContracts.SearchModels;
using CarRentContracts.StoragesContracts;
using CarRentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentBusinessLogic.BusinessLogics
{
public class RentalLogic : IRentalLogic
{
private readonly IRentalStorage _rentalStorage;
public RentalLogic(IRentalStorage RentalStorage)
{
_rentalStorage = RentalStorage;
}
public string TestInsertList(int num,
List<ClientViewModel> clients,
List<CarViewModel> cars)
{
return _rentalStorage.TestInsertList(num, clients, cars);
}
public string TestReadList(int num)
{
return _rentalStorage.TestReadList(num);
}
public string TestJoinReadList(int num)
{
return _rentalStorage.TestJoinReadList(num);
}
public void ClearEntity()
{
_rentalStorage.ClearEntity();
}
public List<RentalViewModel>? ReadList(RentalSearchModel? model)
{
var list = model == null ? _rentalStorage.GetFullList() :
_rentalStorage.GetFilteredList(model);
if (list == null)
{
return null;
}
return list;
}
public RentalViewModel? ReadElement(RentalSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _rentalStorage.GetElement(model);
if (element == null)
{
return null;
}
return element;
}
public bool Create(RentalBindingModel model)
{
CheckModel(model);
if (_rentalStorage.Insert(model) == null)
{
return false;
}
return true;
}
public bool Update(RentalBindingModel model)
{
CheckModel(model);
if (_rentalStorage.Update(model) == null)
{
return false;
}
return true;
}
public bool Delete(RentalBindingModel model)
{
CheckModel(model, false);
if (_rentalStorage.Delete(model) == null)
{
return false;
}
return true;
}
private void CheckModel(RentalBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (model.RentalCost < 0)
{
throw new ArgumentNullException("Цена аренды должна быть больше 0",
nameof(model.RentalCost));
}
if (model.StartDate > DateTime.Now)
{
throw new ArgumentNullException("Дата указана неверно",
nameof(model.StartDate));
}
}
}
}

View File

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

View File

@ -0,0 +1,20 @@
using CarRentDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentContracts.BindingModels
{
public class BranchBindingModel : IBranchModel
{
public string Name { get; set; } = string.Empty;
public string Address { get; set; } = string.Empty;
public string PhoneNumber { get; set; } = string.Empty;
public int Id { get; set; }
}
}

View File

@ -0,0 +1,26 @@
using CarRentDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentContracts.BindingModels
{
public class CarBindingModel : ICarModel
{
public string Brand { get; set; } = string.Empty;
public string Model { get; set; } = string.Empty;
public DateTime YearOfManuf { get; set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
public string Color { get; set; } = string.Empty;
public string LicensePlate { get; set; } = string.Empty;
public double RentalCostPerHour { get; set; }
public int BranchId { get; set; }
public int Id { get; set; }
}
}

View File

@ -0,0 +1,24 @@
using CarRentDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentContracts.BindingModels
{
public class ClientBindingModel : IClientModel
{
public string Name { get; set; } = string.Empty;
public string Surname { get; set; } = string.Empty;
public string PhoneNumber { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
public string DriveLicenseNumber { get; set; } = string.Empty;
public int Id { get; set; }
}
}

View File

@ -0,0 +1,26 @@
using CarRentDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentContracts.BindingModels
{
public class RentalBindingModel : IRentalModel
{
public DateTime StartDate { get; set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
public DateTime? EndDate { get; set; }
public double RentalCost { get; set; }
public string? ReviewText { get; set; } = string.Empty;
public int? ReviewRating { get; set; }
public int ClientId { get; set; }
public int CarId { get; set; }
public int Id { get; set; }
}
}

View File

@ -0,0 +1,22 @@
using CarRentContracts.BindingModels;
using CarRentContracts.SearchModels;
using CarRentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentContracts.BusinessLogicContracts
{
public interface IBranchLogic
{
List<BranchViewModel>? ReadList(BranchSearchModel? model);
BranchViewModel? ReadElement(BranchSearchModel model);
bool Create(BranchBindingModel model);
bool Update(BranchBindingModel model);
bool Delete(BranchBindingModel model);
void BranchInsertList(int num);
void ClearEntity();
}
}

View File

@ -0,0 +1,22 @@
using CarRentContracts.BindingModels;
using CarRentContracts.SearchModels;
using CarRentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentContracts.BusinessLogicContracts
{
public interface ICarLogic
{
List<CarViewModel>? ReadList(CarSearchModel? model);
CarViewModel? ReadElement(CarSearchModel model);
bool Create(CarBindingModel model);
bool Update(CarBindingModel model);
bool Delete(CarBindingModel model);
void CarInsertList(int num, List<BranchViewModel> branches);
void ClearEntity();
}
}

View File

@ -0,0 +1,22 @@
using CarRentContracts.BindingModels;
using CarRentContracts.SearchModels;
using CarRentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentContracts.BusinessLogicContracts
{
public interface IClientLogic
{
List<ClientViewModel>? ReadList(ClientSearchModel? model);
ClientViewModel? ReadElement(ClientSearchModel model);
bool Create(ClientBindingModel model);
bool Update(ClientBindingModel model);
bool Delete(ClientBindingModel model);
void ClientInsertList(int num);
void ClearEntity();
}
}

View File

@ -0,0 +1,26 @@
using CarRentContracts.BindingModels;
using CarRentContracts.SearchModels;
using CarRentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentContracts.BusinessLogicContracts
{
public interface IRentalLogic
{
List<RentalViewModel>? ReadList(RentalSearchModel? model);
RentalViewModel? ReadElement(RentalSearchModel model);
bool Create(RentalBindingModel model);
bool Update(RentalBindingModel model);
bool Delete(RentalBindingModel model);
public string TestInsertList(int num,
List<ClientViewModel> clients,
List<CarViewModel> cars);
string TestReadList(int num);
string TestJoinReadList(int num);
void ClearEntity();
}
}

View File

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

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentContracts.SearchModels
{
public class BranchSearchModel
{
public string? Name { get; set; }
public string? Address { get; set; }
public string? PhoneNumber { get; set; }
public int? Id { 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 CarRentContracts.SearchModels
{
public class CarSearchModel
{
public string? Brand { get; set; }
public string? Model { get; set; }
public DateTime? YearOfManuf { get; set; }
public string? Color { get; set; }
public string? LicensePlate { get; set; }
public double? RentalCostPerHour { get; set; }
public int? Id { get; set; }
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentContracts.SearchModels
{
public class ClientSearchModel
{
public string? Name { get; set; }
public string? Surname { get; set; }
public string? PhoneNumber { get; set; }
public string? Email { get; set; }
public string? DriveLicenseNumber { get; set; }
public int? Id { get; set; }
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentContracts.SearchModels
{
public class RentalSearchModel
{
public DateTime? StartDate { get; set; }
public DateTime? EndDate { get; set; }
public double? RentalCost { get; set; }
public string? ReviewText { get; set; }
public int? ReviewRating { get; set; }
public int? ClientId { get; set; }
public int? Id { get; set; }
}
}

View File

@ -0,0 +1,23 @@
using CarRentContracts.BindingModels;
using CarRentContracts.SearchModels;
using CarRentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentContracts.StoragesContracts
{
public interface IBranchStorage
{
List<BranchViewModel> GetFullList();
List<BranchViewModel> GetFilteredList(BranchSearchModel model);
BranchViewModel? GetElement(BranchSearchModel model);
BranchViewModel? Insert(BranchBindingModel model);
BranchViewModel? Update(BranchBindingModel model);
BranchViewModel? Delete(BranchBindingModel model);
void BranchInsertList(int num);
void ClearEntity();
}
}

View File

@ -0,0 +1,23 @@
using CarRentContracts.BindingModels;
using CarRentContracts.SearchModels;
using CarRentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentContracts.StoragesContracts
{
public interface ICarStorage
{
List<CarViewModel> GetFullList();
List<CarViewModel> GetFilteredList(CarSearchModel model);
CarViewModel? GetElement(CarSearchModel model);
CarViewModel? Insert(CarBindingModel model);
CarViewModel? Update(CarBindingModel model);
CarViewModel? Delete(CarBindingModel model);
void CarInsertList(int num, List<BranchViewModel> branches);
void ClearEntity();
}
}

View File

@ -0,0 +1,23 @@
using CarRentContracts.BindingModels;
using CarRentContracts.SearchModels;
using CarRentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentContracts.StoragesContracts
{
public interface IClientStorage
{
List<ClientViewModel> GetFullList();
List<ClientViewModel> GetFilteredList(ClientSearchModel model);
ClientViewModel? GetElement(ClientSearchModel model);
ClientViewModel? Insert(ClientBindingModel model);
ClientViewModel? Update(ClientBindingModel model);
ClientViewModel? Delete(ClientBindingModel model);
void ClientInsertList(int num);
void ClearEntity();
}
}

View File

@ -0,0 +1,27 @@
using CarRentContracts.BindingModels;
using CarRentContracts.SearchModels;
using CarRentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentContracts.StoragesContracts
{
public interface IRentalStorage
{
List<RentalViewModel> GetFullList();
List<RentalViewModel> GetFilteredList(RentalSearchModel model);
RentalViewModel? GetElement(RentalSearchModel model);
RentalViewModel? Insert(RentalBindingModel model);
RentalViewModel? Update(RentalBindingModel model);
RentalViewModel? Delete(RentalBindingModel model);
string TestInsertList(int num,
List<ClientViewModel> clients,
List<CarViewModel> cars);
string TestReadList(int num);
string TestJoinReadList(int num);
void ClearEntity();
}
}

View File

@ -0,0 +1,21 @@
using CarRentDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentContracts.ViewModels
{
public class BranchViewModel : IBranchModel
{
[DisplayName("Название филиала")]
public string Name { get; set; } = string.Empty;
[DisplayName("Адрес филиала")]
public string Address { get; set; } = string.Empty;
[DisplayName("Номер телефона")]
public string PhoneNumber { get; set; } = string.Empty;
public int Id { get; set; }
}
}

View File

@ -0,0 +1,30 @@
using CarRentDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentContracts.ViewModels
{
public class CarViewModel : ICarModel
{
[DisplayName("Филиал")]
public string BranchName { get; set; } = string.Empty;
[DisplayName("Производитель")]
public string Brand { get; set; } = string.Empty;
[DisplayName("Модель")]
public string Model { get; set; } = string.Empty;
[DisplayName("Год выпуска")]
public DateTime YearOfManuf { get; set; } = DateTime.SpecifyKind(DateTime.MinValue, DateTimeKind.Utc);
[DisplayName("Цвет")]
public string Color { get; set; } = string.Empty;
[DisplayName("Номер автомобиля")]
public string LicensePlate { get; set; } = string.Empty;
[DisplayName("Цена аренды за час")]
public double RentalCostPerHour { get; set; }
public int BranchId { get; set; }
public int Id { get; set; }
}
}

View File

@ -0,0 +1,26 @@
using CarRentDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentContracts.ViewModels
{
public class ClientViewModel : IClientModel
{
[DisplayName("Имя")]
public string Name { get; set; } = string.Empty;
[DisplayName("Фамилия")]
public string Surname { get; set; } = string.Empty;
[DisplayName("Номер телефона")]
public string PhoneNumber { get; set; } = string.Empty;
[DisplayName("Адрес электронной почты")]
public string Email { get; set; } = string.Empty;
[DisplayName("Номер водительских прав")]
public string DriveLicenseNumber { get; set; } = string.Empty;
public int Id { get; set; }
}
}

View File

@ -0,0 +1,34 @@
using CarRentDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentContracts.ViewModels
{
public class RentalViewModel : IRentalModel
{
[DisplayName("Имя")]
public string ClientName { get; set; } = string.Empty;
[DisplayName("Фамилия")]
public string ClientSurname { get; set; } = string.Empty;
[DisplayName("Номер автомобиля")]
public string LicensePlate { get; set; } = string.Empty;
[DisplayName("Дата начала аренды")]
public DateTime StartDate { get; set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
[DisplayName("Дата конца аренды")]
public DateTime? EndDate { get; set; }
[DisplayName("Общая стоимость аренды")]
public double RentalCost { get; set; }
[DisplayName("Текст отзыва к аренде")]
public string? ReviewText { get; set; } = string.Empty;
[DisplayName("Оценка аренды")]
public int? ReviewRating { get; set; }
public int ClientId { get; set; }
public int CarId { get; set; }
public int Id { get; set; }
}
}

View File

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

7
CarRentDataModels/IId.cs Normal file
View File

@ -0,0 +1,7 @@
namespace CarRentDataModels
{
public interface IId
{
int Id { get; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentDataModels.Models
{
public interface IBranchModel : IId
{
string Name { get; }
string Address { get; }
string PhoneNumber { get; }
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentDataModels.Models
{
public interface ICarModel : IId
{
string Brand { get; }
string Model { get; }
DateTime YearOfManuf { get; }
string Color { get; }
string LicensePlate { get; }
double RentalCostPerHour { get; }
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentDataModels.Models
{
public interface IClientModel : IId
{
string Name { get; }
string Surname { get; }
string PhoneNumber { get; }
string Email { get; }
string DriveLicenseNumber { get; }
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentDataModels.Models
{
public interface IRentalModel : IId
{
DateTime StartDate { get; }
DateTime? EndDate { get; }
double RentalCost { get; }
string? ReviewText { get; }
int? ReviewRating { get; }
}
}

View File

@ -0,0 +1,28 @@
using CarRentDatabase.Models;
using Microsoft.EntityFrameworkCore;
using System.Numerics;
using System.Reflection.Metadata;
namespace CarRentDatabase
{
public class CarRentDatabase : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseNpgsql(@"
Host=192.168.56.101;
Port=5432;
Database=SUBDLab4;
Username=postgres;
Password=123");
}
base.OnConfiguring(optionsBuilder);
}
public virtual DbSet<Branch> Branches { set; get; }
public virtual DbSet<Car> Cars { set; get; }
public virtual DbSet<Client> Clients { set; get; }
public virtual DbSet<Rental> Rentals { set; get; }
}
}

View File

@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Folder Include="Migrations\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Bogus" Version="34.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.4" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CarRentContracts\CarRentContracts.csproj" />
<ProjectReference Include="..\CarRentDataModels\CarRentDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,118 @@
using Bogus;
using CarRentContracts.BindingModels;
using CarRentContracts.SearchModels;
using CarRentContracts.StoragesContracts;
using CarRentContracts.ViewModels;
using CarRentDatabase.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace CarRentDatabase.Implements
{
public class BranchStorage : IBranchStorage
{
public void ClearEntity()
{
using var context = new CarRentDatabase();
string deleteAllQuery = "DELETE FROM \"Branches\"";
context.Database.ExecuteSqlRaw(deleteAllQuery);
}
public void BranchInsertList(int num)
{
using var context = new CarRentDatabase();
var faker = new Faker("ru");
for (int i = 0; i < num; ++i)
{
var model = new BranchBindingModel
{
Id = 0,
Name = faker.Company.CompanyName(),
Address = faker.Address.FullAddress(),
PhoneNumber = faker.Phone.PhoneNumber(),
};
context.Branches.Add(Branch.Create(model));
}
context.SaveChanges();
}
public BranchViewModel? GetElement(BranchSearchModel model)
{
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
{
return null;
}
using var context = new CarRentDatabase();
return context.Branches
.FirstOrDefault(x =>
(!string.IsNullOrEmpty(model.Name) && x.Name ==
model.Name) ||
(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public List<BranchViewModel> GetFilteredList(BranchSearchModel model)
{
if (string.IsNullOrEmpty(model.Name))
{
return new();
}
using var context = new CarRentDatabase();
return context.Branches
.Where(x => x.Name.Contains(model.Name))
.Select(x => x.GetViewModel)
.ToList();
}
public List<BranchViewModel> GetFullList()
{
using var context = new CarRentDatabase();
return context.Branches
.Select(x => x.GetViewModel)
.ToList();
}
public BranchViewModel? Insert(BranchBindingModel model)
{
var newBranch = Branch.Create(model);
if (newBranch == null)
{
return null;
}
using var context = new CarRentDatabase();
context.Branches.Add(newBranch);
context.SaveChanges();
return newBranch.GetViewModel;
}
public BranchViewModel? Update(BranchBindingModel model)
{
using var context = new CarRentDatabase();
var component = context.Branches.FirstOrDefault(x => x.Id == model.Id);
if (component == null)
{
return null;
}
component.Update(model);
context.SaveChanges();
return component.GetViewModel;
}
public BranchViewModel? Delete(BranchBindingModel model)
{
using var context = new CarRentDatabase();
var element = context.Branches.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Branches.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,150 @@
using Bogus;
using CarRentContracts.BindingModels;
using CarRentContracts.SearchModels;
using CarRentContracts.StoragesContracts;
using CarRentContracts.ViewModels;
using CarRentDatabase.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentDatabase.Implements
{
public class CarStorage : ICarStorage
{
public void ClearEntity()
{
using var context = new CarRentDatabase();
string deleteAllQuery = "DELETE FROM \"Cars\"";
context.Database.ExecuteSqlRaw(deleteAllQuery);
}
public CarViewModel? GetElement(CarSearchModel model)
{
if (string.IsNullOrEmpty(model.LicensePlate) && !model.Id.HasValue)
{
return null;
}
using var context = new CarRentDatabase();
return context.Cars
.FirstOrDefault(x =>
(!string.IsNullOrEmpty(model.LicensePlate) && x.LicensePlate ==
model.LicensePlate) ||
(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public void CarInsertList(int num, List<BranchViewModel> branches)
{
Random rnd = new Random();
var faker = new Faker("ru");
using var context = new CarRentDatabase();
for (int i = 0; i < num; ++i)
{
var model = new CarBindingModel
{
Id = 0,
Brand = faker.Vehicle.Manufacturer(),
Model = faker.Vehicle.Model(),
YearOfManuf = DateTime.SpecifyKind(faker.Date.Past(), DateTimeKind.Utc),
Color = "#" + rnd.Next(100000).ToString(),
LicensePlate = faker.Vehicle.Vin(),
RentalCostPerHour = rnd.Next(1000),
BranchId = branches[rnd.Next(branches.Count)].Id,
};
context.Cars.Add(Car.Create(model));
}
context.SaveChanges();
}
public List<CarViewModel> GetFilteredList(CarSearchModel model)
{
using var context = new CarRentDatabase();
if (model.Id.HasValue)
{
return context.Cars
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
}
else if (model.Brand != string.Empty)
{
return context.Cars
.Where(x => x.Brand == model.Brand)
.Select(x => x.GetViewModel)
.ToList();
}
else if (model.Color != string.Empty)
{
return context.Cars
.Where(x => x.Color == model.Color)
.Select(x => x.GetViewModel)
.ToList();
}
else if (model.YearOfManuf.HasValue)
{
return context.Cars
.Where(x => x.YearOfManuf >= model.YearOfManuf)
.Select(x => x.GetViewModel)
.ToList();
}
else if (model.RentalCostPerHour.HasValue)
{
return context.Cars
.Where(x => x.RentalCostPerHour <= model.RentalCostPerHour)
.Select(x => x.GetViewModel)
.ToList();
}
return null;
}
public List<CarViewModel> GetFullList()
{
using var context = new CarRentDatabase();
return context.Cars
.Include(x => x.Branch)
.Select(x => x.GetViewModel)
.ToList();
}
public CarViewModel? Insert(CarBindingModel model)
{
var newCar = Car.Create(model);
if (newCar == null)
{
return null;
}
using var context = new CarRentDatabase();
context.Cars.Add(newCar);
context.SaveChanges();
return newCar.GetViewModel;
}
public CarViewModel? Update(CarBindingModel model)
{
using var context = new CarRentDatabase();
var component = context.Cars.FirstOrDefault(x => x.Id == model.Id);
if (component == null)
{
return null;
}
component.Update(model);
context.SaveChanges();
return component.GetViewModel;
}
public CarViewModel? Delete(CarBindingModel model)
{
using var context = new CarRentDatabase();
var element = context.Cars.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Cars.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,120 @@
using CarRentContracts.BindingModels;
using CarRentContracts.SearchModels;
using CarRentContracts.StoragesContracts;
using CarRentContracts.ViewModels;
using CarRentDatabase.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Bogus;
using Microsoft.EntityFrameworkCore;
namespace CarRentDatabase.Implements
{
public class ClientStorage : IClientStorage
{
public void ClearEntity()
{
using var context = new CarRentDatabase();
string deleteAllQuery = "DELETE FROM \"Clients\"";
context.Database.ExecuteSqlRaw(deleteAllQuery);
}
public void ClientInsertList(int num)
{
var faker = new Faker("ru");
Random rnd = new Random();
using var context = new CarRentDatabase();
var uniqueGen = context.Clients.OrderByDescending(x => x.Id).FirstOrDefault()?.Id + 1;
for (int i = 0; i < num; ++i)
{
var model = new ClientBindingModel
{
Id = 0,
Name = faker.Name.FirstName(),
Surname = faker.Name.LastName(),
PhoneNumber = faker.Phone.PhoneNumber(),
Email = faker.Internet.Email(uniqueGen.ToString()),
DriveLicenseNumber = rnd.Next(1000).ToString(),
};
context.Clients.Add(Client.Create(model));
}
context.SaveChanges();
}
public ClientViewModel? GetElement(ClientSearchModel model)
{
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
{
return null;
}
using var context = new CarRentDatabase();
return context.Clients
.FirstOrDefault(x =>
(!string.IsNullOrEmpty(model.Name) && x.Name ==
model.Name) ||
(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
{
if (string.IsNullOrEmpty(model.Name))
{
return new();
}
using var context = new CarRentDatabase();
return context.Clients
.Where(x => x.Name.Contains(model.Name))
.Select(x => x.GetViewModel)
.ToList();
}
public List<ClientViewModel> GetFullList()
{
using var context = new CarRentDatabase();
return context.Clients
.Select(x => x.GetViewModel)
.ToList();
}
public ClientViewModel? Insert(ClientBindingModel model)
{
var newClient = Client.Create(model);
if (newClient == null)
{
return null;
}
using var context = new CarRentDatabase();
context.Clients.Add(newClient);
context.SaveChanges();
return newClient.GetViewModel;
}
public ClientViewModel? Update(ClientBindingModel model)
{
using var context = new CarRentDatabase();
var component = context.Clients.FirstOrDefault(x => x.Id == model.Id);
if (component == null)
{
return null;
}
component.Update(model);
context.SaveChanges();
return component.GetViewModel;
}
public ClientViewModel? Delete(ClientBindingModel model)
{
using var context = new CarRentDatabase();
var element = context.Clients.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Clients.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,180 @@
using Bogus;
using CarRentContracts.BindingModels;
using CarRentContracts.SearchModels;
using CarRentContracts.StoragesContracts;
using CarRentContracts.ViewModels;
using CarRentDatabase.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentDatabase.Implements
{
public class RentalStorage : IRentalStorage
{
public void ClearEntity()
{
using var context = new CarRentDatabase();
string deleteAllQuery = "DELETE FROM \"Rentals\"";
context.Database.ExecuteSqlRaw(deleteAllQuery);
}
public string TestInsertList(int num,
List<ClientViewModel> clients,
List<CarViewModel> cars)
{
Random rnd = new Random();
var faker = new Faker("ru");
using var context = new CarRentDatabase();
for(int i = 0; i < num; ++i)
{
var model = new RentalBindingModel
{
Id = 0,
StartDate = DateTime.SpecifyKind(faker.Date.Past(), DateTimeKind.Utc),
EndDate = DateTime.SpecifyKind(faker.Date.Future(), DateTimeKind.Utc),
RentalCost = 25,
ClientId = clients[rnd.Next(clients.Count)].Id,
CarId = cars[rnd.Next(cars.Count)].Id,
};
context.Rentals.Add(Rental.Create(model));
}
Stopwatch stopwatch = new();
stopwatch.Start();
context.SaveChanges();
stopwatch.Stop();
return stopwatch.ElapsedMilliseconds.ToString();
}
public string TestReadList(int num)
{
using var context = new CarRentDatabase();
Stopwatch stopwatch = new();
stopwatch.Start();
List<RentalViewModel> list = context.Rentals
.Include(x => x.Car)
.Include(x => x.Client)
.Take(num)
.Select(x => x.GetViewModel)
.ToList();
stopwatch.Stop();
return stopwatch.ElapsedMilliseconds.ToString();
}
public string TestJoinReadList(int num)
{
using var context = new CarRentDatabase();
Stopwatch stopwatch = new();
stopwatch.Start();
var list = context.Rentals
.Include(x => x.Car)
.Include(x => x.Client)
.Join(context.Clients,
r => r.ClientId,
c => c.Id,
(r, c) => new { Rental = r, Client = c })
.Join(context.Cars,
rc => rc.Rental.CarId,
car => car.Id,
(rc, car) => new { rc.Rental, rc.Client, Car = car })
.Select(rc => new
{
Rental = rc.Rental.GetViewModel,
Client = rc.Client.GetViewModel,
Car = rc.Car.GetViewModel,
})
.Take(num)
.ToList();
stopwatch.Stop();
return stopwatch.ElapsedMilliseconds.ToString();
}
public RentalViewModel? GetElement(RentalSearchModel model)
{
if (!model.Id.HasValue)
{
return null;
}
using var context = new CarRentDatabase();
return context.Rentals
.Include(x => x.Car)
.Include(x => x.Client)
.FirstOrDefault(x =>
(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public List<RentalViewModel> GetFilteredList(RentalSearchModel model)
{
if (!model.Id.HasValue && !model.ClientId.HasValue)
{
return new();
}
using var context = new CarRentDatabase();
return context.Rentals
.Include(x => x.Car)
.Include(x => x.Client)
.Where(x => x.ClientId == model.ClientId)
.Select(x => x.GetViewModel)
.ToList();
}
public List<RentalViewModel> GetFullList()
{
using var context = new CarRentDatabase();
return context.Rentals
.Include(x => x.Car)
.Include(x => x.Client)
.Select(x => x.GetViewModel)
.ToList();
}
public RentalViewModel? Insert(RentalBindingModel model)
{
var newRental = Rental.Create(model);
if (newRental == null)
{
return null;
}
using var context = new CarRentDatabase();
context.Rentals.Add(newRental);
context.SaveChanges();
return newRental.GetViewModel;
}
public RentalViewModel? Update(RentalBindingModel model)
{
using var context = new CarRentDatabase();
var component = context.Rentals.FirstOrDefault(x => x.Id == model.Id);
if (component == null)
{
return null;
}
component.Update(model);
context.SaveChanges();
return component.GetViewModel;
}
public RentalViewModel? Delete(RentalBindingModel model)
{
using var context = new CarRentDatabase();
var element = context.Rentals.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Rentals.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,204 @@
// <auto-generated />
using System;
using CarRentDatabase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace CarRentDatabase.Migrations
{
[DbContext(typeof(CarRentDatabase))]
[Migration("20230412152855_Lab4")]
partial class Lab4
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("CarRentDatabase.Models.Branch", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Address")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Branches");
});
modelBuilder.Entity("CarRentDatabase.Models.Car", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int?>("BranchId")
.HasColumnType("integer");
b.Property<string>("Brand")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Color")
.IsRequired()
.HasColumnType("text");
b.Property<string>("LicensePlate")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Model")
.IsRequired()
.HasColumnType("text");
b.Property<double>("RentalCostPerHour")
.HasColumnType("double precision");
b.Property<DateTime>("YearOfManuf")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("BranchId");
b.ToTable("Cars");
});
modelBuilder.Entity("CarRentDatabase.Models.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("DriveLicenseNumber")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("CarRentDatabase.Models.Rental", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CarId")
.HasColumnType("integer");
b.Property<int>("ClientId")
.HasColumnType("integer");
b.Property<DateTime?>("EndDate")
.IsRequired()
.HasColumnType("timestamp with time zone");
b.Property<double>("RentalCost")
.HasColumnType("double precision");
b.Property<int?>("ReviewRating")
.IsRequired()
.HasColumnType("integer");
b.Property<string>("ReviewText")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("CarId");
b.HasIndex("ClientId");
b.ToTable("Rentals");
});
modelBuilder.Entity("CarRentDatabase.Models.Car", b =>
{
b.HasOne("CarRentDatabase.Models.Branch", null)
.WithMany("Cars")
.HasForeignKey("BranchId");
});
modelBuilder.Entity("CarRentDatabase.Models.Rental", b =>
{
b.HasOne("CarRentDatabase.Models.Car", "Car")
.WithMany()
.HasForeignKey("CarId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CarRentDatabase.Models.Client", "Client")
.WithMany()
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Car");
b.Navigation("Client");
});
modelBuilder.Entity("CarRentDatabase.Models.Branch", b =>
{
b.Navigation("Cars");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,135 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace CarRentDatabase.Migrations
{
/// <inheritdoc />
public partial class Lab4 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Branches",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false),
Address = table.Column<string>(type: "text", nullable: false),
PhoneNumber = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Branches", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Clients",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false),
Surname = table.Column<string>(type: "text", nullable: false),
PhoneNumber = table.Column<string>(type: "text", nullable: false),
Email = table.Column<string>(type: "text", nullable: false),
Password = table.Column<string>(type: "text", nullable: false),
DriveLicenseNumber = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Clients", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Cars",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Brand = table.Column<string>(type: "text", nullable: false),
Model = table.Column<string>(type: "text", nullable: false),
YearOfManuf = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
Color = table.Column<string>(type: "text", nullable: false),
LicensePlate = table.Column<string>(type: "text", nullable: false),
RentalCostPerHour = table.Column<double>(type: "double precision", nullable: false),
BranchId = table.Column<int>(type: "integer", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Cars", x => x.Id);
table.ForeignKey(
name: "FK_Cars_Branches_BranchId",
column: x => x.BranchId,
principalTable: "Branches",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "Rentals",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
StartDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
EndDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
RentalCost = table.Column<double>(type: "double precision", nullable: false),
ReviewText = table.Column<string>(type: "text", nullable: false),
ReviewRating = table.Column<int>(type: "integer", nullable: false),
ClientId = table.Column<int>(type: "integer", nullable: false),
CarId = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Rentals", x => x.Id);
table.ForeignKey(
name: "FK_Rentals_Cars_CarId",
column: x => x.CarId,
principalTable: "Cars",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Rentals_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Cars_BranchId",
table: "Cars",
column: "BranchId");
migrationBuilder.CreateIndex(
name: "IX_Rentals_CarId",
table: "Rentals",
column: "CarId");
migrationBuilder.CreateIndex(
name: "IX_Rentals_ClientId",
table: "Rentals",
column: "ClientId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Rentals");
migrationBuilder.DropTable(
name: "Cars");
migrationBuilder.DropTable(
name: "Clients");
migrationBuilder.DropTable(
name: "Branches");
}
}
}

View File

@ -0,0 +1,204 @@
// <auto-generated />
using System;
using CarRentDatabase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace CarRentDatabase.Migrations
{
[DbContext(typeof(CarRentDatabase))]
[Migration("20230425195232_lab4start")]
partial class lab4start
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("CarRentDatabase.Models.Branch", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Address")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Branches");
});
modelBuilder.Entity("CarRentDatabase.Models.Car", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int?>("BranchId")
.HasColumnType("integer");
b.Property<string>("Brand")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Color")
.IsRequired()
.HasColumnType("text");
b.Property<string>("LicensePlate")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Model")
.IsRequired()
.HasColumnType("text");
b.Property<double>("RentalCostPerHour")
.HasColumnType("double precision");
b.Property<DateTime>("YearOfManuf")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("BranchId");
b.ToTable("Cars");
});
modelBuilder.Entity("CarRentDatabase.Models.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("DriveLicenseNumber")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("CarRentDatabase.Models.Rental", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CarId")
.HasColumnType("integer");
b.Property<int>("ClientId")
.HasColumnType("integer");
b.Property<DateTime?>("EndDate")
.IsRequired()
.HasColumnType("timestamp with time zone");
b.Property<double>("RentalCost")
.HasColumnType("double precision");
b.Property<int?>("ReviewRating")
.IsRequired()
.HasColumnType("integer");
b.Property<string>("ReviewText")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("CarId");
b.HasIndex("ClientId");
b.ToTable("Rentals");
});
modelBuilder.Entity("CarRentDatabase.Models.Car", b =>
{
b.HasOne("CarRentDatabase.Models.Branch", null)
.WithMany("Cars")
.HasForeignKey("BranchId");
});
modelBuilder.Entity("CarRentDatabase.Models.Rental", b =>
{
b.HasOne("CarRentDatabase.Models.Car", "Car")
.WithMany()
.HasForeignKey("CarId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CarRentDatabase.Models.Client", "Client")
.WithMany()
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Car");
b.Navigation("Client");
});
modelBuilder.Entity("CarRentDatabase.Models.Branch", b =>
{
b.Navigation("Cars");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CarRentDatabase.Migrations
{
/// <inheritdoc />
public partial class lab4start : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -0,0 +1,204 @@
// <auto-generated />
using System;
using CarRentDatabase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace CarRentDatabase.Migrations
{
[DbContext(typeof(CarRentDatabase))]
[Migration("20230426104558_lab4sybdfix")]
partial class lab4sybdfix
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("CarRentDatabase.Models.Branch", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Address")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Branches");
});
modelBuilder.Entity("CarRentDatabase.Models.Car", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("BranchId")
.HasColumnType("integer");
b.Property<string>("Brand")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Color")
.IsRequired()
.HasColumnType("text");
b.Property<string>("LicensePlate")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Model")
.IsRequired()
.HasColumnType("text");
b.Property<double>("RentalCostPerHour")
.HasColumnType("double precision");
b.Property<DateTime>("YearOfManuf")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("BranchId");
b.ToTable("Cars");
});
modelBuilder.Entity("CarRentDatabase.Models.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("DriveLicenseNumber")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("CarRentDatabase.Models.Rental", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CarId")
.HasColumnType("integer");
b.Property<int>("ClientId")
.HasColumnType("integer");
b.Property<DateTime?>("EndDate")
.IsRequired()
.HasColumnType("timestamp with time zone");
b.Property<double>("RentalCost")
.HasColumnType("double precision");
b.Property<int?>("ReviewRating")
.IsRequired()
.HasColumnType("integer");
b.Property<string>("ReviewText")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("CarId");
b.HasIndex("ClientId");
b.ToTable("Rentals");
});
modelBuilder.Entity("CarRentDatabase.Models.Car", b =>
{
b.HasOne("CarRentDatabase.Models.Branch", "Branch")
.WithMany("Cars")
.HasForeignKey("BranchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Branch");
});
modelBuilder.Entity("CarRentDatabase.Models.Rental", b =>
{
b.HasOne("CarRentDatabase.Models.Car", "Car")
.WithMany()
.HasForeignKey("CarId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CarRentDatabase.Models.Client", "Client")
.WithMany()
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Car");
b.Navigation("Client");
});
modelBuilder.Entity("CarRentDatabase.Models.Branch", b =>
{
b.Navigation("Cars");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,70 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CarRentDatabase.Migrations
{
/// <inheritdoc />
public partial class lab4sybdfix : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Cars_Branches_BranchId",
table: "Cars");
migrationBuilder.DropColumn(
name: "Password",
table: "Clients");
migrationBuilder.AlterColumn<int>(
name: "BranchId",
table: "Cars",
type: "integer",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "integer",
oldNullable: true);
migrationBuilder.AddForeignKey(
name: "FK_Cars_Branches_BranchId",
table: "Cars",
column: "BranchId",
principalTable: "Branches",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Cars_Branches_BranchId",
table: "Cars");
migrationBuilder.AddColumn<string>(
name: "Password",
table: "Clients",
type: "text",
nullable: false,
defaultValue: "");
migrationBuilder.AlterColumn<int>(
name: "BranchId",
table: "Cars",
type: "integer",
nullable: true,
oldClrType: typeof(int),
oldType: "integer");
migrationBuilder.AddForeignKey(
name: "FK_Cars_Branches_BranchId",
table: "Cars",
column: "BranchId",
principalTable: "Branches",
principalColumn: "Id");
}
}
}

View File

@ -0,0 +1,202 @@
// <auto-generated />
using System;
using CarRentDatabase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace CarRentDatabase.Migrations
{
[DbContext(typeof(CarRentDatabase))]
[Migration("20230426112015_lab4sybdfix2")]
partial class lab4sybdfix2
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("CarRentDatabase.Models.Branch", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Address")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Branches");
});
modelBuilder.Entity("CarRentDatabase.Models.Car", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("BranchId")
.HasColumnType("integer");
b.Property<string>("Brand")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Color")
.IsRequired()
.HasColumnType("text");
b.Property<string>("LicensePlate")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Model")
.IsRequired()
.HasColumnType("text");
b.Property<double>("RentalCostPerHour")
.HasColumnType("double precision");
b.Property<DateTime>("YearOfManuf")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("BranchId");
b.ToTable("Cars");
});
modelBuilder.Entity("CarRentDatabase.Models.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("DriveLicenseNumber")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("CarRentDatabase.Models.Rental", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CarId")
.HasColumnType("integer");
b.Property<int>("ClientId")
.HasColumnType("integer");
b.Property<DateTime?>("EndDate")
.IsRequired()
.HasColumnType("timestamp with time zone");
b.Property<double>("RentalCost")
.HasColumnType("double precision");
b.Property<int?>("ReviewRating")
.HasColumnType("integer");
b.Property<string>("ReviewText")
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("CarId");
b.HasIndex("ClientId");
b.ToTable("Rentals");
});
modelBuilder.Entity("CarRentDatabase.Models.Car", b =>
{
b.HasOne("CarRentDatabase.Models.Branch", "Branch")
.WithMany("Cars")
.HasForeignKey("BranchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Branch");
});
modelBuilder.Entity("CarRentDatabase.Models.Rental", b =>
{
b.HasOne("CarRentDatabase.Models.Car", "Car")
.WithMany()
.HasForeignKey("CarId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CarRentDatabase.Models.Client", "Client")
.WithMany()
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Car");
b.Navigation("Client");
});
modelBuilder.Entity("CarRentDatabase.Models.Branch", b =>
{
b.Navigation("Cars");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,54 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CarRentDatabase.Migrations
{
/// <inheritdoc />
public partial class lab4sybdfix2 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "ReviewText",
table: "Rentals",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<int>(
name: "ReviewRating",
table: "Rentals",
type: "integer",
nullable: true,
oldClrType: typeof(int),
oldType: "integer");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "ReviewText",
table: "Rentals",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "ReviewRating",
table: "Rentals",
type: "integer",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "integer",
oldNullable: true);
}
}
}

View File

@ -0,0 +1,202 @@
// <auto-generated />
using System;
using CarRentDatabase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace CarRentDatabase.Migrations
{
[DbContext(typeof(CarRentDatabase))]
[Migration("20230426113038_lab4sybdfix3")]
partial class lab4sybdfix3
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("CarRentDatabase.Models.Branch", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Address")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Branches");
});
modelBuilder.Entity("CarRentDatabase.Models.Car", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("BranchId")
.HasColumnType("integer");
b.Property<string>("Brand")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Color")
.IsRequired()
.HasColumnType("text");
b.Property<string>("LicensePlate")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Model")
.IsRequired()
.HasColumnType("text");
b.Property<double>("RentalCostPerHour")
.HasColumnType("double precision");
b.Property<DateTime>("YearOfManuf")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("BranchId");
b.ToTable("Cars");
});
modelBuilder.Entity("CarRentDatabase.Models.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("DriveLicenseNumber")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("CarRentDatabase.Models.Rental", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CarId")
.HasColumnType("integer");
b.Property<int>("ClientId")
.HasColumnType("integer");
b.Property<DateTime?>("EndDate")
.IsRequired()
.HasColumnType("timestamp with time zone");
b.Property<double>("RentalCost")
.HasColumnType("double precision");
b.Property<int?>("ReviewRating")
.HasColumnType("integer");
b.Property<string>("ReviewText")
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("CarId");
b.HasIndex("ClientId");
b.ToTable("Rentals");
});
modelBuilder.Entity("CarRentDatabase.Models.Car", b =>
{
b.HasOne("CarRentDatabase.Models.Branch", "Branch")
.WithMany("Cars")
.HasForeignKey("BranchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Branch");
});
modelBuilder.Entity("CarRentDatabase.Models.Rental", b =>
{
b.HasOne("CarRentDatabase.Models.Car", "Car")
.WithMany()
.HasForeignKey("CarId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CarRentDatabase.Models.Client", "Client")
.WithMany()
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Car");
b.Navigation("Client");
});
modelBuilder.Entity("CarRentDatabase.Models.Branch", b =>
{
b.Navigation("Cars");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CarRentDatabase.Migrations
{
/// <inheritdoc />
public partial class lab4sybdfix3 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -0,0 +1,199 @@
// <auto-generated />
using System;
using CarRentDatabase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace CarRentDatabase.Migrations
{
[DbContext(typeof(CarRentDatabase))]
partial class CarRentDatabaseModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("CarRentDatabase.Models.Branch", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Address")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Branches");
});
modelBuilder.Entity("CarRentDatabase.Models.Car", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("BranchId")
.HasColumnType("integer");
b.Property<string>("Brand")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Color")
.IsRequired()
.HasColumnType("text");
b.Property<string>("LicensePlate")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Model")
.IsRequired()
.HasColumnType("text");
b.Property<double>("RentalCostPerHour")
.HasColumnType("double precision");
b.Property<DateTime>("YearOfManuf")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("BranchId");
b.ToTable("Cars");
});
modelBuilder.Entity("CarRentDatabase.Models.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("DriveLicenseNumber")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("CarRentDatabase.Models.Rental", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CarId")
.HasColumnType("integer");
b.Property<int>("ClientId")
.HasColumnType("integer");
b.Property<DateTime?>("EndDate")
.IsRequired()
.HasColumnType("timestamp with time zone");
b.Property<double>("RentalCost")
.HasColumnType("double precision");
b.Property<int?>("ReviewRating")
.HasColumnType("integer");
b.Property<string>("ReviewText")
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("CarId");
b.HasIndex("ClientId");
b.ToTable("Rentals");
});
modelBuilder.Entity("CarRentDatabase.Models.Car", b =>
{
b.HasOne("CarRentDatabase.Models.Branch", "Branch")
.WithMany("Cars")
.HasForeignKey("BranchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Branch");
});
modelBuilder.Entity("CarRentDatabase.Models.Rental", b =>
{
b.HasOne("CarRentDatabase.Models.Car", "Car")
.WithMany()
.HasForeignKey("CarId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CarRentDatabase.Models.Client", "Client")
.WithMany()
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Car");
b.Navigation("Client");
});
modelBuilder.Entity("CarRentDatabase.Models.Branch", b =>
{
b.Navigation("Cars");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,60 @@
using CarRentContracts.BindingModels;
using CarRentContracts.ViewModels;
using CarRentDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace CarRentDatabase.Models
{
public class Branch : IBranchModel
{
[Required]
public string Name { get; set; } = string.Empty;
[Required]
public string Address { get; set; } = string.Empty;
[Required]
public string PhoneNumber { get; set; } = string.Empty;
public int Id { get; private set; }
[ForeignKey("BranchId")]
public virtual List<Car> Cars { get; set; } = new();
public static Branch? Create(BranchBindingModel model)
{
if (model == null)
{
return null;
}
return new Branch()
{
Id = model.Id,
Name = model.Name,
Address = model.Address,
PhoneNumber = model.PhoneNumber,
};
}
public void Update(BranchBindingModel model)
{
if (model == null)
{
return;
}
Name = model.Name;
Address = model.Address;
PhoneNumber = model.PhoneNumber;
}
public BranchViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
Address = Address,
PhoneNumber = PhoneNumber,
};
}
}

View File

@ -0,0 +1,83 @@
using CarRentContracts.BindingModels;
using CarRentContracts.ViewModels;
using CarRentDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace CarRentDatabase.Models
{
public class Car : ICarModel
{
[Required]
public string Brand { get; set; } = string.Empty;
[Required]
public string Model { get; set; } = string.Empty;
[Required]
public DateTime YearOfManuf { get; set; } = DateTime.SpecifyKind(DateTime.MinValue, DateTimeKind.Utc);
[Required]
public string Color { get; set; } = string.Empty;
[Required]
public string LicensePlate { get; set; } = string.Empty;
[Required]
public double RentalCostPerHour { get; set; }
[Required]
public int BranchId { get; set; }
public int Id { get; private set; }
[ForeignKey("CarId")]
List<Rental> RentalCars { get; set; } = new();
public virtual Branch Branch { get; set; }
public static Car? Create(CarBindingModel model)
{
if (model == null)
{
return null;
}
return new Car()
{
Id = model.Id,
Brand = model.Brand,
Model = model.Model,
YearOfManuf = model.YearOfManuf,
Color = model.Color,
LicensePlate = model.LicensePlate,
RentalCostPerHour = model.RentalCostPerHour,
BranchId = model.BranchId,
};
}
public void Update(CarBindingModel model)
{
if (model == null)
{
return;
}
Brand = model.Brand;
Model = model.Model;
YearOfManuf = model.YearOfManuf;
Color = model.Color;
LicensePlate = model.LicensePlate;
RentalCostPerHour = model.RentalCostPerHour;
}
public CarViewModel GetViewModel => new()
{
Id = Id,
Brand = Brand,
Model = Model,
YearOfManuf = YearOfManuf,
Color = Color,
LicensePlate = LicensePlate,
RentalCostPerHour = RentalCostPerHour,
BranchId = BranchId,
BranchName = Branch == null ? string.Empty : Branch.Name,
};
}
}

View File

@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CarRentDatabase.Models;
using CarRentDataModels.Models;
using CarRentContracts.BindingModels;
using CarRentContracts.ViewModels;
namespace CarRentDatabase.Models
{
public class Client : IClientModel
{
[Required]
public string Name { get; set; } = string.Empty;
[Required]
public string Surname { get; set; } = string.Empty;
[Required]
public string PhoneNumber { get; set; } = string.Empty;
[Required]
public string Email { get; set; } = string.Empty;
[Required]
public string DriveLicenseNumber { get; set; } = string.Empty;
[Required]
public int Id { get; private set; }
[ForeignKey("ClientId")]
List<Rental> RentalClients { get; set; } = new();
public static Client? Create(ClientBindingModel model)
{
if (model == null)
{
return null;
}
return new Client()
{
Id = model.Id,
Name = model.Name,
Surname = model.Surname,
PhoneNumber = model.PhoneNumber,
Email = model.Email,
DriveLicenseNumber = model.DriveLicenseNumber,
};
}
public void Update(ClientBindingModel model)
{
if (model == null)
{
return;
}
Name = model.Name;
Surname = model.Surname;
PhoneNumber = model.PhoneNumber;
Email = model.Email;
DriveLicenseNumber = model.DriveLicenseNumber;
}
public ClientViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
Surname = Surname,
PhoneNumber = PhoneNumber,
Email = Email,
DriveLicenseNumber = DriveLicenseNumber,
};
}
}

View File

@ -0,0 +1,78 @@
using CarRentContracts.BindingModels;
using CarRentContracts.BusinessLogicContracts;
using CarRentContracts.ViewModels;
using CarRentDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentDatabase.Models
{
public class Rental : IRentalModel
{
[Required]
public DateTime StartDate { get; set; }
[Required]
public DateTime? EndDate { get; set; }
[Required]
public double RentalCost { get; set; }
public string? ReviewText { get; set; }
public int? ReviewRating { get ; set; }
[Required]
public int ClientId { get; set; }
[Required]
public int CarId { get; set; }
public int Id { get; private set; }
public virtual Car Car { get; set; }
public virtual Client Client { get; set; }
public static Rental? Create(RentalBindingModel? model)
{
if (model == null)
{
return null;
}
return new Rental()
{
Id = model.Id,
StartDate = model.StartDate,
EndDate = model.EndDate,
RentalCost = model.RentalCost,
ReviewText = model.ReviewText,
ReviewRating = model.ReviewRating,
CarId = model.CarId,
ClientId = model.ClientId,
};
}
public void Update(RentalBindingModel? model)
{
if (model == null)
{
return;
}
ReviewText = model.ReviewText;
ReviewRating = model.ReviewRating;
}
public RentalViewModel GetViewModel => new()
{
Id = Id,
ClientName = Client == null ? string.Empty : Client.Name,
ClientSurname = Client == null ? string.Empty : Client.Surname,
LicensePlate = Car == null ? string.Empty : Car.LicensePlate,
StartDate = StartDate,
EndDate = EndDate,
RentalCost = RentalCost,
ReviewText = ReviewText,
ReviewRating = ReviewRating,
ClientId = ClientId,
CarId = CarId,
};
}
}

6
CarRentView/App.config Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

View File

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{BB672625-9EB3-4B53-83B6-00CCF87286F7}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>CarRentView</RootNamespace>
<AssemblyName>CarRentView</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.DependencyInjection, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.DependencyInjection.7.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.7.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="FormMain.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormMain.Designer.cs">
<DependentUpon>FormMain.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CarRentBusinessLogic\CarRentBusinessLogic.csproj">
<Project>{be1510f5-bc13-45df-ad5e-09d22d29f316}</Project>
<Name>CarRentBusinessLogic</Name>
</ProjectReference>
<ProjectReference Include="..\CarRentContracts\CarRentContracts.csproj">
<Project>{442821e8-c13e-4fc8-92fb-43f59bcd60b2}</Project>
<Name>CarRentContracts</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

39
CarRentView/FormMain.Designer.cs generated Normal file
View File

@ -0,0 +1,39 @@
namespace CarRentView
{
partial class FormMain
{
/// <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 = "FormMain";
}
#endregion
}
}

20
CarRentView/FormMain.cs Normal file
View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CarRentView
{
public partial class FormMain : Form
{
public FormMain()
{
InitializeComponent();
}
}
}

43
CarRentView/Program.cs Normal file
View File

@ -0,0 +1,43 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using
namespace CarRent
{
internal static class Program
{
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
/// <summary>
/// Главная точка входа для приложения.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddTransient<IBranchStorage, BranchStorage>();
services.AddTransient<ICarStorage, CarStorage>();
services.AddTransient<IRentalStorage, RentalStorage>();
services.AddTransient<IClientStorage, ClientStorage>();
services.AddTransient<IBlankLogic, BlankLogic>();
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IDocumentLogic, DocumentLogic>();
services.AddTransient<IReportLogic, ReportLogic>();
services.AddTransient<FormMain>();
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Общие сведения об этой сборке предоставляются следующим набором
// набора атрибутов. Измените значения этих атрибутов для изменения сведений,
// связанных со сборкой.
[assembly: AssemblyTitle("CarRentView")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CarRentView")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
// COM, следует установить атрибут ComVisible в TRUE для этого типа.
[assembly: ComVisible(false)]
// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
[assembly: Guid("bb672625-9eb3-4b53-83b6-00ccf87286f7")]
// Сведения о версии сборки состоят из указанных ниже четырех значений:
//
// Основной номер версии
// Дополнительный номер версии
// Номер сборки
// Редакция
//
// Можно задать все значения или принять номера сборки и редакции по умолчанию
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программным средством.
// Версия среды выполнения: 4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильному поведению и будут утрачены, если
// код создан повторно.
// </auto-generated>
//------------------------------------------------------------------------------
namespace CarRentView.Properties
{
/// <summary>
/// Класс ресурсов со строгим типом для поиска локализованных строк и пр.
/// </summary>
// Этот класс был автоматически создан при помощи StronglyTypedResourceBuilder
// класс с помощью таких средств, как ResGen или Visual Studio.
// Для добавления или удаления члена измените файл .ResX, а затем перезапустите ResGen
// с параметром /str или заново постройте свой VS-проект.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Возврат кэшированного экземпляра ResourceManager, используемого этим классом.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CarRentView.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Переопределяет свойство CurrentUICulture текущего потока для всех
/// подстановки ресурсов с помощью этого класса ресурсов со строгим типом.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View File

@ -0,0 +1,117 @@
<?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.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: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" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</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" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace CarRentView.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl.AsyncInterfaces" version="7.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.DependencyInjection" version="7.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="7.0.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
</packages>

View File

@ -1,2 +0,0 @@
# SUBD