Compare commits

...

4 Commits

Author SHA1 Message Date
b63ef37d04 Ну вроде все 2023-03-10 18:23:51 +04:00
59cb3e269f Базовая часть 2023-03-10 16:54:34 +04:00
eba969fe0b Merge branch 'LabWork03' into LabWork04 2023-03-10 16:45:03 +04:00
eaafd9b703 Исправление имен 2023-03-10 16:44:26 +04:00
26 changed files with 204 additions and 102 deletions

View File

@ -32,16 +32,16 @@
this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ингредиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.сушиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.списокИнгредиентовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ингредиентыПоСушиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.buttonUpdate = new System.Windows.Forms.Button();
this.buttonSetToFinish = new System.Windows.Forms.Button();
this.buttonSetToDone = new System.Windows.Forms.Button();
this.buttonSetToWork = new System.Windows.Forms.Button();
this.buttonCreateOrder = new System.Windows.Forms.Button();
this.dataGridView = new System.Windows.Forms.DataGridView();
this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.списокИнгредиентовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ингредиентыПоСушиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
@ -80,6 +80,37 @@
this.сушиToolStripMenuItem.Text = "Суши";
this.сушиToolStripMenuItem.Click += new System.EventHandler(this.SushiToolStripMenuItem_Click);
//
// отчетыToolStripMenuItem
//
this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.списокИнгредиентовToolStripMenuItem,
this.ингредиентыПоСушиToolStripMenuItem,
this.списокЗаказовToolStripMenuItem});
this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(60, 20);
this.отчетыToolStripMenuItem.Text = "Отчеты";
//
// списокИнгредиентовToolStripMenuItem
//
this.списокИнгредиентовToolStripMenuItem.Name = "списокИнгредиентовToolStripMenuItem";
this.списокИнгредиентовToolStripMenuItem.Size = new System.Drawing.Size(203, 22);
this.списокИнгредиентовToolStripMenuItem.Text = "Список суши";
this.списокИнгредиентовToolStripMenuItem.Click += new System.EventHandler(this.SushiListToolStripMenuItem_Click);
//
// ингредиентыПоСушиToolStripMenuItem
//
this.ингредиентыПоСушиToolStripMenuItem.Name = "ингредиентыПоСушиToolStripMenuItem";
this.ингредиентыПоСушиToolStripMenuItem.Size = new System.Drawing.Size(203, 22);
this.ингредиентыПоСушиToolStripMenuItem.Text = "Суши с ингредиентами";
this.ингредиентыПоСушиToolStripMenuItem.Click += new System.EventHandler(this.SushiIngredientToolStripMenuItem_Click);
//
// списокЗаказовToolStripMenuItem
//
this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(203, 22);
this.списокЗаказовToolStripMenuItem.Text = "Список заказов";
this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.OrdersToolStripMenuItem_Click);
//
// buttonUpdate
//
this.buttonUpdate.Location = new System.Drawing.Point(780, 314);
@ -147,37 +178,6 @@
this.dataGridView.Size = new System.Drawing.Size(755, 426);
this.dataGridView.TabIndex = 7;
//
// отчетыToolStripMenuItem
//
this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.списокИнгредиентовToolStripMenuItem,
this.ингредиентыПоСушиToolStripMenuItem,
this.списокЗаказовToolStripMenuItem});
this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(60, 20);
this.отчетыToolStripMenuItem.Text = "Отчеты";
//
// списокИнгредиентовToolStripMenuItem
//
this.списокИнгредиентовToolStripMenuItem.Name = "списокИнгредиентовToolStripMenuItem";
this.списокИнгредиентовToolStripMenuItem.Size = new System.Drawing.Size(198, 22);
this.списокИнгредиентовToolStripMenuItem.Text = "Список ингредиентов";
this.списокИнгредиентовToolStripMenuItem.Click += new System.EventHandler(this.IngredientToolStripMenuItem_Click);
//
// ингредиентыПоСушиToolStripMenuItem
//
this.ингредиентыПоСушиToolStripMenuItem.Name = "ингредиентыПоСушиToolStripMenuItem";
this.ингредиентыПоСушиToolStripMenuItem.Size = new System.Drawing.Size(198, 22);
this.ингредиентыПоСушиToolStripMenuItem.Text = "Ингредиенты по суши";
this.ингредиентыПоСушиToolStripMenuItem.Click += new System.EventHandler(this.IngredientSushiToolStripMenuItem_Click);
//
// списокЗаказовToolStripMenuItem
//
this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(198, 22);
this.списокЗаказовToolStripMenuItem.Text = "Список заказов";
this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.OrdersToolStripMenuItem_Click);
//
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);

