обычные действия
This commit is contained in:
parent
90186bb7a9
commit
19bfe37214
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Contracts\Contracts.csproj" />
|
<ProjectReference Include="..\Contracts\Contracts.csproj" />
|
||||||
<ProjectReference Include="..\DataBase\DataBase.csproj" />
|
<ProjectReference Include="..\MongoDB\MongoDB.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -100,10 +100,6 @@ namespace BusinessBL.BusinessBL
|
|||||||
{
|
{
|
||||||
throw new ArgumentNullException("Грузоподъемность должна быть больше 0", nameof(model.Tonnage));
|
throw new ArgumentNullException("Грузоподъемность должна быть больше 0", nameof(model.Tonnage));
|
||||||
}
|
}
|
||||||
if (model.StatusId <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Стутус должн быть ", nameof(model.StatusId));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,10 +96,10 @@ namespace BusinessLogic.BusinessLogic
|
|||||||
throw new ArgumentNullException("Нет названия ", nameof(model.Title));
|
throw new ArgumentNullException("Нет названия ", nameof(model.Title));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model.StatusId <= 0)
|
//if (model.StatusId <= 0)
|
||||||
{
|
//{
|
||||||
throw new ArgumentNullException("Стутус должн быть ", nameof(model.StatusId));
|
// throw new ArgumentNullException("Стутус должн быть ", nameof(model.StatusId));
|
||||||
}
|
// }
|
||||||
_logger.LogInformation("Car. CarName:{CarName}.Cost:{ Cost}. Id: { Id}", model.Title);
|
_logger.LogInformation("Car. CarName:{CarName}.Cost:{ Cost}. Id: { Id}", model.Title);
|
||||||
var element = _companyStorage.GetElement(new CompanySM
|
var element = _companyStorage.GetElement(new CompanySM
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,6 @@ using Contracts.BusinessLogic;
|
|||||||
using Contracts.SearchModel;
|
using Contracts.SearchModel;
|
||||||
using Contracts.Storage;
|
using Contracts.Storage;
|
||||||
using Contracts.ViewModels;
|
using Contracts.ViewModels;
|
||||||
using DataBase.Implements;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -101,10 +100,7 @@ namespace BusinessLogic.BusinessLogic
|
|||||||
{
|
{
|
||||||
throw new ArgumentNullException("Нет номера телефона", nameof(model.Phone));
|
throw new ArgumentNullException("Нет номера телефона", nameof(model.Phone));
|
||||||
}
|
}
|
||||||
if (model.StatusId <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Стутус должн быть ", nameof(model.StatusId));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Car. CarName:{CarName}.Cost:{ Cost}. Id: { Id}", model.Name);
|
_logger.LogInformation("Car. CarName:{CarName}.Cost:{ Cost}. Id: { Id}", model.Name);
|
||||||
var element = _humanStorage.GetElement(new HumanSM
|
var element = _humanStorage.GetElement(new HumanSM
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,6 @@ using Contracts.BusinessLogic;
|
|||||||
using Contracts.SearchModel;
|
using Contracts.SearchModel;
|
||||||
using Contracts.Storage;
|
using Contracts.Storage;
|
||||||
using Contracts.ViewModels;
|
using Contracts.ViewModels;
|
||||||
using DataBase.Implements;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -4,7 +4,6 @@ using Contracts.BusinessLogic;
|
|||||||
using Contracts.SearchModel;
|
using Contracts.SearchModel;
|
||||||
using Contracts.Storage;
|
using Contracts.Storage;
|
||||||
using Contracts.ViewModels;
|
using Contracts.ViewModels;
|
||||||
using DataBase.Implements;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -97,20 +96,12 @@ namespace BusinessLogic.BusinessLogic
|
|||||||
{
|
{
|
||||||
throw new ArgumentNullException("Нет длины маршрута", nameof(model.Length));
|
throw new ArgumentNullException("Нет длины маршрута", nameof(model.Length));
|
||||||
}
|
}
|
||||||
if (model.PlaceStart <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("нет т-ки отправления", nameof(model.PlaceStart));
|
|
||||||
}
|
|
||||||
if (model.PlaceStart <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("нет т-ки назначения", nameof(model.PlaceEnd));
|
|
||||||
}
|
|
||||||
|
|
||||||
var element = _routeStorage.GetElement(new RouteSM
|
var element = _routeStorage.GetElement(new RouteSM
|
||||||
{
|
{
|
||||||
Id = model.Id,
|
Title = model.Title,
|
||||||
Start = model.PlaceStart,
|
|
||||||
End = model.PlaceEnd
|
|
||||||
});
|
});
|
||||||
if (element != null && element.Id != model.Id)
|
if (element != null && element.Id != model.Id)
|
||||||
{
|
{
|
||||||
|
@ -86,22 +86,7 @@ namespace BusinessLogic.BusinessLogic
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (model.CarId <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет машины", nameof(model.CarId));
|
|
||||||
}
|
|
||||||
if (model.CompanyId <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("нет заказчкика", nameof(model.CompanyId));
|
|
||||||
}
|
|
||||||
if (model.HumanId <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("нет водилы", nameof(model.HumanId));
|
|
||||||
}
|
|
||||||
if (model.HumanId <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("нет водилы", nameof(model.HumanId));
|
|
||||||
}
|
|
||||||
if (!model.DateEnd.HasValue)
|
if (!model.DateEnd.HasValue)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("нет дедлайна", nameof(model.HumanId));
|
throw new ArgumentNullException("нет дедлайна", nameof(model.HumanId));
|
||||||
|
@ -10,7 +10,8 @@ namespace Contracts.BindingModels
|
|||||||
public class CarBM : ICar
|
public class CarBM : ICar
|
||||||
{
|
{
|
||||||
public string Model { get; set; } = string.Empty;
|
public string Model { get; set; } = string.Empty;
|
||||||
|
public string oldModel { get; set; } = string.Empty ;
|
||||||
|
public string number { get; set; } = string.Empty;
|
||||||
public int Tonnage { get; set; }
|
public int Tonnage { get; set; }
|
||||||
|
|
||||||
public int? StatusId { get; set; }
|
public int? StatusId { get; set; }
|
||||||
|
@ -10,7 +10,7 @@ namespace Contracts.BindingModels
|
|||||||
public class CompanyBM : ICompany
|
public class CompanyBM : ICompany
|
||||||
{
|
{
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
|
public string oldTitle { get; set; } = string.Empty;
|
||||||
public int? StatusId {get; set; }
|
public int? StatusId {get; set; }
|
||||||
|
|
||||||
public string? StatusTitle { get; set; } = string.Empty;
|
public string? StatusTitle { get; set; } = string.Empty;
|
||||||
|
@ -10,7 +10,7 @@ namespace Contracts.BindingModels
|
|||||||
public class HumanBM : IHuman
|
public class HumanBM : IHuman
|
||||||
{
|
{
|
||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
|
public string oldName { get; set; } = string.Empty;
|
||||||
public string Phone { get; set; } = string.Empty;
|
public string Phone { get; set; } = string.Empty;
|
||||||
|
|
||||||
public int? StatusId { get; set; }
|
public int? StatusId { get; set; }
|
||||||
|
@ -10,7 +10,7 @@ namespace Contracts.BindingModels
|
|||||||
public class PlaceBM : IPlace
|
public class PlaceBM : IPlace
|
||||||
{
|
{
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
|
public string oldTitle { get; set; } = string.Empty;
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,13 +10,13 @@ namespace Contracts.BindingModels
|
|||||||
public class RouteBM : IRoute
|
public class RouteBM : IRoute
|
||||||
{
|
{
|
||||||
public int? PlaceStart { get; set; }
|
public int? PlaceStart { get; set; }
|
||||||
|
public string PlaceStartName { get; set; } = string.Empty;
|
||||||
public int? PlaceEnd { get; set; }
|
public int? PlaceEnd { get; set; }
|
||||||
|
public string PlaceEndName { get; set; } = string.Empty;
|
||||||
public int Length { get; set; }
|
public int Length { get; set; }
|
||||||
|
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
|
public string oldTitle { get; set; } = string.Empty;
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ namespace Contracts.BindingModels
|
|||||||
public class StatusBM : IStatus
|
public class StatusBM : IStatus
|
||||||
{
|
{
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
|
public string oldTitle { get; set; } = string.Empty;
|
||||||
public int Id {get; set;}
|
public int Id {get; set;}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,5 +12,6 @@ namespace Contracts.SearchModel
|
|||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
public int? Start { get; set; }
|
public int? Start { get; set; }
|
||||||
public int? End { get; set; }
|
public int? End { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ namespace Contracts.ViewModels
|
|||||||
public class CarVM : ICar
|
public class CarVM : ICar
|
||||||
{
|
{
|
||||||
[DisplayName("Номер")]
|
[DisplayName("Номер")]
|
||||||
|
public string number { get; set; }
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Модель")]
|
[DisplayName("Модель")]
|
||||||
public string Model { get; set; } = string.Empty;
|
public string Model { get; set; } = string.Empty;
|
||||||
|
11
Subd/Forms/FormCar.Designer.cs
generated
11
Subd/Forms/FormCar.Designer.cs
generated
@ -40,6 +40,7 @@
|
|||||||
this.label1 = new System.Windows.Forms.Label();
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
this.Timelabel = new System.Windows.Forms.Label();
|
this.Timelabel = new System.Windows.Forms.Label();
|
||||||
this.label2 = new System.Windows.Forms.Label();
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
|
this.NumberBox1 = new System.Windows.Forms.TextBox();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// ModelLabel
|
// ModelLabel
|
||||||
@ -153,11 +154,20 @@
|
|||||||
this.label2.TabIndex = 12;
|
this.label2.TabIndex = 12;
|
||||||
this.label2.Text = "мс";
|
this.label2.Text = "мс";
|
||||||
//
|
//
|
||||||
|
// NumberBox1
|
||||||
|
//
|
||||||
|
this.NumberBox1.Location = new System.Drawing.Point(241, 60);
|
||||||
|
this.NumberBox1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.NumberBox1.Name = "NumberBox1";
|
||||||
|
this.NumberBox1.Size = new System.Drawing.Size(100, 27);
|
||||||
|
this.NumberBox1.TabIndex = 13;
|
||||||
|
//
|
||||||
// FormCar
|
// FormCar
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(375, 305);
|
this.ClientSize = new System.Drawing.Size(375, 305);
|
||||||
|
this.Controls.Add(this.NumberBox1);
|
||||||
this.Controls.Add(this.label2);
|
this.Controls.Add(this.label2);
|
||||||
this.Controls.Add(this.Timelabel);
|
this.Controls.Add(this.Timelabel);
|
||||||
this.Controls.Add(this.label1);
|
this.Controls.Add(this.label1);
|
||||||
@ -193,5 +203,6 @@
|
|||||||
private Label label1;
|
private Label label1;
|
||||||
private Label Timelabel;
|
private Label Timelabel;
|
||||||
private Label label2;
|
private Label label2;
|
||||||
|
private TextBox NumberBox1;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -84,6 +84,7 @@ namespace Forms
|
|||||||
{
|
{
|
||||||
Id = _id ?? 0,
|
Id = _id ?? 0,
|
||||||
Model = ModelTextBox.Text,
|
Model = ModelTextBox.Text,
|
||||||
|
number = NumberBox1.Text,
|
||||||
Tonnage = Convert.ToInt32(TonnageTextBox.Text),
|
Tonnage = Convert.ToInt32(TonnageTextBox.Text),
|
||||||
StatusId = Convert.ToInt32(StatuscomboBox.SelectedValue),
|
StatusId = Convert.ToInt32(StatuscomboBox.SelectedValue),
|
||||||
StatusTitle = StatuscomboBox.Text,
|
StatusTitle = StatuscomboBox.Text,
|
||||||
|
@ -90,14 +90,14 @@ namespace Forms
|
|||||||
{
|
{
|
||||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
string id = (DataGridView.SelectedRows[0].Cells["number"].Value.ToString());
|
||||||
_logger.LogInformation("Удаление изделия");
|
_logger.LogInformation("Удаление изделия");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!_logic.Delete(new CarBM
|
if (!_logic.Delete(new CarBM
|
||||||
{
|
{
|
||||||
Id = id
|
number = id
|
||||||
}))
|
}))
|
||||||
{
|
{
|
||||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||||
|
@ -90,14 +90,14 @@ namespace Forms
|
|||||||
{
|
{
|
||||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
string id = (DataGridView.SelectedRows[0].Cells["Title"].Value.ToString());
|
||||||
_logger.LogInformation("Удаление изделия");
|
_logger.LogInformation("Удаление изделия");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!_logic.Delete(new CompanyBM
|
if (!_logic.Delete(new CompanyBM
|
||||||
{
|
{
|
||||||
Id = id
|
Title = id
|
||||||
}))
|
}))
|
||||||
{
|
{
|
||||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||||
|
11
Subd/Forms/FormHuman.Designer.cs
generated
11
Subd/Forms/FormHuman.Designer.cs
generated
@ -39,6 +39,7 @@
|
|||||||
this.AddTenbutton = new System.Windows.Forms.Button();
|
this.AddTenbutton = new System.Windows.Forms.Button();
|
||||||
this.Timelabel = new System.Windows.Forms.Label();
|
this.Timelabel = new System.Windows.Forms.Label();
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.NumbertextBox = new System.Windows.Forms.TextBox();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// ComponentNameLabel
|
// ComponentNameLabel
|
||||||
@ -143,11 +144,20 @@
|
|||||||
this.label1.TabIndex = 11;
|
this.label1.TabIndex = 11;
|
||||||
this.label1.Text = "mc";
|
this.label1.Text = "mc";
|
||||||
//
|
//
|
||||||
|
// NumbertextBox
|
||||||
|
//
|
||||||
|
this.NumbertextBox.Location = new System.Drawing.Point(272, 64);
|
||||||
|
this.NumbertextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.NumbertextBox.Name = "NumbertextBox";
|
||||||
|
this.NumbertextBox.Size = new System.Drawing.Size(69, 27);
|
||||||
|
this.NumbertextBox.TabIndex = 12;
|
||||||
|
//
|
||||||
// FormHuman
|
// FormHuman
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(375, 318);
|
this.ClientSize = new System.Drawing.Size(375, 318);
|
||||||
|
this.Controls.Add(this.NumbertextBox);
|
||||||
this.Controls.Add(this.label1);
|
this.Controls.Add(this.label1);
|
||||||
this.Controls.Add(this.Timelabel);
|
this.Controls.Add(this.Timelabel);
|
||||||
this.Controls.Add(this.AddTenbutton);
|
this.Controls.Add(this.AddTenbutton);
|
||||||
@ -181,5 +191,6 @@
|
|||||||
private Button AddTenbutton;
|
private Button AddTenbutton;
|
||||||
private Label Timelabel;
|
private Label Timelabel;
|
||||||
private Label label1;
|
private Label label1;
|
||||||
|
private TextBox NumbertextBox;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -82,7 +82,7 @@ namespace Forms
|
|||||||
{
|
{
|
||||||
var model = new HumanBM
|
var model = new HumanBM
|
||||||
{
|
{
|
||||||
Id = _id ?? 0,
|
Id = Convert.ToInt32(NumbertextBox.Text),
|
||||||
Name = FIOTextBox.Text,
|
Name = FIOTextBox.Text,
|
||||||
Phone = PhoneTextBox.Text,
|
Phone = PhoneTextBox.Text,
|
||||||
StatusId = Convert.ToInt32(StatuscomboBox.SelectedValue),
|
StatusId = Convert.ToInt32(StatuscomboBox.SelectedValue),
|
||||||
|
@ -90,14 +90,14 @@ namespace Forms
|
|||||||
{
|
{
|
||||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
string id = DataGridView.SelectedRows[0].Cells["Phone"].Value.ToString();
|
||||||
_logger.LogInformation("Удаление изделия");
|
_logger.LogInformation("Удаление изделия");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!_logic.Delete(new HumanBM
|
if (!_logic.Delete(new HumanBM
|
||||||
{
|
{
|
||||||
Id = id
|
Phone = id
|
||||||
}))
|
}))
|
||||||
{
|
{
|
||||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||||
|
26
Subd/Forms/FormMain.Designer.cs
generated
26
Subd/Forms/FormMain.Designer.cs
generated
@ -41,6 +41,7 @@
|
|||||||
this.DataGridView = new System.Windows.Forms.DataGridView();
|
this.DataGridView = new System.Windows.Forms.DataGridView();
|
||||||
this.CreateOrderButton = new System.Windows.Forms.Button();
|
this.CreateOrderButton = new System.Windows.Forms.Button();
|
||||||
this.UpdateListButton = new System.Windows.Forms.Button();
|
this.UpdateListButton = new System.Windows.Forms.Button();
|
||||||
|
this.статусToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.MenuStrip.SuspendLayout();
|
this.MenuStrip.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
@ -65,7 +66,8 @@
|
|||||||
this.КомпонентыToolStripMenuItem,
|
this.КомпонентыToolStripMenuItem,
|
||||||
this.компанииToolStripMenuItem,
|
this.компанииToolStripMenuItem,
|
||||||
this.маршрутыToolStripMenuItem,
|
this.маршрутыToolStripMenuItem,
|
||||||
this.местаToolStripMenuItem});
|
this.местаToolStripMenuItem,
|
||||||
|
this.статусToolStripMenuItem});
|
||||||
this.СправочникиToolStripMenuItem.Name = "СправочникиToolStripMenuItem";
|
this.СправочникиToolStripMenuItem.Name = "СправочникиToolStripMenuItem";
|
||||||
this.СправочникиToolStripMenuItem.Size = new System.Drawing.Size(117, 24);
|
this.СправочникиToolStripMenuItem.Size = new System.Drawing.Size(117, 24);
|
||||||
this.СправочникиToolStripMenuItem.Text = "Cправочники";
|
this.СправочникиToolStripMenuItem.Text = "Cправочники";
|
||||||
@ -73,35 +75,35 @@
|
|||||||
// ИзделияToolStripMenuItem
|
// ИзделияToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.ИзделияToolStripMenuItem.Name = "ИзделияToolStripMenuItem";
|
this.ИзделияToolStripMenuItem.Name = "ИзделияToolStripMenuItem";
|
||||||
this.ИзделияToolStripMenuItem.Size = new System.Drawing.Size(167, 26);
|
this.ИзделияToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||||
this.ИзделияToolStripMenuItem.Text = "Машины";
|
this.ИзделияToolStripMenuItem.Text = "Машины";
|
||||||
this.ИзделияToolStripMenuItem.Click += new System.EventHandler(this.МашиныToolStripMenuItem_Click);
|
this.ИзделияToolStripMenuItem.Click += new System.EventHandler(this.МашиныToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// КомпонентыToolStripMenuItem
|
// КомпонентыToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.КомпонентыToolStripMenuItem.Name = "КомпонентыToolStripMenuItem";
|
this.КомпонентыToolStripMenuItem.Name = "КомпонентыToolStripMenuItem";
|
||||||
this.КомпонентыToolStripMenuItem.Size = new System.Drawing.Size(167, 26);
|
this.КомпонентыToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||||
this.КомпонентыToolStripMenuItem.Text = "Водители";
|
this.КомпонентыToolStripMenuItem.Text = "Водители";
|
||||||
this.КомпонентыToolStripMenuItem.Click += new System.EventHandler(this.ВодителиToolStripMenuItem_Click);
|
this.КомпонентыToolStripMenuItem.Click += new System.EventHandler(this.ВодителиToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// компанииToolStripMenuItem
|
// компанииToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.компанииToolStripMenuItem.Name = "компанииToolStripMenuItem";
|
this.компанииToolStripMenuItem.Name = "компанииToolStripMenuItem";
|
||||||
this.компанииToolStripMenuItem.Size = new System.Drawing.Size(167, 26);
|
this.компанииToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||||
this.компанииToolStripMenuItem.Text = "Компании";
|
this.компанииToolStripMenuItem.Text = "Компании";
|
||||||
this.компанииToolStripMenuItem.Click += new System.EventHandler(this.компанииToolStripMenuItem_Click);
|
this.компанииToolStripMenuItem.Click += new System.EventHandler(this.компанииToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// маршрутыToolStripMenuItem
|
// маршрутыToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.маршрутыToolStripMenuItem.Name = "маршрутыToolStripMenuItem";
|
this.маршрутыToolStripMenuItem.Name = "маршрутыToolStripMenuItem";
|
||||||
this.маршрутыToolStripMenuItem.Size = new System.Drawing.Size(167, 26);
|
this.маршрутыToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||||
this.маршрутыToolStripMenuItem.Text = "Маршруты";
|
this.маршрутыToolStripMenuItem.Text = "Маршруты";
|
||||||
this.маршрутыToolStripMenuItem.Click += new System.EventHandler(this.маршрутыToolStripMenuItem_Click);
|
this.маршрутыToolStripMenuItem.Click += new System.EventHandler(this.маршрутыToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// местаToolStripMenuItem
|
// местаToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.местаToolStripMenuItem.Name = "местаToolStripMenuItem";
|
this.местаToolStripMenuItem.Name = "местаToolStripMenuItem";
|
||||||
this.местаToolStripMenuItem.Size = new System.Drawing.Size(167, 26);
|
this.местаToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||||
this.местаToolStripMenuItem.Text = "Места";
|
this.местаToolStripMenuItem.Text = "Места";
|
||||||
this.местаToolStripMenuItem.Click += new System.EventHandler(this.местаToolStripMenuItem_Click);
|
this.местаToolStripMenuItem.Click += new System.EventHandler(this.местаToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
@ -117,14 +119,14 @@
|
|||||||
// водителиToolStripMenuItem
|
// водителиToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.водителиToolStripMenuItem.Name = "водителиToolStripMenuItem";
|
this.водителиToolStripMenuItem.Name = "водителиToolStripMenuItem";
|
||||||
this.водителиToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
this.водителиToolStripMenuItem.Size = new System.Drawing.Size(165, 26);
|
||||||
this.водителиToolStripMenuItem.Text = "Водители";
|
this.водителиToolStripMenuItem.Text = "Водители";
|
||||||
this.водителиToolStripMenuItem.Click += new System.EventHandler(this.водителиToolStripMenuItem_Click_1);
|
this.водителиToolStripMenuItem.Click += new System.EventHandler(this.водителиToolStripMenuItem_Click_1);
|
||||||
//
|
//
|
||||||
// компанииToolStripMenuItem1
|
// компанииToolStripMenuItem1
|
||||||
//
|
//
|
||||||
this.компанииToolStripMenuItem1.Name = "компанииToolStripMenuItem1";
|
this.компанииToolStripMenuItem1.Name = "компанииToolStripMenuItem1";
|
||||||
this.компанииToolStripMenuItem1.Size = new System.Drawing.Size(224, 26);
|
this.компанииToolStripMenuItem1.Size = new System.Drawing.Size(165, 26);
|
||||||
this.компанииToolStripMenuItem1.Text = "Компании";
|
this.компанииToolStripMenuItem1.Text = "Компании";
|
||||||
this.компанииToolStripMenuItem1.Click += new System.EventHandler(this.компанииToolStripMenuItem1_Click);
|
this.компанииToolStripMenuItem1.Click += new System.EventHandler(this.компанииToolStripMenuItem1_Click);
|
||||||
//
|
//
|
||||||
@ -161,6 +163,13 @@
|
|||||||
this.UpdateListButton.UseVisualStyleBackColor = true;
|
this.UpdateListButton.UseVisualStyleBackColor = true;
|
||||||
this.UpdateListButton.Click += new System.EventHandler(this.UpdateListButton_Click);
|
this.UpdateListButton.Click += new System.EventHandler(this.UpdateListButton_Click);
|
||||||
//
|
//
|
||||||
|
// статусToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.статусToolStripMenuItem.Name = "статусToolStripMenuItem";
|
||||||
|
this.статусToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||||
|
this.статусToolStripMenuItem.Text = "Статус";
|
||||||
|
this.статусToolStripMenuItem.Click += new System.EventHandler(this.статусToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
@ -198,5 +207,6 @@
|
|||||||
private ToolStripMenuItem отчетыToolStripMenuItem;
|
private ToolStripMenuItem отчетыToolStripMenuItem;
|
||||||
private ToolStripMenuItem водителиToolStripMenuItem;
|
private ToolStripMenuItem водителиToolStripMenuItem;
|
||||||
private ToolStripMenuItem компанииToolStripMenuItem1;
|
private ToolStripMenuItem компанииToolStripMenuItem1;
|
||||||
|
private ToolStripMenuItem статусToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -50,6 +50,7 @@ namespace Forms
|
|||||||
DataGridView.Columns["RouteId"].Visible = false;
|
DataGridView.Columns["RouteId"].Visible = false;
|
||||||
DataGridView.Columns["RouteName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
DataGridView.Columns["RouteName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
DataGridView.Columns["Id"].Visible = false;
|
DataGridView.Columns["Id"].Visible = false;
|
||||||
|
DataGridView.Columns["Km"].Visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation("Загрузка ");
|
_logger.LogInformation("Загрузка ");
|
||||||
@ -148,5 +149,15 @@ namespace Forms
|
|||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void статусToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormStatuses));
|
||||||
|
|
||||||
|
if (service is FormStatuses form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,14 +90,14 @@ namespace Forms
|
|||||||
{
|
{
|
||||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
string id = (DataGridView.SelectedRows[0].Cells["Title"].Value.ToString());
|
||||||
_logger.LogInformation("Удаление изделия");
|
_logger.LogInformation("Удаление изделия");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!_logic.Delete(new PlaceBM
|
if (!_logic.Delete(new PlaceBM
|
||||||
{
|
{
|
||||||
Id = id
|
Title = id
|
||||||
}))
|
}))
|
||||||
{
|
{
|
||||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||||
|
@ -84,7 +84,9 @@ namespace Forms
|
|||||||
|
|
||||||
Length = Convert.ToInt32(LengthTextBox.Text),
|
Length = Convert.ToInt32(LengthTextBox.Text),
|
||||||
PlaceStart = Convert.ToInt32(StartcomboBox.SelectedValue),
|
PlaceStart = Convert.ToInt32(StartcomboBox.SelectedValue),
|
||||||
|
PlaceStartName = StartcomboBox.SelectedValue.ToString(),
|
||||||
PlaceEnd = Convert.ToInt32(EndcomboBox.SelectedValue),
|
PlaceEnd = Convert.ToInt32(EndcomboBox.SelectedValue),
|
||||||
|
PlaceEndName = EndcomboBox.SelectedValue.ToString(),
|
||||||
Title = StartcomboBox.Text + " - " + EndcomboBox.Text
|
Title = StartcomboBox.Text + " - " + EndcomboBox.Text
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -91,14 +91,14 @@ namespace Forms
|
|||||||
{
|
{
|
||||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
string id = DataGridView.SelectedRows[0].Cells["Title"].Value.ToString();
|
||||||
_logger.LogInformation("Удаление изделия");
|
_logger.LogInformation("Удаление изделия");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!_logic.Delete(new RouteBM
|
if (!_logic.Delete(new RouteBM
|
||||||
{
|
{
|
||||||
Id = id
|
Title = id
|
||||||
}))
|
}))
|
||||||
{
|
{
|
||||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||||
|
@ -91,13 +91,14 @@ namespace Forms
|
|||||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
string title = DataGridView.SelectedRows[0].Cells["Title"].Value.ToString();
|
||||||
_logger.LogInformation("Удаление изделия");
|
_logger.LogInformation("Удаление изделия");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!_logic.Delete(new StatusBM
|
if (!_logic.Delete(new StatusBM
|
||||||
{
|
{
|
||||||
Id = id
|
Title = title
|
||||||
}))
|
}))
|
||||||
{
|
{
|
||||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using Contracts.BindingModels;
|
using Contracts.BindingModels;
|
||||||
using Contracts.BusinessLogic;
|
using Contracts.BusinessLogic;
|
||||||
using Contracts.SearchModel;
|
using Contracts.SearchModel;
|
||||||
using DataBase;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using NLog.LayoutRenderers;
|
using NLog.LayoutRenderers;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -40,31 +39,31 @@ namespace Forms
|
|||||||
if (routes != null)
|
if (routes != null)
|
||||||
{
|
{
|
||||||
RoutecomboBox.DisplayMember = "Title";
|
RoutecomboBox.DisplayMember = "Title";
|
||||||
RoutecomboBox.ValueMember = "Id";
|
RoutecomboBox.ValueMember = "Title";
|
||||||
RoutecomboBox.DataSource = routes;
|
RoutecomboBox.DataSource = routes;
|
||||||
RoutecomboBox.SelectedItem = null;
|
RoutecomboBox.SelectedItem = null;
|
||||||
}
|
}
|
||||||
var cars = _carLogic.ReadList(new CarSM { StatusId = 1});
|
var cars = _carLogic.ReadList(null);
|
||||||
if (cars != null)
|
if (cars != null)
|
||||||
{
|
{
|
||||||
CarcomboBox.DisplayMember = "Model";
|
CarcomboBox.DisplayMember = "Model";
|
||||||
CarcomboBox.ValueMember = "Id";
|
CarcomboBox.ValueMember = "Model";
|
||||||
CarcomboBox.DataSource = cars;
|
CarcomboBox.DataSource = cars;
|
||||||
CarcomboBox.SelectedItem = null;
|
CarcomboBox.SelectedItem = null;
|
||||||
}
|
}
|
||||||
var companys = _companyLogic.ReadList(new CompanySM { StatusId =1});
|
var companys = _companyLogic.ReadList(null);
|
||||||
if (companys != null)
|
if (companys != null)
|
||||||
{
|
{
|
||||||
CompanycomboBox.DisplayMember = "Title";
|
CompanycomboBox.DisplayMember = "Title";
|
||||||
CompanycomboBox.ValueMember = "Id";
|
CompanycomboBox.ValueMember = "Title";
|
||||||
CompanycomboBox.DataSource = companys;
|
CompanycomboBox.DataSource = companys;
|
||||||
CompanycomboBox.SelectedItem = null;
|
CompanycomboBox.SelectedItem = null;
|
||||||
}
|
}
|
||||||
var humans = _humanLogic.ReadList(new HumanSM { StatusId=1});
|
var humans = _humanLogic.ReadList(null);
|
||||||
if (humans != null)
|
if (humans != null)
|
||||||
{
|
{
|
||||||
HumancomboBox.DisplayMember = "Name";
|
HumancomboBox.DisplayMember = "Name";
|
||||||
HumancomboBox.ValueMember = "Id";
|
HumancomboBox.ValueMember = "Name";
|
||||||
HumancomboBox.DataSource = humans;
|
HumancomboBox.DataSource = humans;
|
||||||
HumancomboBox.SelectedItem = null;
|
HumancomboBox.SelectedItem = null;
|
||||||
}
|
}
|
||||||
@ -92,10 +91,10 @@ namespace Forms
|
|||||||
var model = new VoyageBM
|
var model = new VoyageBM
|
||||||
{
|
{
|
||||||
Id = _id ?? 0,
|
Id = _id ?? 0,
|
||||||
RouteId = Convert.ToInt32(RoutecomboBox.SelectedValue),
|
RouteName = (RoutecomboBox.SelectedValue.ToString()),
|
||||||
CarId = Convert.ToInt32(CarcomboBox.SelectedValue),
|
CarName = (CarcomboBox.SelectedValue.ToString()),
|
||||||
HumanId = Convert.ToInt32(HumancomboBox.SelectedValue),
|
HumanName = (HumancomboBox.SelectedValue.ToString()),
|
||||||
CompanyId = Convert.ToInt32(CompanycomboBox.SelectedValue),
|
CompanyName = CompanycomboBox.SelectedValue.ToString(),
|
||||||
DateStart = DateOnly.FromDateTime(DateTime.SpecifyKind(dateTimePickerFrom.Value, DateTimeKind.Utc)),
|
DateStart = DateOnly.FromDateTime(DateTime.SpecifyKind(dateTimePickerFrom.Value, DateTimeKind.Utc)),
|
||||||
DateEnd = DateOnly.FromDateTime(DateTime.SpecifyKind(dateTimePickerTo.Value, DateTimeKind.Utc)),
|
DateEnd = DateOnly.FromDateTime(DateTime.SpecifyKind(dateTimePickerTo.Value, DateTimeKind.Utc)),
|
||||||
};
|
};
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\BusinessLogic\BusinessLogic.csproj" />
|
<ProjectReference Include="..\BusinessLogic\BusinessLogic.csproj" />
|
||||||
<ProjectReference Include="..\DataBase\DataBase.csproj" />
|
<ProjectReference Include="..\MongoDB\MongoDB.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -3,9 +3,9 @@ using BusinessBL.BusinessBL;
|
|||||||
using BusinessLogic.BusinessLogic;
|
using BusinessLogic.BusinessLogic;
|
||||||
using Contracts.BusinessLogic;
|
using Contracts.BusinessLogic;
|
||||||
using Contracts.Storage;
|
using Contracts.Storage;
|
||||||
using DataBase.Implements;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using MongoDB;
|
||||||
using NLog.Extensions.Logging;
|
using NLog.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
14
Subd/GoingToMongo/GoingToMongo.csproj
Normal file
14
Subd/GoingToMongo/GoingToMongo.csproj
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\MongoDB\MongoDB.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
15
Subd/GoingToMongo/Program.cs
Normal file
15
Subd/GoingToMongo/Program.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// See https://aka.ms/new-console-template for more information
|
||||||
|
using MongoDB;
|
||||||
|
using MongoDB.Driver;
|
||||||
|
using System.Data;
|
||||||
|
|
||||||
|
MongoClient context = MongoDateBase.getInstance().client;
|
||||||
|
foreach (var datab in context.ListDatabaseNames().ToList())
|
||||||
|
{
|
||||||
|
Console.WriteLine(datab);
|
||||||
|
}
|
||||||
|
IMongoDatabase logistic = context.GetDatabase("logistic");
|
||||||
|
foreach(var collection in logistic.ListCollections().ToList())
|
||||||
|
{
|
||||||
|
Console.WriteLine(collection);
|
||||||
|
}
|
122
Subd/MongoDB/CarStorage.cs
Normal file
122
Subd/MongoDB/CarStorage.cs
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.SearchModel;
|
||||||
|
using Contracts.Storage;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using MongoDB.Bson;
|
||||||
|
using MongoDB.Driver;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MongoDB
|
||||||
|
{
|
||||||
|
public class CarStorage : ICarStorage
|
||||||
|
{
|
||||||
|
public MongoClient contex;
|
||||||
|
public CarStorage()
|
||||||
|
{
|
||||||
|
contex = MongoDateBase.getInstance().client;
|
||||||
|
}
|
||||||
|
public CarVM? Delete(CarBM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Car");
|
||||||
|
var res = collection.FindOneAndDelete(new BsonDocument("number", model.number));
|
||||||
|
if (res == null)
|
||||||
|
return null;
|
||||||
|
return new CarVM
|
||||||
|
{
|
||||||
|
Model = res["model"].ToString(),
|
||||||
|
number = res["number"].ToString(),
|
||||||
|
StatusTitle = res["Status"].ToString(),
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public CarVM? GetElement(CarSM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Car");
|
||||||
|
BsonDocument car = collection.Find(new BsonDocument("number", model.Id)).FirstOrDefault();
|
||||||
|
if (car == null)
|
||||||
|
return null;
|
||||||
|
return new CarVM
|
||||||
|
{
|
||||||
|
Model = car["name"].ToString(),
|
||||||
|
number = car["phone"].ToString(),
|
||||||
|
Tonnage = car["tonnage"].ToInt32(),
|
||||||
|
StatusTitle = car["Status"].ToString()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CarVM> GetFilteredList(CarSM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Car");
|
||||||
|
List<BsonDocument> cars = collection.Find(new BsonDocument { { "$regex", $"^.{model.Model}.$" } }).ToList();
|
||||||
|
List<CarVM> res = new List<CarVM>();
|
||||||
|
foreach (var car in cars)
|
||||||
|
{
|
||||||
|
res.Add(new CarVM
|
||||||
|
{
|
||||||
|
Model = car["name"].ToString(),
|
||||||
|
number = car["phone"].ToString(),
|
||||||
|
Tonnage = car["tonnage"].ToInt32(),
|
||||||
|
StatusTitle = car["Status"].ToString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CarVM> GetFullList()
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Car");
|
||||||
|
List<BsonDocument> cars = collection.Find(new BsonDocument()).ToList();
|
||||||
|
List<CarVM> res = new List<CarVM>();
|
||||||
|
foreach (var car in cars)
|
||||||
|
{
|
||||||
|
res.Add(new CarVM
|
||||||
|
{
|
||||||
|
Model = car["model"].ToString(),
|
||||||
|
number = car["number"].ToString(),
|
||||||
|
Tonnage = car["tonnage"].ToInt32(),
|
||||||
|
StatusTitle = car["Status"].ToString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CarVM? Insert(CarBM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Car");
|
||||||
|
BsonDocument car = new BsonDocument { { "number", model.number }, { "model", model.Model }, { "Status", model.StatusTitle }, { "tonnage", model.Tonnage } };
|
||||||
|
collection.InsertOne(car);
|
||||||
|
return new CarVM {
|
||||||
|
Model = car["model"].ToString(),
|
||||||
|
number = car["number"].ToString(),
|
||||||
|
Tonnage = car["tonnage"].ToInt32(),
|
||||||
|
StatusTitle = car["Status"].ToString()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public CarVM? Update(CarBM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Car");
|
||||||
|
var result = collection.UpdateOneAsync(new BsonDocument("name", model.oldModel), new BsonDocument("$set", new BsonDocument("name", model.Model)));
|
||||||
|
if (result == null)
|
||||||
|
return null;
|
||||||
|
return new CarVM
|
||||||
|
{
|
||||||
|
Model = model.Model,
|
||||||
|
StatusTitle = model.StatusTitle,
|
||||||
|
Tonnage = model.Tonnage,
|
||||||
|
number = model.number
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
107
Subd/MongoDB/CompanyStorage.cs
Normal file
107
Subd/MongoDB/CompanyStorage.cs
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.SearchModel;
|
||||||
|
using Contracts.Storage;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using MongoDB.Bson;
|
||||||
|
using MongoDB.Driver;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MongoDB
|
||||||
|
{
|
||||||
|
public class CompanyStorage : ICompanyStorage
|
||||||
|
{
|
||||||
|
public MongoClient contex;
|
||||||
|
public CompanyStorage()
|
||||||
|
{
|
||||||
|
contex = MongoDateBase.getInstance().client;
|
||||||
|
}
|
||||||
|
public CompanyVM? Delete(CompanyBM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Company");
|
||||||
|
var res = collection.FindOneAndDelete(new BsonDocument("name", model.Title));
|
||||||
|
if (res == null)
|
||||||
|
return null;
|
||||||
|
return new CompanyVM
|
||||||
|
{
|
||||||
|
Title = res["name"].ToString(),
|
||||||
|
StatusTitle = res["Status"].ToString()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompanyVM? GetElement(CompanySM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Company");
|
||||||
|
BsonDocument company = collection.Find(new BsonDocument("name", model.Title)).FirstOrDefault();
|
||||||
|
if (company == null)
|
||||||
|
return null;
|
||||||
|
return new CompanyVM
|
||||||
|
{
|
||||||
|
Title = company["name"].ToString(),
|
||||||
|
StatusTitle = company["Status"].ToString()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CompanyVM> GetFilteredList(CompanySM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Company");
|
||||||
|
List<BsonDocument> statuses = collection.Find(new BsonDocument { { "$regex",$"^.{model.Title}.$"} }).ToList();
|
||||||
|
List<CompanyVM> res = new List<CompanyVM>();
|
||||||
|
foreach (var status in statuses)
|
||||||
|
{
|
||||||
|
res.Add(new CompanyVM
|
||||||
|
{
|
||||||
|
Title = status["name"].ToString(),
|
||||||
|
StatusTitle = status["Status"].ToString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CompanyVM> GetFullList()
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Company");
|
||||||
|
List<BsonDocument> statuses = collection.Find(new BsonDocument()).ToList();
|
||||||
|
List<CompanyVM> res = new List<CompanyVM>();
|
||||||
|
foreach (var status in statuses)
|
||||||
|
{
|
||||||
|
res.Add(new CompanyVM
|
||||||
|
{
|
||||||
|
Title = status["name"].ToString(),
|
||||||
|
StatusTitle = status["Status"].ToString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompanyVM? Insert(CompanyBM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Company");
|
||||||
|
BsonDocument status = new BsonDocument { { "name", model.Title },{"Status", model.StatusTitle } };
|
||||||
|
collection.InsertOne(status);
|
||||||
|
return new CompanyVM { Title = model.Title, StatusTitle = model.StatusTitle };
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompanyVM? Update(CompanyBM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Company");
|
||||||
|
var result = collection.UpdateOneAsync(new BsonDocument("name", model.oldTitle), new BsonDocument("$set", new BsonDocument("name", model.Title)));
|
||||||
|
if (result == null)
|
||||||
|
return null;
|
||||||
|
return new CompanyVM
|
||||||
|
{
|
||||||
|
Title = model.Title,
|
||||||
|
StatusTitle = model.StatusTitle,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
113
Subd/MongoDB/HumanStorage.cs
Normal file
113
Subd/MongoDB/HumanStorage.cs
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.SearchModel;
|
||||||
|
using Contracts.Storage;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using MongoDB.Bson;
|
||||||
|
using MongoDB.Driver;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MongoDB
|
||||||
|
{
|
||||||
|
public class HumanStorage : IHumanStorage
|
||||||
|
{
|
||||||
|
public MongoClient contex;
|
||||||
|
public HumanStorage()
|
||||||
|
{
|
||||||
|
contex = MongoDateBase.getInstance().client;
|
||||||
|
}
|
||||||
|
public HumanVM? Delete(HumanBM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Human");
|
||||||
|
var res = collection.FindOneAndDelete(new BsonDocument("phone", model.Phone));
|
||||||
|
if (res == null)
|
||||||
|
return null;
|
||||||
|
return new HumanVM
|
||||||
|
{
|
||||||
|
Name = res["name"].ToString(),
|
||||||
|
Phone = res["phone"].ToString(),
|
||||||
|
StatusTitle = res["Status"].ToString(),
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public HumanVM? GetElement(HumanSM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Human");
|
||||||
|
BsonDocument human = collection.Find(new BsonDocument("number", model.Id)).FirstOrDefault();
|
||||||
|
if (human == null)
|
||||||
|
return null;
|
||||||
|
return new HumanVM
|
||||||
|
{
|
||||||
|
Name = human["name"].ToString(),
|
||||||
|
Phone = human["phone"].ToString(),
|
||||||
|
StatusTitle = human["Status"].ToString()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<HumanVM> GetFilteredList(HumanSM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Human");
|
||||||
|
List<BsonDocument> humans = collection.Find(new BsonDocument { { "$regex", $"^.{model.Name}.$" } }).ToList();
|
||||||
|
List<HumanVM> res = new List<HumanVM>();
|
||||||
|
foreach (var human in humans)
|
||||||
|
{
|
||||||
|
res.Add(new HumanVM
|
||||||
|
{
|
||||||
|
Name = human["name"].ToString(),
|
||||||
|
Phone = human["phone"].ToString(),
|
||||||
|
StatusTitle = human["Status"].ToString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<HumanVM> GetFullList()
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Human");
|
||||||
|
List<BsonDocument> humans = collection.Find(new BsonDocument()).ToList();
|
||||||
|
List<HumanVM> res = new List<HumanVM>();
|
||||||
|
foreach (var human in humans)
|
||||||
|
{
|
||||||
|
res.Add(new HumanVM
|
||||||
|
{
|
||||||
|
Name = human["name"].ToString(),
|
||||||
|
Phone = human["phone"].ToString(),
|
||||||
|
StatusTitle = human["Status"].ToString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HumanVM? Insert(HumanBM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Human");
|
||||||
|
BsonDocument human = new BsonDocument { {"number", model.Id }, { "name", model.Name }, { "Status", model.StatusTitle }, { "phone" , model.Phone} };
|
||||||
|
collection.InsertOne(human);
|
||||||
|
return new HumanVM { Name = model.Name, StatusTitle = model.StatusTitle,Phone = model.Phone };
|
||||||
|
}
|
||||||
|
|
||||||
|
public HumanVM? Update(HumanBM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Human");
|
||||||
|
var result = collection.UpdateOneAsync(new BsonDocument("name", model.oldName), new BsonDocument("$set", new BsonDocument("name", model.Name)));
|
||||||
|
if (result == null)
|
||||||
|
return null;
|
||||||
|
return new HumanVM
|
||||||
|
{
|
||||||
|
Name = model.Name,
|
||||||
|
StatusTitle = model.StatusTitle,
|
||||||
|
Phone = model.Phone
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
18
Subd/MongoDB/MongoDB.csproj
Normal file
18
Subd/MongoDB/MongoDB.csproj
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="MongoDB.Driver" Version="2.19.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Contracts\Contracts.csproj" />
|
||||||
|
<ProjectReference Include="..\Subd\DataModels.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
24
Subd/MongoDB/MongoDateBase.cs
Normal file
24
Subd/MongoDB/MongoDateBase.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using MongoDB.Driver;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MongoDB
|
||||||
|
{
|
||||||
|
public class MongoDateBase
|
||||||
|
{
|
||||||
|
private static MongoDateBase instance;
|
||||||
|
public MongoClient client;
|
||||||
|
private MongoDateBase()
|
||||||
|
{ client = new MongoClient("mongodb://localhost:27017"); }
|
||||||
|
|
||||||
|
public static MongoDateBase getInstance()
|
||||||
|
{
|
||||||
|
if (instance == null)
|
||||||
|
instance = new MongoDateBase();
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
107
Subd/MongoDB/PlaceStorage.cs
Normal file
107
Subd/MongoDB/PlaceStorage.cs
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.SearchModel;
|
||||||
|
using Contracts.Storage;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using MongoDB.Bson;
|
||||||
|
using MongoDB.Driver;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MongoDB
|
||||||
|
{
|
||||||
|
public class PlaceStorage : IPlaceStorage
|
||||||
|
{
|
||||||
|
public MongoClient contex;
|
||||||
|
public PlaceStorage()
|
||||||
|
{
|
||||||
|
contex = MongoDateBase.getInstance().client;
|
||||||
|
}
|
||||||
|
public PlaceVM? Delete(PlaceBM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Place");
|
||||||
|
var res = collection.FindOneAndDelete(new BsonDocument("name", model.Title));
|
||||||
|
if (res == null)
|
||||||
|
return null;
|
||||||
|
return new PlaceVM
|
||||||
|
{
|
||||||
|
Title = res["name"].ToString(),
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlaceVM? GetElement(PlaceSM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Place");
|
||||||
|
BsonDocument place = collection.Find(new BsonDocument("name", model.Title)).FirstOrDefault();
|
||||||
|
if (place == null)
|
||||||
|
return null;
|
||||||
|
return new PlaceVM
|
||||||
|
{
|
||||||
|
Title = place["name"].ToString(),
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PlaceVM> GetFilteredList(PlaceSM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Place");
|
||||||
|
List<BsonDocument> statuses = collection.Find(new BsonDocument { { "$regex", $"^.{model.Title}.$" } }).ToList();
|
||||||
|
List<PlaceVM> res = new List<PlaceVM>();
|
||||||
|
foreach (var status in statuses)
|
||||||
|
{
|
||||||
|
res.Add(new PlaceVM
|
||||||
|
{
|
||||||
|
Title = status["name"].ToString(),
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PlaceVM> GetFullList()
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Place");
|
||||||
|
List<BsonDocument> statuses = collection.Find(new BsonDocument()).ToList();
|
||||||
|
List<PlaceVM> res = new List<PlaceVM>();
|
||||||
|
foreach (var status in statuses)
|
||||||
|
{
|
||||||
|
res.Add(new PlaceVM
|
||||||
|
{
|
||||||
|
Title = status["name"].ToString(),
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlaceVM? Insert(PlaceBM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Place");
|
||||||
|
BsonDocument status = new BsonDocument { { "name", model.Title } };
|
||||||
|
collection.InsertOne(status);
|
||||||
|
return new PlaceVM { Title = model.Title};
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlaceVM? Update(PlaceBM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Place");
|
||||||
|
var result = collection.UpdateOneAsync(new BsonDocument("name", model.oldTitle), new BsonDocument("$set", new BsonDocument("name", model.Title)));
|
||||||
|
if (result == null)
|
||||||
|
return null;
|
||||||
|
return new PlaceVM
|
||||||
|
{
|
||||||
|
Title = model.Title,
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
104
Subd/MongoDB/RouteStorage.cs
Normal file
104
Subd/MongoDB/RouteStorage.cs
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.SearchModel;
|
||||||
|
using Contracts.Storage;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using MongoDB.Bson;
|
||||||
|
using MongoDB.Driver;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MongoDB
|
||||||
|
{
|
||||||
|
public class RouteStorage : IRouteStorage
|
||||||
|
{
|
||||||
|
public MongoClient contex;
|
||||||
|
public RouteStorage()
|
||||||
|
{
|
||||||
|
contex = MongoDateBase.getInstance().client;
|
||||||
|
}
|
||||||
|
public RouteVM? Delete(RouteBM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Route");
|
||||||
|
var res = collection.FindOneAndDelete(new BsonDocument("name", model.Title));
|
||||||
|
if (res == null)
|
||||||
|
return null;
|
||||||
|
return new RouteVM
|
||||||
|
{
|
||||||
|
Title = res["name"].ToString(),
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public RouteVM? GetElement(RouteSM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Route");
|
||||||
|
BsonDocument route = collection.Find(new BsonDocument("name", model.Title)).FirstOrDefault();
|
||||||
|
if (route == null)
|
||||||
|
return null;
|
||||||
|
return new RouteVM
|
||||||
|
{
|
||||||
|
Title = route["name"].ToString(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<RouteVM> GetFilteredList(RouteSM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Route");
|
||||||
|
List<BsonDocument> statuses = collection.Find(new BsonDocument { { "$regex", $"^.{model.Title}.$" } }).ToList();
|
||||||
|
List<RouteVM> res = new List<RouteVM>();
|
||||||
|
foreach (var status in statuses)
|
||||||
|
{
|
||||||
|
res.Add(new RouteVM
|
||||||
|
{
|
||||||
|
Title = status["name"].ToString(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<RouteVM> GetFullList()
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Route");
|
||||||
|
List<BsonDocument> statuses = collection.Find(new BsonDocument()).ToList();
|
||||||
|
List<RouteVM> res = new List<RouteVM>();
|
||||||
|
foreach (var status in statuses)
|
||||||
|
{
|
||||||
|
res.Add(new RouteVM
|
||||||
|
{
|
||||||
|
Title = status["name"].ToString(),
|
||||||
|
Length = status["length"].ToInt32()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RouteVM? Insert(RouteBM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Route");
|
||||||
|
BsonDocument status = new BsonDocument { { "name", model.Title }, { "length", model.Length }, { "place_From" , model.PlaceStartName}, { "place_To", model.PlaceEndName } };
|
||||||
|
collection.InsertOne(status);
|
||||||
|
return new RouteVM { Title = model.Title, Length = model.Length };
|
||||||
|
}
|
||||||
|
|
||||||
|
public RouteVM? Update(RouteBM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Route");
|
||||||
|
var result = collection.UpdateOneAsync(new BsonDocument("name", model.oldTitle), new BsonDocument("$set", new BsonDocument("name", model.Title)));
|
||||||
|
if (result == null)
|
||||||
|
return null;
|
||||||
|
return new RouteVM
|
||||||
|
{
|
||||||
|
Title = model.Title,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
88
Subd/MongoDB/StatusStorage.cs
Normal file
88
Subd/MongoDB/StatusStorage.cs
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.SearchModel;
|
||||||
|
using Contracts.Storage;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using MongoDB.Bson;
|
||||||
|
using MongoDB.Driver;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics.Metrics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MongoDB
|
||||||
|
{
|
||||||
|
public class StatusStorage : IStatusStorage
|
||||||
|
{
|
||||||
|
public MongoClient contex;
|
||||||
|
public StatusStorage()
|
||||||
|
{
|
||||||
|
contex = MongoDateBase.getInstance().client;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StatusVM? Delete(StatusBM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Status");
|
||||||
|
var res = collection.FindOneAndDelete(new BsonDocument("name", model.Title));
|
||||||
|
if (res == null)
|
||||||
|
return null;
|
||||||
|
return new StatusVM
|
||||||
|
{
|
||||||
|
Title = res["name"].ToString()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public StatusVM? GetElement(StatusSM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Status");
|
||||||
|
BsonDocument status = collection.Find(new BsonDocument("name",model.Title)).FirstOrDefault();
|
||||||
|
if (status == null)
|
||||||
|
return null;
|
||||||
|
return new StatusVM
|
||||||
|
{
|
||||||
|
Title = status["name"].ToString()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<StatusVM> GetFullList()
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Status");
|
||||||
|
List<BsonDocument> statuses = collection.Find(new BsonDocument()).ToList();
|
||||||
|
List < StatusVM > res = new List<StatusVM>();
|
||||||
|
foreach (var status in statuses)
|
||||||
|
{
|
||||||
|
res.Add(new StatusVM
|
||||||
|
{
|
||||||
|
Title = status["name"].ToString()
|
||||||
|
}) ;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StatusVM? Insert(StatusBM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Status");
|
||||||
|
BsonDocument status = new BsonDocument { { "name", model.Title } };
|
||||||
|
collection.InsertOne(status);
|
||||||
|
return new StatusVM { Title = model.Title };
|
||||||
|
}
|
||||||
|
|
||||||
|
public StatusVM? Update(StatusBM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Status");
|
||||||
|
var result = collection.UpdateOneAsync(new BsonDocument("name", model.oldTitle), new BsonDocument("$set", new BsonDocument("name", model.Title)));
|
||||||
|
if(result == null)
|
||||||
|
return null;
|
||||||
|
return new StatusVM
|
||||||
|
{
|
||||||
|
Title = model.Title
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
77
Subd/MongoDB/VoyageStorage.cs
Normal file
77
Subd/MongoDB/VoyageStorage.cs
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.SearchModel;
|
||||||
|
using Contracts.Storage;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using MongoDB.Bson;
|
||||||
|
using MongoDB.Driver;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using static System.Net.Mime.MediaTypeNames;
|
||||||
|
|
||||||
|
namespace MongoDB
|
||||||
|
{
|
||||||
|
public class VoyageStorage : IVoyageStorage
|
||||||
|
{
|
||||||
|
public MongoClient contex;
|
||||||
|
public VoyageStorage()
|
||||||
|
{
|
||||||
|
contex = MongoDateBase.getInstance().client;
|
||||||
|
}
|
||||||
|
public VoyageVM? Delete(VoyageBM model)
|
||||||
|
{
|
||||||
|
throw new Exception("DONT DO IT!!!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public VoyageVM? GetElement(VoyageSM model)
|
||||||
|
{
|
||||||
|
throw new Exception("DONT DO IT!!!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<VoyageVM> GetFilteredList(VoyageSM model)
|
||||||
|
{
|
||||||
|
throw new Exception("DONT DO IT!!!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<VoyageVM> GetFullList()
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Voyage");
|
||||||
|
List<BsonDocument> humans = collection.Find(new BsonDocument()).ToList();
|
||||||
|
List<VoyageVM> res = new List<VoyageVM>();
|
||||||
|
foreach (var human in humans)
|
||||||
|
{
|
||||||
|
res.Add(new VoyageVM
|
||||||
|
{
|
||||||
|
CarName = human["car"].ToString(),
|
||||||
|
HumanName = human["human"].ToString(),
|
||||||
|
RouteName = human["route"].ToString(),
|
||||||
|
CompanyName = human["company"].ToString(),
|
||||||
|
DateStart = DateOnly.Parse(human["date_From"].ToString().Substring(0,10)),
|
||||||
|
DateEnd = DateOnly.Parse(human["date_To"].ToString().Substring(0,10)),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VoyageVM? Insert(VoyageBM model)
|
||||||
|
{
|
||||||
|
IMongoDatabase db = contex.GetDatabase("logistic");
|
||||||
|
var collection = db.GetCollection<BsonDocument>("Voyage");
|
||||||
|
BsonDocument human = new BsonDocument { { "car", model.CarName }, { "human", model.HumanName }, { "route", model.RouteName }, {"company", model.CompanyName } ,{ "date_From", DateTime.Parse(model.DateStart.ToString()) }, { "date_To", DateTime.Parse(model.DateEnd.ToString()) } };
|
||||||
|
collection.InsertOne(human);
|
||||||
|
return new VoyageVM {
|
||||||
|
CarName = human["car"].ToString(),
|
||||||
|
HumanName = human["human"].ToString(),
|
||||||
|
RouteName = human["route"].ToString(),
|
||||||
|
CompanyName = human["company"].ToString(),
|
||||||
|
DateStart = DateOnly.Parse(human["date_From"].ToString().Substring(0, 10)),
|
||||||
|
DateEnd = DateOnly.Parse(human["date_To"].ToString().Substring(0, 10))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -3,15 +3,19 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.3.32825.248
|
VisualStudioVersion = 17.3.32825.248
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataModels", "Subd\DataModels.csproj", "{4F51BFA8-D899-4A30-96AA-0B6BFE630E9C}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataModels", "Subd\DataModels.csproj", "{4F51BFA8-D899-4A30-96AA-0B6BFE630E9C}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contracts", "Contracts\Contracts.csproj", "{AB284C76-C880-4A90-8E6D-00A8ACCA531A}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Contracts", "Contracts\Contracts.csproj", "{AB284C76-C880-4A90-8E6D-00A8ACCA531A}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataBase", "DataBase\DataBase.csproj", "{1BD4BC13-350F-48B2-8A5D-55585620470B}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataBase", "DataBase\DataBase.csproj", "{1BD4BC13-350F-48B2-8A5D-55585620470B}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Forms", "Forms\Forms.csproj", "{1901CFE4-7DA9-423E-A3A1-20A3444CC7F7}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Forms", "Forms\Forms.csproj", "{1901CFE4-7DA9-423E-A3A1-20A3444CC7F7}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BusinessLogic", "BusinessLogic\BusinessLogic.csproj", "{6ED0D589-EC71-42CE-A20E-C7C1E036F26B}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BusinessLogic", "BusinessLogic\BusinessLogic.csproj", "{6ED0D589-EC71-42CE-A20E-C7C1E036F26B}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB", "MongoDB\MongoDB.csproj", "{679402AD-48C2-424E-A64A-D76493B13B15}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GoingToMongo", "GoingToMongo\GoingToMongo.csproj", "{4FC61670-0BE7-4119-ACBF-CE75EB6836F3}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -39,6 +43,14 @@ Global
|
|||||||
{6ED0D589-EC71-42CE-A20E-C7C1E036F26B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{6ED0D589-EC71-42CE-A20E-C7C1E036F26B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{6ED0D589-EC71-42CE-A20E-C7C1E036F26B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{6ED0D589-EC71-42CE-A20E-C7C1E036F26B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{6ED0D589-EC71-42CE-A20E-C7C1E036F26B}.Release|Any CPU.Build.0 = Release|Any CPU
|
{6ED0D589-EC71-42CE-A20E-C7C1E036F26B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{679402AD-48C2-424E-A64A-D76493B13B15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{679402AD-48C2-424E-A64A-D76493B13B15}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{679402AD-48C2-424E-A64A-D76493B13B15}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{679402AD-48C2-424E-A64A-D76493B13B15}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{4FC61670-0BE7-4119-ACBF-CE75EB6836F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{4FC61670-0BE7-4119-ACBF-CE75EB6836F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{4FC61670-0BE7-4119-ACBF-CE75EB6836F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{4FC61670-0BE7-4119-ACBF-CE75EB6836F3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
Loading…
Reference in New Issue
Block a user