Все работает \(^-^)/
This commit is contained in:
parent
8682baa376
commit
aa94208637
63
SushiBar/SushiBar/FormMain.Designer.cs
generated
63
SushiBar/SushiBar/FormMain.Designer.cs
generated
@ -40,6 +40,7 @@
|
||||
buttonCreateTask = new Button();
|
||||
dataGridView = new DataGridView();
|
||||
buttonTest = new Button();
|
||||
buttonPsqlToMongo = new Button();
|
||||
menuStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
@ -49,8 +50,7 @@
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { объектыToolStripMenuItem });
|
||||
menuStrip1.Location = new Point(0, 0);
|
||||
menuStrip1.Name = "menuStrip1";
|
||||
menuStrip1.Padding = new Padding(7, 3, 0, 3);
|
||||
menuStrip1.Size = new Size(1387, 30);
|
||||
menuStrip1.Size = new Size(1214, 24);
|
||||
menuStrip1.TabIndex = 0;
|
||||
menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
@ -58,43 +58,42 @@
|
||||
//
|
||||
объектыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { buyerToolStripMenuItem, cookToolStripMenuItem, menuToolStripMenuItem, placeToolStripMenuItem });
|
||||
объектыToolStripMenuItem.Name = "объектыToolStripMenuItem";
|
||||
объектыToolStripMenuItem.Size = new Size(82, 24);
|
||||
объектыToolStripMenuItem.Size = new Size(68, 20);
|
||||
объектыToolStripMenuItem.Text = "Объекты";
|
||||
//
|
||||
// buyerToolStripMenuItem
|
||||
//
|
||||
buyerToolStripMenuItem.Name = "buyerToolStripMenuItem";
|
||||
buyerToolStripMenuItem.Size = new Size(159, 24);
|
||||
buyerToolStripMenuItem.Size = new Size(139, 22);
|
||||
buyerToolStripMenuItem.Text = "Покупатель";
|
||||
buyerToolStripMenuItem.Click += buyerToolStripMenuItem_Click;
|
||||
//
|
||||
// cookToolStripMenuItem
|
||||
//
|
||||
cookToolStripMenuItem.Name = "cookToolStripMenuItem";
|
||||
cookToolStripMenuItem.Size = new Size(159, 24);
|
||||
cookToolStripMenuItem.Size = new Size(139, 22);
|
||||
cookToolStripMenuItem.Text = "Повар";
|
||||
cookToolStripMenuItem.Click += cookToolStripMenuItem_Click;
|
||||
//
|
||||
// menuToolStripMenuItem
|
||||
//
|
||||
menuToolStripMenuItem.Name = "menuToolStripMenuItem";
|
||||
menuToolStripMenuItem.Size = new Size(159, 24);
|
||||
menuToolStripMenuItem.Size = new Size(139, 22);
|
||||
menuToolStripMenuItem.Text = "Меню";
|
||||
menuToolStripMenuItem.Click += menuToolStripMenuItem_Click;
|
||||
//
|
||||
// placeToolStripMenuItem
|
||||
//
|
||||
placeToolStripMenuItem.Name = "placeToolStripMenuItem";
|
||||
placeToolStripMenuItem.Size = new Size(159, 24);
|
||||
placeToolStripMenuItem.Size = new Size(139, 22);
|
||||
placeToolStripMenuItem.Text = "Столик";
|
||||
placeToolStripMenuItem.Click += placeToolStripMenuItem_Click;
|
||||
//
|
||||
// buttonIssuedTask
|
||||
//
|
||||
buttonIssuedTask.Location = new Point(1106, 275);
|
||||
buttonIssuedTask.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonIssuedTask.Location = new Point(968, 206);
|
||||
buttonIssuedTask.Name = "buttonIssuedTask";
|
||||
buttonIssuedTask.Size = new Size(226, 37);
|
||||
buttonIssuedTask.Size = new Size(198, 28);
|
||||
buttonIssuedTask.TabIndex = 11;
|
||||
buttonIssuedTask.Text = "Заказ выдан";
|
||||
buttonIssuedTask.UseVisualStyleBackColor = true;
|
||||
@ -102,10 +101,9 @@
|
||||
//
|
||||
// buttonTaskReady
|
||||
//
|
||||
buttonTaskReady.Location = new Point(1106, 205);
|
||||
buttonTaskReady.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonTaskReady.Location = new Point(968, 154);
|
||||
buttonTaskReady.Name = "buttonTaskReady";
|
||||
buttonTaskReady.Size = new Size(226, 37);
|
||||
buttonTaskReady.Size = new Size(198, 28);
|
||||
buttonTaskReady.TabIndex = 10;
|
||||
buttonTaskReady.Text = "Заказ готов";
|
||||
buttonTaskReady.UseVisualStyleBackColor = true;
|
||||
@ -113,10 +111,9 @@
|
||||
//
|
||||
// buttonTakeTaskInWork
|
||||
//
|
||||
buttonTakeTaskInWork.Location = new Point(1106, 133);
|
||||
buttonTakeTaskInWork.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonTakeTaskInWork.Location = new Point(968, 100);
|
||||
buttonTakeTaskInWork.Name = "buttonTakeTaskInWork";
|
||||
buttonTakeTaskInWork.Size = new Size(226, 37);
|
||||
buttonTakeTaskInWork.Size = new Size(198, 28);
|
||||
buttonTakeTaskInWork.TabIndex = 9;
|
||||
buttonTakeTaskInWork.Text = "Отдать на выполнение";
|
||||
buttonTakeTaskInWork.UseVisualStyleBackColor = true;
|
||||
@ -124,10 +121,9 @@
|
||||
//
|
||||
// buttonCreateTask
|
||||
//
|
||||
buttonCreateTask.Location = new Point(1106, 61);
|
||||
buttonCreateTask.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonCreateTask.Location = new Point(968, 46);
|
||||
buttonCreateTask.Name = "buttonCreateTask";
|
||||
buttonCreateTask.Size = new Size(226, 37);
|
||||
buttonCreateTask.Size = new Size(198, 28);
|
||||
buttonCreateTask.TabIndex = 8;
|
||||
buttonCreateTask.Text = "Создать заказ";
|
||||
buttonCreateTask.UseVisualStyleBackColor = true;
|
||||
@ -139,31 +135,40 @@
|
||||
dataGridView.BackgroundColor = Color.White;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Dock = DockStyle.Left;
|
||||
dataGridView.Location = new Point(0, 30);
|
||||
dataGridView.Margin = new Padding(3, 4, 3, 4);
|
||||
dataGridView.Location = new Point(0, 24);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.ReadOnly = true;
|
||||
dataGridView.RowHeadersVisible = false;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(1049, 570);
|
||||
dataGridView.Size = new Size(918, 426);
|
||||
dataGridView.TabIndex = 7;
|
||||
//
|
||||
// buttonTest
|
||||
//
|
||||
buttonTest.Location = new Point(1106, 349);
|
||||
buttonTest.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonTest.Location = new Point(968, 262);
|
||||
buttonTest.Name = "buttonTest";
|
||||
buttonTest.Size = new Size(226, 37);
|
||||
buttonTest.Size = new Size(198, 28);
|
||||
buttonTest.TabIndex = 12;
|
||||
buttonTest.Text = "ТЕСТ";
|
||||
buttonTest.Text = "Удалить все данные";
|
||||
buttonTest.UseVisualStyleBackColor = true;
|
||||
buttonTest.Click += buttonTest_Click;
|
||||
//
|
||||
// buttonPsqlToMongo
|
||||
//
|
||||
buttonPsqlToMongo.Location = new Point(968, 309);
|
||||
buttonPsqlToMongo.Name = "buttonPsqlToMongo";
|
||||
buttonPsqlToMongo.Size = new Size(198, 42);
|
||||
buttonPsqlToMongo.TabIndex = 13;
|
||||
buttonPsqlToMongo.Text = "Перенести все данные на MongoDB";
|
||||
buttonPsqlToMongo.UseVisualStyleBackColor = true;
|
||||
buttonPsqlToMongo.Click += buttonPsqlToMongo_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1387, 600);
|
||||
ClientSize = new Size(1214, 450);
|
||||
Controls.Add(buttonPsqlToMongo);
|
||||
Controls.Add(buttonTest);
|
||||
Controls.Add(buttonIssuedTask);
|
||||
Controls.Add(buttonTaskReady);
|
||||
@ -172,7 +177,6 @@
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(menuStrip1);
|
||||
MainMenuStrip = menuStrip1;
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "FormMain";
|
||||
Text = "Главное окно";
|
||||
Load += FormMain_Load;
|
||||
@ -197,5 +201,6 @@
|
||||
private Button buttonCreateTask;
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonTest;
|
||||
private Button buttonPsqlToMongo;
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
using SushiBar;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.BusinessLogicContracts;
|
||||
using SushiBarMongoDB;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@ -16,14 +17,21 @@ namespace SushiBarView
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
|
||||
private readonly ITaskLogic _logic;
|
||||
private readonly ICookLogic _CLogic;
|
||||
private readonly ITaskLogic _TaskLogic;
|
||||
private readonly ICookLogic _CookLogic;
|
||||
private readonly IBuyerLogic _BuyerLogic;
|
||||
private readonly IMenuLogic _MenuLogic;
|
||||
private readonly IPlaceLogic _PlaceLogic;
|
||||
|
||||
public FormMain(ITaskLogic logic, ICookLogic cLogic)
|
||||
|
||||
public FormMain(ITaskLogic logic, ICookLogic cLogic, IBuyerLogic buyerLogic, IMenuLogic menuLogic, IPlaceLogic placeLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
_CLogic = cLogic;
|
||||
_TaskLogic = logic;
|
||||
_CookLogic = cLogic;
|
||||
_BuyerLogic = buyerLogic;
|
||||
_MenuLogic = menuLogic;
|
||||
_PlaceLogic = placeLogic;
|
||||
}
|
||||
|
||||
private void buyerToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
@ -69,7 +77,7 @@ namespace SushiBarView
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
var _list = _logic.ReadList(null);
|
||||
var _list = _TaskLogic.ReadList(null);
|
||||
if (_list != null)
|
||||
{
|
||||
dataGridView.DataSource = _list;
|
||||
@ -97,7 +105,7 @@ namespace SushiBarView
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
try
|
||||
{
|
||||
var operationResult = _logic.TakeTaskInWork(new TaskBindingModel
|
||||
var operationResult = _TaskLogic.TakeTaskInWork(new TaskBindingModel
|
||||
{
|
||||
Id = id,
|
||||
Status = Enum.Parse<SushiBarDataModels.Enum.TaskStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||
@ -122,7 +130,7 @@ namespace SushiBarView
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
try
|
||||
{
|
||||
var operationResult = _logic.FinishTask(new TaskBindingModel
|
||||
var operationResult = _TaskLogic.FinishTask(new TaskBindingModel
|
||||
{
|
||||
Id = id,
|
||||
Status = Enum.Parse<SushiBarDataModels.Enum.TaskStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||
@ -147,7 +155,7 @@ namespace SushiBarView
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
try
|
||||
{
|
||||
var operationResult = _logic.DeliveryTask(new TaskBindingModel
|
||||
var operationResult = _TaskLogic.DeliveryTask(new TaskBindingModel
|
||||
{
|
||||
Id = id,
|
||||
Status = Enum.Parse<SushiBarDataModels.Enum.TaskStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||
@ -168,25 +176,21 @@ namespace SushiBarView
|
||||
private void buttonTest_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
CookBindingModel model = new CookBindingModel()
|
||||
try
|
||||
{
|
||||
Id = 2,
|
||||
CookName = "Иван",
|
||||
CookSurname = "dssfsdfs",
|
||||
Experience = 2,
|
||||
PhoneNumber = "+79054324312",
|
||||
Passport = "123124"
|
||||
};
|
||||
|
||||
DateTime start = DateTime.Now;
|
||||
_CLogic.Delete(model);
|
||||
DateTime stop = DateTime.Now;
|
||||
MessageBox.Show((start - stop).ToString(), "Test", MessageBoxButtons.OK);
|
||||
}
|
||||
_BuyerLogic.ClearEntity();
|
||||
_CookLogic.ClearEntity();
|
||||
_MenuLogic.ClearEntity();
|
||||
_PlaceLogic.ClearEntity();
|
||||
_TaskLogic.ClearEntity();
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
|
||||
//public string CookSurname { get; set; } = string.Empty;
|
||||
//public int Experience { get; set; }
|
||||
//public string PhoneNumber { get; set; } = string.Empty;
|
||||
//public string Passport { get; set; } = string.Empty;
|
||||
private void buttonPsqlToMongo_Click(object sender, EventArgs e)
|
||||
{
|
||||
PostgresToMongo.Convert();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,8 @@ using Microsoft.Extensions.Logging;
|
||||
using SushiBarBusinessLogic.BusinessLogics;
|
||||
using SushiBarContracts.BusinessLogicContracts;
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
//using SushiBarDatabaseImplement.Implements;
|
||||
using SushiBarMongoDB.Implements;
|
||||
using SushiBarDatabaseImplement.Implements;
|
||||
//using SushiBarMongoDB.Implements;
|
||||
using SushiBarView;
|
||||
|
||||
namespace SushiBar
|
||||
|
@ -90,5 +90,10 @@ namespace SushiBarBusinessLogic.BusinessLogics
|
||||
throw new ArgumentNullException("Нет названия", nameof(model.BuyerName));
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearEntity()
|
||||
{
|
||||
_buyerStorage.ClearEntity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,5 +89,10 @@ namespace SushiBarBusinessLogic.BusinessLogics
|
||||
throw new ArgumentNullException("Нет названия", nameof(model.CookName));
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearEntity()
|
||||
{
|
||||
_cookStorage.ClearEntity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,5 +89,10 @@ namespace SushiBarBusinessLogic.BusinessLogics
|
||||
throw new ArgumentNullException("Нет названия", nameof(model.FoodName));
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearEntity()
|
||||
{
|
||||
_menuStorage.ClearEntity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,5 +89,10 @@ namespace SushiBarBusinessLogic.BusinessLogics
|
||||
throw new ArgumentNullException("Нет названия", nameof(model.PlaceNumber));
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearEntity()
|
||||
{
|
||||
_placeStorage.ClearEntity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -116,5 +116,10 @@ namespace SushiBarBusinessLogic.BusinessLogics
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearEntity()
|
||||
{
|
||||
_taskStorage.ClearEntity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,5 +17,6 @@ namespace SushiBarContracts.BusinessLogicContracts
|
||||
bool Create(BuyerBindingModel model);
|
||||
bool Update(BuyerBindingModel model);
|
||||
bool Delete(BuyerBindingModel model);
|
||||
void ClearEntity();
|
||||
}
|
||||
}
|
||||
|
@ -17,5 +17,6 @@ namespace SushiBarContracts.BusinessLogicContracts
|
||||
bool Create(CookBindingModel model);
|
||||
bool Update(CookBindingModel model);
|
||||
bool Delete(CookBindingModel model);
|
||||
void ClearEntity();
|
||||
}
|
||||
}
|
||||
|
@ -17,5 +17,6 @@ namespace SushiBarContracts.BusinessLogicContracts
|
||||
bool Create(MenuBindingModel model);
|
||||
bool Update(MenuBindingModel model);
|
||||
bool Delete(MenuBindingModel model);
|
||||
void ClearEntity();
|
||||
}
|
||||
}
|
||||
|
@ -17,5 +17,6 @@ namespace SushiBarContracts.BusinessLogicContracts
|
||||
bool Create(PlaceBindingModel model);
|
||||
bool Update(PlaceBindingModel model);
|
||||
bool Delete(PlaceBindingModel model);
|
||||
void ClearEntity();
|
||||
}
|
||||
}
|
||||
|
@ -20,5 +20,6 @@ namespace SushiBarContracts.BusinessLogicContracts
|
||||
bool TakeTaskInWork(TaskBindingModel model);
|
||||
bool FinishTask(TaskBindingModel model);
|
||||
bool DeliveryTask(TaskBindingModel model);
|
||||
void ClearEntity();
|
||||
}
|
||||
}
|
||||
|
@ -18,5 +18,6 @@ namespace SushiBarContracts.StoragesContracts
|
||||
BuyerViewModel? Insert(BuyerBindingModel model);
|
||||
BuyerViewModel? Update(BuyerBindingModel model);
|
||||
BuyerViewModel? Delete(BuyerBindingModel model);
|
||||
void ClearEntity();
|
||||
}
|
||||
}
|
||||
|
@ -18,5 +18,6 @@ namespace SushiBarContracts.StoragesContracts
|
||||
CookViewModel? Insert(CookBindingModel model);
|
||||
CookViewModel? Update(CookBindingModel model);
|
||||
CookViewModel? Delete(CookBindingModel model);
|
||||
void ClearEntity();
|
||||
}
|
||||
}
|
||||
|
@ -18,5 +18,6 @@ namespace SushiBarContracts.StoragesContracts
|
||||
MenuViewModel? Insert(MenuBindingModel model);
|
||||
MenuViewModel? Update(MenuBindingModel model);
|
||||
MenuViewModel? Delete(MenuBindingModel model);
|
||||
void ClearEntity();
|
||||
}
|
||||
}
|
||||
|
@ -18,5 +18,6 @@ namespace SushiBarContracts.StoragesContracts
|
||||
PlaceViewModel? Insert(PlaceBindingModel model);
|
||||
PlaceViewModel? Update(PlaceBindingModel model);
|
||||
PlaceViewModel? Delete(PlaceBindingModel model);
|
||||
void ClearEntity();
|
||||
}
|
||||
}
|
||||
|
@ -18,5 +18,6 @@ namespace SushiBarContracts.StoragesContracts
|
||||
TaskViewModel? Insert(TaskBindingModel model);
|
||||
TaskViewModel? Update(TaskBindingModel model);
|
||||
TaskViewModel? Delete(TaskBindingModel model);
|
||||
void ClearEntity();
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using SushiBarContracts.BindingModels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.SearchModels;
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
using SushiBarContracts.ViewModels;
|
||||
@ -74,5 +75,13 @@ namespace SushiBarDatabaseImplement.Implements
|
||||
context.SaveChanges();
|
||||
return component.GetViewModel;
|
||||
}
|
||||
|
||||
public void ClearEntity()
|
||||
{
|
||||
using var context = new SushiBarDatabase();
|
||||
|
||||
string deleteAllQuery = "DELETE FROM \"Buyers\"";
|
||||
context.Database.ExecuteSqlRaw(deleteAllQuery);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using SushiBarContracts.BindingModels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.SearchModels;
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
using SushiBarContracts.ViewModels;
|
||||
@ -14,6 +15,14 @@ namespace SushiBarDatabaseImplement.Implements
|
||||
{
|
||||
public class CookStorage : ICookStorage
|
||||
{
|
||||
public void ClearEntity()
|
||||
{
|
||||
using var context = new SushiBarDatabase();
|
||||
|
||||
string deleteAllQuery = "DELETE FROM \"Cooks\"";
|
||||
context.Database.ExecuteSqlRaw(deleteAllQuery);
|
||||
}
|
||||
|
||||
public CookViewModel? Delete(CookBindingModel model)
|
||||
{
|
||||
using var context = new SushiBarDatabase();
|
||||
|
@ -1,4 +1,5 @@
|
||||
using SushiBarContracts.BindingModels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.SearchModels;
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
using SushiBarContracts.ViewModels;
|
||||
@ -14,6 +15,14 @@ namespace SushiBarDatabaseImplement.Implements
|
||||
{
|
||||
public class MenuStorage : IMenuStorage
|
||||
{
|
||||
public void ClearEntity()
|
||||
{
|
||||
using var context = new SushiBarDatabase();
|
||||
|
||||
string deleteAllQuery = "DELETE FROM \"Menus\"";
|
||||
context.Database.ExecuteSqlRaw(deleteAllQuery);
|
||||
}
|
||||
|
||||
public MenuViewModel? Delete(MenuBindingModel model)
|
||||
{
|
||||
using var context = new SushiBarDatabase();
|
||||
|
@ -1,4 +1,5 @@
|
||||
using SushiBarContracts.BindingModels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.SearchModels;
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
using SushiBarContracts.ViewModels;
|
||||
@ -14,6 +15,14 @@ namespace SushiBarDatabaseImplement.Implements
|
||||
{
|
||||
public class PlaceStorage : IPlaceStorage
|
||||
{
|
||||
public void ClearEntity()
|
||||
{
|
||||
using var context = new SushiBarDatabase();
|
||||
|
||||
string deleteAllQuery = "DELETE FROM \"Places\"";
|
||||
context.Database.ExecuteSqlRaw(deleteAllQuery);
|
||||
}
|
||||
|
||||
public PlaceViewModel? Delete(PlaceBindingModel model)
|
||||
{
|
||||
using var context = new SushiBarDatabase();
|
||||
|
@ -13,6 +13,14 @@ namespace SushiBarDatabaseImplement.Implements
|
||||
{
|
||||
public class TaskStorage : ITaskStorage
|
||||
{
|
||||
public void ClearEntity()
|
||||
{
|
||||
using var context = new SushiBarDatabase();
|
||||
|
||||
string deleteAllQuery = "DELETE FROM \"Tasks\"";
|
||||
context.Database.ExecuteSqlRaw(deleteAllQuery);
|
||||
}
|
||||
|
||||
public TaskViewModel? Delete(TaskBindingModel model)
|
||||
{
|
||||
using var context = new SushiBarDatabase();
|
||||
|
@ -2,9 +2,9 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using SushiBarDatabaseImplement;
|
||||
|
||||
#nullable disable
|
||||
@ -12,8 +12,8 @@ using SushiBarDatabaseImplement;
|
||||
namespace SushiBarDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(SushiBarDatabase))]
|
||||
[Migration("20240326181255_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
[Migration("20240507174252_InitMigration")]
|
||||
partial class InitMigration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@ -21,24 +21,24 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.3")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Buyer", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("BuyerBirthDate")
|
||||
.HasColumnType("datetime2");
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("BuyerName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
@ -49,28 +49,28 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("CookName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("CookSurname")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Experience")
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Passport")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
@ -81,20 +81,20 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("FoodName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
@ -105,15 +105,15 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CountPlaces")
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("PlaceNumber")
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
@ -124,27 +124,27 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("BuyerId")
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("CookId")
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("FullPrice")
|
||||
.HasColumnType("float");
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("PlaceId")
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("TaskDate")
|
||||
.HasColumnType("datetime2");
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
@ -155,18 +155,18 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("MenuId")
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("TaskId")
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
@ -1,12 +1,13 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SushiBarDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
public partial class InitMigration : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
@ -15,10 +16,10 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
name: "Buyers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
BuyerName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
BuyerBirthDate = table.Column<DateTime>(type: "datetime2", nullable: true)
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
BuyerName = table.Column<string>(type: "text", nullable: false),
|
||||
BuyerBirthDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
@ -29,13 +30,13 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
name: "Cooks",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
CookName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
CookSurname = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Experience = table.Column<int>(type: "int", nullable: false),
|
||||
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Passport = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
CookName = table.Column<string>(type: "text", nullable: false),
|
||||
CookSurname = table.Column<string>(type: "text", nullable: false),
|
||||
Experience = table.Column<int>(type: "integer", nullable: false),
|
||||
PhoneNumber = table.Column<string>(type: "text", nullable: false),
|
||||
Passport = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
@ -46,11 +47,11 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
name: "Menus",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
FoodName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Price = table.Column<double>(type: "float", nullable: false)
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
FoodName = table.Column<string>(type: "text", nullable: false),
|
||||
Description = table.Column<string>(type: "text", nullable: false),
|
||||
Price = table.Column<double>(type: "double precision", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
@ -61,10 +62,10 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
name: "Places",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
PlaceNumber = table.Column<int>(type: "int", nullable: false),
|
||||
CountPlaces = table.Column<int>(type: "int", nullable: false)
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
PlaceNumber = table.Column<int>(type: "integer", nullable: false),
|
||||
CountPlaces = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
@ -75,14 +76,14 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
name: "Tasks",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
TaskDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
Status = table.Column<int>(type: "int", nullable: false),
|
||||
FullPrice = table.Column<double>(type: "float", nullable: false),
|
||||
PlaceId = table.Column<int>(type: "int", nullable: false),
|
||||
CookId = table.Column<int>(type: "int", nullable: false),
|
||||
BuyerId = table.Column<int>(type: "int", nullable: false)
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
TaskDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||
Status = table.Column<int>(type: "integer", nullable: false),
|
||||
FullPrice = table.Column<double>(type: "double precision", nullable: false),
|
||||
PlaceId = table.Column<int>(type: "integer", nullable: false),
|
||||
CookId = table.Column<int>(type: "integer", nullable: false),
|
||||
BuyerId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
@ -93,11 +94,11 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
name: "TaskMenus",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
TaskId = table.Column<int>(type: "int", nullable: false),
|
||||
MenuId = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false)
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
TaskId = table.Column<int>(type: "integer", nullable: false),
|
||||
MenuId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
@ -2,8 +2,8 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using SushiBarDatabaseImplement;
|
||||
|
||||
#nullable disable
|
||||
@ -18,24 +18,24 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.3")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Buyer", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("BuyerBirthDate")
|
||||
.HasColumnType("datetime2");
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("BuyerName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
@ -46,28 +46,28 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("CookName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("CookSurname")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Experience")
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Passport")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
@ -78,20 +78,20 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("FoodName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
@ -102,15 +102,15 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CountPlaces")
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("PlaceNumber")
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
@ -121,27 +121,27 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("BuyerId")
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("CookId")
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("FullPrice")
|
||||
.HasColumnType("float");
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("PlaceId")
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("TaskDate")
|
||||
.HasColumnType("datetime2");
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
@ -152,18 +152,18 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("MenuId")
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("TaskId")
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
|
@ -15,11 +15,15 @@ namespace SushiBarDatabaseImplement
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=.\SQLEXPRESS;Initial Catalog=SushiBarDatabase;Integrated Security=True;MultipleActiveResultSets=True;TrustServerCertificate=True");
|
||||
optionsBuilder.UseNpgsql(@"Host=localhost;Database=SUBDLab8;Username=postgres;Password=shotboll200412");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
|
||||
}
|
||||
|
||||
//optionsBuilder.UseNpgsql(@"Host=localhost;Database=ComputersShop_db;Username=postgres;Password=postgres");
|
||||
|
||||
public virtual DbSet<Buyer> Buyers { get; set; }
|
||||
public virtual DbSet<Cook> Cooks { get; set; }
|
||||
public virtual DbSet<Menu> Menus { get; set; }
|
||||
|
@ -15,6 +15,14 @@ namespace SushiBarMongoDB.Implements
|
||||
{
|
||||
public class CookStorage : ICookStorage
|
||||
{
|
||||
|
||||
public void ClearEntity()
|
||||
{
|
||||
using var context = new SushiBarMongoDB();
|
||||
context.GetCollection<Cook>("Cooks")
|
||||
.DeleteMany(Builders<Cook>.Filter.Empty);
|
||||
}
|
||||
|
||||
public List<CookViewModel> GetFullList()
|
||||
{
|
||||
using var context = new SushiBarMongoDB();
|
||||
|
122
SushiBar/SushiBarMongoDB/PostgresToMongo.cs
Normal file
122
SushiBar/SushiBarMongoDB/PostgresToMongo.cs
Normal file
@ -0,0 +1,122 @@
|
||||
using MongoDB.Bson;
|
||||
using MongoDB.Driver;
|
||||
using MongoDB.Driver.Core.Configuration;
|
||||
using Npgsql;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SushiBarMongoDB
|
||||
{
|
||||
public static class PostgresToMongo
|
||||
{
|
||||
public static void Convert()
|
||||
{
|
||||
string postgresConnection = "Host=localhost;Username=postgres;Password=shotboll200412;Database=SUBDLab8";
|
||||
using var psqlConn = new NpgsqlConnection(postgresConnection);
|
||||
psqlConn.Open();
|
||||
|
||||
var client = new MongoClient("mongodb://localhost:27017");
|
||||
var database = client.GetDatabase("lab8SUBD");
|
||||
|
||||
var buyers = database.GetCollection<BsonDocument>("Buyers");
|
||||
var cooks = database.GetCollection<BsonDocument>("Cooks");
|
||||
var menus = database.GetCollection<BsonDocument>("Menus");
|
||||
var places = database.GetCollection<BsonDocument>("Places");
|
||||
var tasks = database.GetCollection<BsonDocument>("Tasks");
|
||||
|
||||
//Конвертация покупателей
|
||||
|
||||
using var psqlBuyers = new NpgsqlCommand("SELECT * FROM \"Buyers\"", psqlConn);
|
||||
using var readBuyers = psqlBuyers.ExecuteReader();
|
||||
|
||||
while(readBuyers.Read())
|
||||
{
|
||||
var document = new BsonDocument();
|
||||
for(int i = 0;i<readBuyers.FieldCount;i++)
|
||||
{
|
||||
document.Add(readBuyers.GetName(i), BsonValue.Create(readBuyers.GetValue(i)));
|
||||
}
|
||||
buyers.InsertOne(document);
|
||||
}
|
||||
readBuyers.Close();
|
||||
psqlBuyers.Cancel();
|
||||
|
||||
//Конвертация поваров
|
||||
|
||||
using var psqlCooks = new NpgsqlCommand("SELECT * FROM \"Cooks\"", psqlConn);
|
||||
using var readCooks = psqlCooks.ExecuteReader();
|
||||
|
||||
while (readCooks.Read())
|
||||
{
|
||||
var document = new BsonDocument();
|
||||
for (int i = 0; i < readCooks.FieldCount; i++)
|
||||
{
|
||||
document.Add(readCooks.GetName(i), BsonValue.Create(readCooks.GetValue(i)));
|
||||
}
|
||||
cooks.InsertOne(document);
|
||||
}
|
||||
readCooks.Close();
|
||||
psqlCooks.Cancel();
|
||||
|
||||
//Конвертация меню
|
||||
|
||||
using var psqlMenus = new NpgsqlCommand("SELECT * FROM \"Menus\"", psqlConn);
|
||||
using var readMenus = psqlMenus.ExecuteReader();
|
||||
|
||||
while (readMenus.Read())
|
||||
{
|
||||
var document = new BsonDocument();
|
||||
for (int i = 0; i < readMenus.FieldCount; i++)
|
||||
{
|
||||
document.Add(readMenus.GetName(i), BsonValue.Create(readMenus.GetValue(i)));
|
||||
}
|
||||
menus.InsertOne(document);
|
||||
}
|
||||
readMenus.Close();
|
||||
psqlMenus.Cancel();
|
||||
|
||||
//Конвертация столиков
|
||||
|
||||
using var psqlPlaces = new NpgsqlCommand("SELECT * FROM \"Places\"", psqlConn);
|
||||
using var readPlaces = psqlPlaces.ExecuteReader();
|
||||
|
||||
while (readPlaces.Read())
|
||||
{
|
||||
var document = new BsonDocument();
|
||||
for (int i = 0; i < readPlaces.FieldCount; i++)
|
||||
{
|
||||
document.Add(readPlaces.GetName(i), BsonValue.Create(readPlaces.GetValue(i)));
|
||||
}
|
||||
places.InsertOne(document);
|
||||
}
|
||||
readPlaces.Close();
|
||||
psqlPlaces.Cancel();
|
||||
|
||||
//Конфертация заказов
|
||||
|
||||
using var psqlTasks = new NpgsqlCommand("SELECT * FROM \"Tasks\"", psqlConn);
|
||||
using var readTasks = psqlTasks.ExecuteReader();
|
||||
|
||||
while (readTasks.Read())
|
||||
{
|
||||
var document = new BsonDocument();
|
||||
for (int i = 0; i < readTasks.FieldCount; i++)
|
||||
{
|
||||
string fieldName = readTasks.GetName(i);
|
||||
if (fieldName == "PlaceId") fieldName = "place_id";
|
||||
if (fieldName == "CookId") fieldName = "cook_id";
|
||||
if (fieldName == "BuyerId") fieldName = "buyer_id";
|
||||
if (fieldName == "MenuIds") fieldName = "menu_ids";
|
||||
document.Add(readTasks.GetName(i), BsonValue.Create(readTasks.GetValue(i)));
|
||||
}
|
||||
tasks.InsertOne(document);
|
||||
}
|
||||
readTasks.Close();
|
||||
psqlTasks.Cancel();
|
||||
psqlConn.Close();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user