View File

@ -145,17 +145,17 @@ namespace SushiBarView
{
LoadData();
}
private void IngredientToolStripMenuItem_Click(object sender, EventArgs e)
private void SushiListToolStripMenuItem_Click(object sender, EventArgs e)
{
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
if (dialog.ShowDialog() == DialogResult.OK)
{
_reportLogic.SaveIngredientsToWordFile(new ReportBindingModel { FileName = dialog.FileName });
_reportLogic.SaveListSushiToWordFile(new ReportBindingModel { FileName = dialog.FileName });
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void IngredientSushiToolStripMenuItem_Click(object sender, EventArgs e)
private void SushiIngredientToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormReportSushiIngredients));
if (service is FormReportSushiIngredients form)

View File

@ -18,7 +18,7 @@ namespace SushiBarView
InitializeComponent();
_logger = logger;
_logic = logic;
reportViewer = new ReportViewer
reportViewer = new ReportViewer
{
Dock = DockStyle.Fill
};

View File

@ -27,8 +27,8 @@ namespace SushiBarView
dataGridView.Rows.Clear();
foreach (var elem in dict)
{
dataGridView.Rows.Add(new object[] { elem.IngredientName, "", "" });
foreach (var listElem in elem.ListSushi)
dataGridView.Rows.Add(new object[] { elem.SushiName, "", "" });
foreach (var listElem in elem.Ingredients)
{
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
}

View File

@ -30,8 +30,8 @@
{
this.dataGridView = new System.Windows.Forms.DataGridView();
this.buttonSaveToExcel = new System.Windows.Forms.Button();
this.ColumnIngredient = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnSushi = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnIngredient = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
@ -46,8 +46,8 @@
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.ColumnIngredient,
this.ColumnSushi,
this.ColumnIngredient,
this.ColumnCount});
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Bottom;
this.dataGridView.Location = new System.Drawing.Point(0, 47);
@ -70,13 +70,6 @@
this.buttonSaveToExcel.UseVisualStyleBackColor = true;
this.buttonSaveToExcel.Click += new System.EventHandler(this.ButtonSaveToExcel_Click);
//
// ColumnIngredient
//
this.ColumnIngredient.HeaderText = "Ингредиент";
this.ColumnIngredient.Name = "ColumnIngredient";
this.ColumnIngredient.ReadOnly = true;
this.ColumnIngredient.Width = 200;
//
// ColumnSushi
//
this.ColumnSushi.HeaderText = "Суши";
@ -84,6 +77,13 @@
this.ColumnSushi.ReadOnly = true;
this.ColumnSushi.Width = 200;
//
// ColumnIngredient
//
this.ColumnIngredient.HeaderText = "Ингредиент";
this.ColumnIngredient.Name = "ColumnIngredient";
this.ColumnIngredient.ReadOnly = true;
this.ColumnIngredient.Width = 200;
//
// ColumnCount
//
this.ColumnCount.HeaderText = "Количество";
@ -110,8 +110,8 @@
private System.Windows.Forms.DataGridView dataGridView;
private System.Windows.Forms.Button buttonSaveToExcel;
private DataGridViewTextBoxColumn ColumnIngredient;
private DataGridViewTextBoxColumn ColumnSushi;
private DataGridViewTextBoxColumn ColumnIngredient;
private DataGridViewTextBoxColumn ColumnCount;
}
}

View File

@ -29,6 +29,10 @@
<DataField>SushiName</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="OrderStatus">
<DataField>OrderStatus</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Sum">
<DataField>Sum</DataField>
<rd:TypeName>System.Decimal</rd:TypeName>
@ -127,6 +131,9 @@
<TablixColumn>
<Width>2.5cm</Width>
</TablixColumn>
<TablixColumn>
<Width>2.5cm</Width>
</TablixColumn>
</TablixColumns>
<TablixRows>
<TablixRow>
@ -228,6 +235,38 @@
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="Textbox2">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Статус</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox2</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="Textbox7">
@ -357,6 +396,36 @@
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="OrderStatus">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!OrderStatus.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>OrderStatus</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="Sum">
@ -397,6 +466,7 @@
<TablixMember />
<TablixMember />
<TablixMember />
<TablixMember />
</TablixMembers>
</TablixColumnHierarchy>
<TablixRowHierarchy>
@ -413,7 +483,7 @@
<Top>2.48391cm</Top>
<Left>0.55245cm</Left>
<Height>1.2cm</Height>
<Width>16.44755cm</Width>
<Width>18.94755cm</Width>
<ZIndex>2</ZIndex>
<Style>
<Border>

View File

@ -19,8 +19,8 @@
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.ReportViewer.WinForms" Version="10.0.40219.1" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.1" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.2" />
<PackageReference Include="ReportViewerCore.WinForms" Version="15.1.17" />
</ItemGroup>
<ItemGroup>

View File

@ -12,7 +12,7 @@ namespace SushiBarBusinessLogic.BusinessLogics
{
private readonly IIngredientStorage _ingredientStorage;
private readonly ISushiStorage _productStorage;
private readonly ISushiStorage _sushiStorage;
private readonly IOrderStorage _orderStorage;
@ -25,7 +25,7 @@ namespace SushiBarBusinessLogic.BusinessLogics
public ReportLogic(ISushiStorage productStorage, IIngredientStorage ingredientStorage, IOrderStorage orderStorage,
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
{
_productStorage = productStorage;
_sushiStorage = productStorage;
_ingredientStorage = ingredientStorage;
_orderStorage = orderStorage;
@ -42,24 +42,25 @@ namespace SushiBarBusinessLogic.BusinessLogics
{
var ingredients = _ingredientStorage.GetFullList();
var products = _productStorage.GetFullList();
var sushiList = _sushiStorage.GetFullList();
var list = new List<ReportSushiIngredientViewModel>();
foreach (var ingredient in ingredients)
foreach (var sushi in sushiList)
{
var record = new ReportSushiIngredientViewModel
{
IngredientName = ingredient.IngredientName,
ListSushi = new List<(string, int)>(),
SushiName = sushi.SushiName,
Ingredients = new(),
TotalCount = 0
};
foreach (var product in products)
foreach (var ingredient in ingredients)
{
if (product.SushiIngredients.ContainsKey(ingredient.Id))
if (sushi.SushiIngredients.ContainsKey(ingredient.Id))
{
record.ListSushi.Add(new(product.SushiName, product.SushiIngredients[ingredient.Id].Item2));
record.TotalCount += product.SushiIngredients[ingredient.Id].Item2;
record.Ingredients.Add(new(ingredient.IngredientName,
sushi.SushiIngredients[ingredient.Id].Item2));
record.TotalCount += sushi.SushiIngredients[ingredient.Id].Item2;
}
}
@ -82,22 +83,23 @@ namespace SushiBarBusinessLogic.BusinessLogics
Id = x.Id,
DateCreate = x.DateCreate,
SushiName = x.SushiName,
OrderStatus = x.Status.ToString(),
Sum = x.Sum
})
.ToList();
}
/// <summary>
/// Сохранение ингредиентов в файл-Word
/// Сохранение суши в файл-Word
/// </summary>
/// <param name="model"></param>
public void SaveIngredientsToWordFile(ReportBindingModel model)
public void SaveListSushiToWordFile(ReportBindingModel model)
{
_saveToWord.CreateDoc(new WordInfo
{
FileName = model.FileName,
Title = "Список ингредиентов",
Ingredients = _ingredientStorage.GetFullList()
Title = "Список суши",
ListSushi = _sushiStorage.GetFullList()
});
}
@ -110,7 +112,7 @@ namespace SushiBarBusinessLogic.BusinessLogics
_saveToExcel.CreateReport(new ExcelInfo
{
FileName = model.FileName,
Title = "Список ингредиентов",
Title = "Список суши",
SushiIngredients = GetSushiIngredient()
});
}

View File

@ -34,18 +34,18 @@ namespace SushiBarBusinessLogic.OfficePackage
{
ColumnName = "A",
RowIndex = rowIndex,
Text = pc.IngredientName,
Text = pc.SushiName,
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
foreach (var (Sushi, Count) in pc.ListSushi)
foreach (var (Ingredient, Count) in pc.Ingredients)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = rowIndex,
Text = Sushi,
Text = Ingredient,
StyleInfo = ExcelStyleInfoType.TextWithBroder
});

View File

@ -11,11 +11,11 @@ namespace SushiBarBusinessLogic.OfficePackage
CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center });
CreateParagraph(new PdfParagraph { Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center });
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm" });
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "3cm" });
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Номер", "Дата заказа", "Суши", "Сумма" },
Texts = new List<string> { "Номер", "Дата заказа", "Суши", "Статус заказа","Сумма" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
@ -24,7 +24,7 @@ namespace SushiBarBusinessLogic.OfficePackage
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.SushiName, order.Sum.ToString() },
Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.SushiName, order.OrderStatus, order.Sum.ToString() },
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});

View File

@ -19,11 +19,14 @@ namespace SushiBarBusinessLogic.OfficePackage
}
});
foreach (var ingredient in info.Ingredients)
foreach (var sushi in info.ListSushi)
{
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)> { (ingredient.IngredientName, new WordTextProperties { Size = "24", }) },
Texts = new List<(string, WordTextProperties)> {
(sushi.SushiName+' ', new WordTextProperties { Size = "24", Bold = true }),
(sushi.Price.ToString(), new WordTextProperties { Size = "24" })
},
TextProperties = new WordTextProperties
{
Size = "24",

View File

@ -8,6 +8,6 @@ namespace SushiBarBusinessLogic.OfficePackage.HelperModels
public string Title { get; set; } = string.Empty;
public List<IngredientViewModel> Ingredients { get; set; } = new();
public List<SushiViewModel> ListSushi { get; set; } = new();
}
}

View File

@ -22,7 +22,7 @@ namespace SushiBarContracts.BusinessLogicsContracts
/// Сохранение индгредиентов в файл-Word
/// </summary>
/// <param name="model"></param>
void SaveIngredientsToWordFile(ReportBindingModel model);
void SaveListSushiToWordFile(ReportBindingModel model);
/// <summary>
/// Сохранение индгредиентов с указаеним суши в файл-Excel

View File

@ -8,6 +8,8 @@
public string SushiName { get; set; } = string.Empty;
public string OrderStatus { get; set; } = string.Empty;
public double Sum { get; set; }
}
}

View File

@ -2,10 +2,10 @@
{
public class ReportSushiIngredientViewModel
{
public string IngredientName { get; set; } = string.Empty;
public string SushiName { get; set; } = string.Empty;
public int TotalCount { get; set; }
public List<(string Sushi, int Count)> ListSushi { get; set; } = new();
public List<(string Ingredient, int Count)> Ingredients { get; set; } = new();
}
}

View File

@ -39,11 +39,19 @@ namespace SushiBarDatabaseImplement.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
if (!model.Id.HasValue)
if (!model.Id.HasValue && !model.DateFrom.HasValue)
{
return new();
}
using var context = new SushiBarDatabase();
if (model.DateFrom.HasValue)
{
return context.Orders
.Include(x => x.Sushi)
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
.Select(x => x.GetViewModel)
.ToList();
}
return context.Orders
.Include(x => x.Sushi)
.Where(x => x.Id == model.Id)

View File

@ -12,7 +12,7 @@ namespace SushiBarDatabaseImplement.Implements
public List<SushiViewModel> GetFullList()
{
using var context = new SushiBarDatabase();
return context.SushiList
return context.ListSushi
.Include(x => x.Ingredients)
.ThenInclude(x => x.Ingredient)
.ToList()
@ -27,7 +27,7 @@ namespace SushiBarDatabaseImplement.Implements
return new();
}
using var context = new SushiBarDatabase();
return context.SushiList
return context.ListSushi
.Include(x => x.Ingredients)
.ThenInclude(x => x.Ingredient)
.Where(x => x.SushiName.Contains(model.SushiName))
@ -43,7 +43,7 @@ namespace SushiBarDatabaseImplement.Implements
return null;
}
using var context = new SushiBarDatabase();
return context.SushiList
return context.ListSushi
.Include(x => x.Ingredients)
.ThenInclude(x => x.Ingredient)
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.SushiName) && x.SushiName == model.SushiName) ||
@ -59,7 +59,7 @@ namespace SushiBarDatabaseImplement.Implements
{
return null;
}
context.SushiList.Add(newSushi);
context.ListSushi.Add(newSushi);
context.SaveChanges();
return newSushi.GetViewModel;
}
@ -70,7 +70,7 @@ namespace SushiBarDatabaseImplement.Implements
using var transaction = context.Database.BeginTransaction();
try
{
var sushi = context.SushiList.FirstOrDefault(rec => rec.Id == model.Id);
var sushi = context.ListSushi.FirstOrDefault(rec => rec.Id == model.Id);
if (sushi == null)
{
return null;
@ -91,13 +91,13 @@ namespace SushiBarDatabaseImplement.Implements
public SushiViewModel? Delete(SushiBindingModel model)
{
using var context = new SushiBarDatabase();
var element = context.SushiList
var element = context.ListSushi
.Include(x => x.Ingredients)
.Include(x => x.Orders)
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.SushiList.Remove(element);
context.ListSushi.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}

View File

@ -93,7 +93,7 @@ namespace SushiBarDatabaseImplement.Migrations
b.HasKey("Id");
b.ToTable("SushiList");
b.ToTable("ListSushi");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.SushiIngredient", b =>

View File

@ -44,7 +44,7 @@ namespace SushiBarDatabaseImplement.Migrations
});
migrationBuilder.CreateTable(
name: "SushiList",
name: "ListSushi",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
@ -54,7 +54,7 @@ namespace SushiBarDatabaseImplement.Migrations
},
constraints: table =>
{
table.PrimaryKey("PK_SushiList", x => x.Id);
table.PrimaryKey("PK_ListSushi", x => x.Id);
});
migrationBuilder.CreateTable(
@ -77,9 +77,9 @@ namespace SushiBarDatabaseImplement.Migrations
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_SushiIngredients_SushiList_SushiId",
name: "FK_SushiIngredients_ListSushi_SushiId",
column: x => x.SushiId,
principalTable: "SushiList",
principalTable: "ListSushi",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
@ -108,7 +108,7 @@ namespace SushiBarDatabaseImplement.Migrations
name: "Ingredients");
migrationBuilder.DropTable(
name: "SushiList");
name: "ListSushi");
}
}
}

View File

@ -95,7 +95,7 @@ namespace SushiBarDatabaseImplement.Migrations
b.HasKey("Id");
b.ToTable("SushiList");
b.ToTable("ListSushi");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.SushiIngredient", b =>

View File

@ -16,10 +16,10 @@ namespace SushiBarDatabaseImplement.Migrations
column: "SushiId");
migrationBuilder.AddForeignKey(
name: "FK_Orders_SushiList_SushiId",
name: "FK_Orders_ListSushi_SushiId",
table: "Orders",
column: "SushiId",
principalTable: "SushiList",
principalTable: "ListSushi",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
@ -28,7 +28,7 @@ namespace SushiBarDatabaseImplement.Migrations
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Orders_SushiList_SushiId",
name: "FK_Orders_ListSushi_SushiId",
table: "Orders");
migrationBuilder.DropIndex(

View File

@ -88,7 +88,7 @@ namespace SushiBarDatabaseImplement.Migrations
b.HasKey("Id");
b.ToTable("SushiList");
b.ToTable("ListSushi");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.SushiIngredient", b =>

View File

@ -81,7 +81,7 @@ namespace SushiBarDatabaseImplement.Models
}
context.SaveChanges();
}
var sushi = context.SushiList.First(x => x.Id == Id);
var sushi = context.ListSushi.First(x => x.Id == Id);
foreach (var si in model.SushiIngredients)
{
context.SushiIngredients.Add(new SushiIngredient

View File

@ -16,7 +16,7 @@ namespace SushiBarDatabaseImplement
public virtual DbSet<Ingredient> Ingredients { set; get; }
public virtual DbSet<Sushi> SushiList { set; get; }
public virtual DbSet<Sushi> ListSushi { set; get; }
public virtual DbSet<SushiIngredient> SushiIngredients { set; get; }

View File

@ -25,6 +25,13 @@ namespace SushiBarFileImplement.Implements
{
return new();
}
if (model.DateFrom.HasValue)
{
return source.Orders
.Where(x => x.Id.Equals(model.Id) && x.DateCreate >= model.DateFrom)
.Select(x => GetViewModel(x))
.ToList();
}
return source.Orders.Where(x => x.Id.Equals(model.Id)).Select(x => GetViewModel(x)).ToList();
}

View File

@ -29,6 +29,16 @@ namespace SushiBarListImplement.Implements
{
return result;
}
if (model.DateFrom.HasValue)
{
foreach (var order in _source.Orders)
{
if (order.Id == model.Id && order.DateCreate >= model.DateFrom)
{
result.Add(GetViewModel(order));
}
}
}
foreach (var order in _source.Orders)
{
if (order.Id == model.Id)