Compare commits
No commits in common. "LabRabota3" and "main" have entirely different histories.
LabRabota3
...
main
25
AbstractFoodOrders/AbstractFoodOrders.sln
Normal file
25
AbstractFoodOrders/AbstractFoodOrders.sln
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.3.32929.385
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AbstractFoodOrdersView", "AbstractFoodOrdersView\AbstractFoodOrdersView.csproj", "{831CD419-7329-4082-9B2F-9EA0EE2EA4AC}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{831CD419-7329-4082-9B2F-9EA0EE2EA4AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{831CD419-7329-4082-9B2F-9EA0EE2EA4AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{831CD419-7329-4082-9B2F-9EA0EE2EA4AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{831CD419-7329-4082-9B2F-9EA0EE2EA4AC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {B6811B4E-9459-44E1-80D8-752C2718AB6A}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
@ -0,0 +1,11 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
39
AbstractFoodOrders/AbstractFoodOrdersView/Form1.Designer.cs
generated
Normal file
39
AbstractFoodOrders/AbstractFoodOrdersView/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
namespace AbstractFoodOrdersView
|
||||||
|
{
|
||||||
|
partial class Form1
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.components = new System.ComponentModel.Container();
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Text = "Form1";
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
10
AbstractFoodOrders/AbstractFoodOrdersView/Form1.cs
Normal file
10
AbstractFoodOrders/AbstractFoodOrdersView/Form1.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace AbstractFoodOrdersView
|
||||||
|
{
|
||||||
|
public partial class Form1 : Form
|
||||||
|
{
|
||||||
|
public Form1()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
17
AbstractFoodOrders/AbstractFoodOrdersView/Program.cs
Normal file
17
AbstractFoodOrders/AbstractFoodOrdersView/Program.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
namespace AbstractFoodOrdersView
|
||||||
|
{
|
||||||
|
internal static class Program
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The main entry point for the application.
|
||||||
|
/// </summary>
|
||||||
|
[STAThread]
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
|
// see https://aka.ms/applicationconfiguration.
|
||||||
|
ApplicationConfiguration.Initialize();
|
||||||
|
Application.Run(new Form1());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,27 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.5">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\FoodOrdersContracts\FoodOrdersContracts.csproj" />
|
|
||||||
<ProjectReference Include="..\FoodOrdersDataModel\FoodOrdersDataModel.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,21 +0,0 @@
|
|||||||
using FoodOrdersDatabaseImplement.Models;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace FoodOrdersDatabaseImplement
|
|
||||||
{
|
|
||||||
public class FoodOrdersDataBase : DbContext
|
|
||||||
{
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
||||||
{
|
|
||||||
if (optionsBuilder.IsConfigured == false)
|
|
||||||
{
|
|
||||||
optionsBuilder.UseNpgsql(@"Host=localhost;Port=5432;Database=FoodOrdersDatabaseFull_2;Username=postgres;Password=12345");
|
|
||||||
}
|
|
||||||
base.OnConfiguring(optionsBuilder);
|
|
||||||
}
|
|
||||||
public virtual DbSet<Component> Components { set; get; }
|
|
||||||
public virtual DbSet<Food> Foods { set; get; }
|
|
||||||
public virtual DbSet<FoodComponent> FoodComponents { set; get; }
|
|
||||||
public virtual DbSet<Order> Orders { set; get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,92 +0,0 @@
|
|||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.SearchModels;
|
|
||||||
using FoodOrdersContracts.StoragesContracts;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
using FoodOrdersDatabaseImplement;
|
|
||||||
using FoodOrdersDatabaseImplement.Models;
|
|
||||||
|
|
||||||
namespace FoodOrderDatabaseImplement.Implements
|
|
||||||
{
|
|
||||||
public class ComponentStorage : IComponentStorage
|
|
||||||
{
|
|
||||||
public List<ComponentViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
using var context = new FoodOrdersDataBase();
|
|
||||||
|
|
||||||
return context.Components.Select(x => x.GetViewModel).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ComponentViewModel> GetFilteredList(ComponentSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.ComponentName))
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
|
|
||||||
using var context = new FoodOrdersDataBase();
|
|
||||||
|
|
||||||
return context.Components.Where(x => x.ComponentName.Contains(model.ComponentName)).Select(x => x.GetViewModel).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ComponentViewModel? GetElement(ComponentSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
using var context = new FoodOrdersDataBase();
|
|
||||||
|
|
||||||
return context.Components.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ComponentName) && x.ComponentName == model.ComponentName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ComponentViewModel? Insert(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
var newComponent = Component.Create(model);
|
|
||||||
|
|
||||||
if (newComponent == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
using var context = new FoodOrdersDataBase();
|
|
||||||
|
|
||||||
context.Components.Add(newComponent);
|
|
||||||
context.SaveChanges();
|
|
||||||
|
|
||||||
return newComponent.GetViewModel;
|
|
||||||
}
|
|
||||||
public ComponentViewModel? Update(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new FoodOrdersDataBase();
|
|
||||||
|
|
||||||
var component = context.Components.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
|
|
||||||
if (component == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
component.Update(model);
|
|
||||||
context.SaveChanges();
|
|
||||||
|
|
||||||
return component.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ComponentViewModel? Delete(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new FoodOrdersDataBase();
|
|
||||||
|
|
||||||
var element = context.Components.FirstOrDefault(rec => rec.Id == model.Id);
|
|
||||||
|
|
||||||
if (element != null)
|
|
||||||
{
|
|
||||||
context.Components.Remove(element);
|
|
||||||
context.SaveChanges();
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,126 +0,0 @@
|
|||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.SearchModels;
|
|
||||||
using FoodOrdersContracts.StoragesContracts;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
using FoodOrdersDatabaseImplement;
|
|
||||||
using FoodOrdersDatabaseImplement.Models;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrderDatabaseImplement.Implements
|
|
||||||
{
|
|
||||||
public class FoodStorage : IFoodStorage
|
|
||||||
{
|
|
||||||
public List<FoodViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
using var context = new FoodOrdersDataBase();
|
|
||||||
|
|
||||||
return context.Foods
|
|
||||||
.Include(x => x.Components)
|
|
||||||
.ThenInclude(x => x.Component)
|
|
||||||
.ToList()
|
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<FoodViewModel> GetFilteredList(FoodSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.FoodName))
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
|
|
||||||
using var context = new FoodOrdersDataBase();
|
|
||||||
|
|
||||||
return context.Foods
|
|
||||||
.Include(x => x.Components)
|
|
||||||
.ThenInclude(x => x.Component)
|
|
||||||
.Where(x => x.FoodName.Contains(model.FoodName))
|
|
||||||
.ToList()
|
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public FoodViewModel? GetElement(FoodSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.FoodName) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
using var context = new FoodOrdersDataBase();
|
|
||||||
|
|
||||||
return context.Foods
|
|
||||||
.Include(x => x.Components)
|
|
||||||
.ThenInclude(x => x.Component)
|
|
||||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.FoodName) && x.FoodName == model.FoodName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FoodViewModel? Insert(FoodBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new FoodOrdersDataBase();
|
|
||||||
|
|
||||||
var newFood = Food.Create(context, model);
|
|
||||||
|
|
||||||
if (newFood == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
context.Foods.Add(newFood);
|
|
||||||
context.SaveChanges();
|
|
||||||
|
|
||||||
return newFood.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FoodViewModel? Update(FoodBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new FoodOrdersDataBase();
|
|
||||||
|
|
||||||
using var transaction = context.Database.BeginTransaction();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var package = context.Foods.FirstOrDefault(rec => rec.Id == model.Id);
|
|
||||||
|
|
||||||
if (package == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
package.Update(model);
|
|
||||||
context.SaveChanges();
|
|
||||||
package.UpdateComponents(context, model);
|
|
||||||
transaction.Commit();
|
|
||||||
|
|
||||||
return package.GetViewModel;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
transaction.Rollback();
|
|
||||||
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public FoodViewModel? Delete(FoodBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new FoodOrdersDataBase();
|
|
||||||
|
|
||||||
var element = context.Foods.Include(x => x.Components).FirstOrDefault(rec => rec.Id == model.Id);
|
|
||||||
|
|
||||||
if (element != null)
|
|
||||||
{
|
|
||||||
context.Foods.Remove(element);
|
|
||||||
context.SaveChanges();
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,94 +0,0 @@
|
|||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.SearchModels;
|
|
||||||
using FoodOrdersContracts.StoragesContracts;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
using FoodOrdersDatabaseImplement;
|
|
||||||
using FoodOrdersDatabaseImplement.Models;
|
|
||||||
|
|
||||||
namespace FoodOrderDatabaseImplement.Implements
|
|
||||||
{
|
|
||||||
public class OrderStorage : IOrderStorage
|
|
||||||
{
|
|
||||||
public List<OrderViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
using var context = new FoodOrdersDataBase();
|
|
||||||
|
|
||||||
return context.Orders.Select(x => x.GetViewModel).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
|
||||||
{
|
|
||||||
if (!model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
|
|
||||||
using var context = new FoodOrdersDataBase();
|
|
||||||
|
|
||||||
return context.Orders.Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
|
||||||
{
|
|
||||||
if (!model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
using var context = new FoodOrdersDataBase();
|
|
||||||
|
|
||||||
return context.Orders.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
var newOrder = Order.Create(model);
|
|
||||||
|
|
||||||
if (newOrder == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
using var context = new FoodOrdersDataBase();
|
|
||||||
|
|
||||||
context.Orders.Add(newOrder);
|
|
||||||
context.SaveChanges();
|
|
||||||
|
|
||||||
return newOrder.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? Update(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new FoodOrdersDataBase();
|
|
||||||
|
|
||||||
var order = context.Orders.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
|
|
||||||
if (order == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
order.Update(model);
|
|
||||||
context.SaveChanges();
|
|
||||||
|
|
||||||
return order.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? Delete(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new FoodOrdersDataBase();
|
|
||||||
|
|
||||||
var element = context.Orders.FirstOrDefault(rec => rec.Id == model.Id);
|
|
||||||
|
|
||||||
if (element != null)
|
|
||||||
{
|
|
||||||
context.Orders.Remove(element);
|
|
||||||
context.SaveChanges();
|
|
||||||
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,175 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using FoodOrdersDatabaseImplement;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace FoodOrderDatabaseImplement.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(FoodOrdersDataBase))]
|
|
||||||
[Migration("20230416163421_InitMigration")]
|
|
||||||
partial class InitMigration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("ProductVersion", "7.0.5")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
|
||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
|
||||||
|
|
||||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Component", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("ComponentName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<double>("Cost")
|
|
||||||
.HasColumnType("double precision");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Components");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Food", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("FoodName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<double>("Price")
|
|
||||||
.HasColumnType("double precision");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Foods");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.FoodComponent", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<int>("ComponentId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<int>("FoodId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("ComponentId");
|
|
||||||
|
|
||||||
b.HasIndex("FoodId");
|
|
||||||
|
|
||||||
b.ToTable("FoodComponents");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Order", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<DateTime>("DateCreate")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.Property<DateTime?>("DateImplement")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.Property<int>("FoodId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<string>("FoodName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<int>("Status")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<double>("Sum")
|
|
||||||
.HasColumnType("double precision");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("FoodId");
|
|
||||||
|
|
||||||
b.ToTable("Orders");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.FoodComponent", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("FoodOrdersDatabaseImplement.Models.Component", "Component")
|
|
||||||
.WithMany("FoodComponents")
|
|
||||||
.HasForeignKey("ComponentId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("FoodOrdersDatabaseImplement.Models.Food", "Food")
|
|
||||||
.WithMany("Components")
|
|
||||||
.HasForeignKey("FoodId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Component");
|
|
||||||
|
|
||||||
b.Navigation("Food");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Order", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("FoodOrdersDatabaseImplement.Models.Food", "Food")
|
|
||||||
.WithMany("Orders")
|
|
||||||
.HasForeignKey("FoodId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Food");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Component", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("FoodComponents");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Food", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Components");
|
|
||||||
|
|
||||||
b.Navigation("Orders");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,127 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace FoodOrderDatabaseImplement.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class InitMigration : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Components",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
ComponentName = table.Column<string>(type: "text", nullable: false),
|
|
||||||
Cost = table.Column<double>(type: "double precision", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Components", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Foods",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
FoodName = table.Column<string>(type: "text", nullable: false),
|
|
||||||
Price = table.Column<double>(type: "double precision", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Foods", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "FoodComponents",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
FoodId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
ComponentId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
Count = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_FoodComponents", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_FoodComponents_Components_ComponentId",
|
|
||||||
column: x => x.ComponentId,
|
|
||||||
principalTable: "Components",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_FoodComponents_Foods_FoodId",
|
|
||||||
column: x => x.FoodId,
|
|
||||||
principalTable: "Foods",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Orders",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
FoodId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
FoodName = table.Column<string>(type: "text", nullable: false),
|
|
||||||
Count = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
Sum = table.Column<double>(type: "double precision", nullable: false),
|
|
||||||
Status = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
DateCreate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
||||||
DateImplement = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Orders_Foods_FoodId",
|
|
||||||
column: x => x.FoodId,
|
|
||||||
principalTable: "Foods",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_FoodComponents_ComponentId",
|
|
||||||
table: "FoodComponents",
|
|
||||||
column: "ComponentId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_FoodComponents_FoodId",
|
|
||||||
table: "FoodComponents",
|
|
||||||
column: "FoodId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Orders_FoodId",
|
|
||||||
table: "Orders",
|
|
||||||
column: "FoodId");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "FoodComponents");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Orders");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Components");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Foods");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,172 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using FoodOrdersDatabaseImplement;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace FoodOrderDatabaseImplement.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(FoodOrdersDataBase))]
|
|
||||||
partial class FoodOrdersDataBaseModelSnapshot : ModelSnapshot
|
|
||||||
{
|
|
||||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("ProductVersion", "7.0.5")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
|
||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
|
||||||
|
|
||||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Component", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("ComponentName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<double>("Cost")
|
|
||||||
.HasColumnType("double precision");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Components");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Food", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("FoodName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<double>("Price")
|
|
||||||
.HasColumnType("double precision");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Foods");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.FoodComponent", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<int>("ComponentId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<int>("FoodId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("ComponentId");
|
|
||||||
|
|
||||||
b.HasIndex("FoodId");
|
|
||||||
|
|
||||||
b.ToTable("FoodComponents");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Order", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<DateTime>("DateCreate")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.Property<DateTime?>("DateImplement")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.Property<int>("FoodId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<string>("FoodName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<int>("Status")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<double>("Sum")
|
|
||||||
.HasColumnType("double precision");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("FoodId");
|
|
||||||
|
|
||||||
b.ToTable("Orders");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.FoodComponent", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("FoodOrdersDatabaseImplement.Models.Component", "Component")
|
|
||||||
.WithMany("FoodComponents")
|
|
||||||
.HasForeignKey("ComponentId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("FoodOrdersDatabaseImplement.Models.Food", "Food")
|
|
||||||
.WithMany("Components")
|
|
||||||
.HasForeignKey("FoodId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Component");
|
|
||||||
|
|
||||||
b.Navigation("Food");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Order", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("FoodOrdersDatabaseImplement.Models.Food", "Food")
|
|
||||||
.WithMany("Orders")
|
|
||||||
.HasForeignKey("FoodId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Food");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Component", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("FoodComponents");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Food", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Components");
|
|
||||||
|
|
||||||
b.Navigation("Orders");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
|
|
||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
using FoodOrdersDataModel.Models;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
|
|
||||||
namespace FoodOrdersDatabaseImplement.Models
|
|
||||||
{
|
|
||||||
public class Component : IComponentModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public string ComponentName { get; private set; } = string.Empty;
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public double Cost { get; set; }
|
|
||||||
|
|
||||||
[ForeignKey("ComponentId")]
|
|
||||||
public virtual List<FoodComponent> FoodComponents { get; set; } = new();
|
|
||||||
|
|
||||||
public static Component? Create(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Component()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
ComponentName = model.ComponentName,
|
|
||||||
Cost = model.Cost
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public static Component Create(ComponentViewModel model)
|
|
||||||
{
|
|
||||||
return new Component
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
ComponentName = model.ComponentName,
|
|
||||||
Cost = model.Cost
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public void Update(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ComponentName = model.ComponentName;
|
|
||||||
Cost = model.Cost;
|
|
||||||
}
|
|
||||||
public ComponentViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
ComponentName = ComponentName,
|
|
||||||
Cost = Cost
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,96 +0,0 @@
|
|||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
using FoodOrdersDataModel.Models;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
|
|
||||||
namespace FoodOrdersDatabaseImplement.Models
|
|
||||||
{
|
|
||||||
public class Food : IFoodModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public string FoodName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public double Price { get; set; }
|
|
||||||
private Dictionary<int, (IComponentModel, int)>? _foodComponents = null;
|
|
||||||
|
|
||||||
[NotMapped]
|
|
||||||
public Dictionary<int, (IComponentModel, int)> FoodComponents
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_foodComponents == null)
|
|
||||||
{
|
|
||||||
_foodComponents = Components.ToDictionary(recPC => recPC.ComponentId, recPC => (recPC.Component as IComponentModel, recPC.Count));
|
|
||||||
}
|
|
||||||
return _foodComponents;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[ForeignKey("FoodId")]
|
|
||||||
public virtual List<FoodComponent> Components { get; set; } = new();
|
|
||||||
|
|
||||||
[ForeignKey("FoodId")]
|
|
||||||
public virtual List<Order> Orders { get; set; } = new();
|
|
||||||
public static Food Create(FoodOrdersDataBase context, FoodBindingModel model)
|
|
||||||
{
|
|
||||||
return new Food()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
FoodName = model.FoodName,
|
|
||||||
Price = model.Price,
|
|
||||||
Components = model.FoodComponents.Select(x => new FoodComponent
|
|
||||||
{
|
|
||||||
Component = context.Components.First(y => y.Id == x.Key),
|
|
||||||
Count = x.Value.Item2
|
|
||||||
}).ToList()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public void Update(FoodBindingModel model)
|
|
||||||
{
|
|
||||||
FoodName = model.FoodName;
|
|
||||||
Price = model.Price;
|
|
||||||
}
|
|
||||||
public FoodViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
FoodName = FoodName,
|
|
||||||
Price = Price,
|
|
||||||
FoodComponents = FoodComponents
|
|
||||||
};
|
|
||||||
public void UpdateComponents(FoodOrdersDataBase context, FoodBindingModel model)
|
|
||||||
{
|
|
||||||
var foodComponents = context.FoodComponents.Where(rec => rec.FoodId == model.Id).ToList();
|
|
||||||
|
|
||||||
if (foodComponents != null && foodComponents.Count > 0)
|
|
||||||
{ // удалили те, которых нет в модели
|
|
||||||
context.FoodComponents.RemoveRange(foodComponents.Where(rec => !model.FoodComponents.ContainsKey(rec.ComponentId)));
|
|
||||||
context.SaveChanges();
|
|
||||||
// обновили количество у существующих записей
|
|
||||||
foreach (var updateComponent in foodComponents)
|
|
||||||
{
|
|
||||||
updateComponent.Count = model.FoodComponents[updateComponent.ComponentId].Item2;
|
|
||||||
model.FoodComponents.Remove(updateComponent.ComponentId);
|
|
||||||
}
|
|
||||||
context.SaveChanges();
|
|
||||||
}
|
|
||||||
|
|
||||||
var food = context.Foods.First(x => x.Id == Id);
|
|
||||||
|
|
||||||
foreach (var pc in model.FoodComponents)
|
|
||||||
{
|
|
||||||
context.FoodComponents.Add(new FoodComponent
|
|
||||||
{
|
|
||||||
Food = food,
|
|
||||||
Component = context.Components.First(x => x.Id == pc.Key),
|
|
||||||
Count = pc.Value.Item2
|
|
||||||
});
|
|
||||||
context.SaveChanges();
|
|
||||||
}
|
|
||||||
_foodComponents = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace FoodOrdersDatabaseImplement.Models
|
|
||||||
{
|
|
||||||
public class FoodComponent
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public int FoodId { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public int ComponentId { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public int Count { get; set; }
|
|
||||||
|
|
||||||
public virtual Component Component { get; set; } = new();
|
|
||||||
public virtual Food Food { get; set; } = new();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,76 +0,0 @@
|
|||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
using FoodOrdersDataModel.Enums;
|
|
||||||
using FoodOrdersDataModel.Models;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace FoodOrdersDatabaseImplement.Models
|
|
||||||
{
|
|
||||||
public class Order : IOrderModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
|
|
||||||
public int FoodId { get; private set; }
|
|
||||||
|
|
||||||
public string FoodName { get; private set; } = string.Empty;
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public int Count { get; private set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public double Sum { get; private set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public DateTime DateCreate { get; private set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
|
||||||
|
|
||||||
public DateTime? DateImplement { get; private set; }
|
|
||||||
|
|
||||||
public virtual Food Food { get; set; }
|
|
||||||
|
|
||||||
public static Order? Create(OrderBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Order()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
FoodId = model.FoodId,
|
|
||||||
FoodName = model.FoodName,
|
|
||||||
Count = model.Count,
|
|
||||||
Sum = model.Sum,
|
|
||||||
Status = model.Status,
|
|
||||||
DateCreate = model.DateCreate,
|
|
||||||
DateImplement = model.DateImplement
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update(OrderBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = model.Status;
|
|
||||||
DateImplement = model.DateImplement;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
FoodId = FoodId,
|
|
||||||
FoodName = FoodName,
|
|
||||||
Count = Count,
|
|
||||||
Sum = Sum,
|
|
||||||
Status = Status,
|
|
||||||
DateCreate = DateCreate,
|
|
||||||
DateImplement = DateImplement
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
using FoodOrderFileImplement.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace FoodOrderFileImplement
|
|
||||||
{
|
|
||||||
public class DataFileSingleton
|
|
||||||
{
|
|
||||||
private static DataFileSingleton? instance;
|
|
||||||
|
|
||||||
private readonly string ComponentFileName = "Component.xml";
|
|
||||||
private readonly string OrderFileName = "Order.xml";
|
|
||||||
private readonly string FoodFileName = "Food.xml";
|
|
||||||
|
|
||||||
public List<Component> Components { get; private set; }
|
|
||||||
public List<Order> Orders { get; private set; }
|
|
||||||
public List<Food> Foods { get; private set; }
|
|
||||||
|
|
||||||
public static DataFileSingleton GetInstance()
|
|
||||||
{
|
|
||||||
if (instance == null)
|
|
||||||
{
|
|
||||||
instance = new DataFileSingleton();
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement);
|
|
||||||
public void SaveFoods() => SaveData(Foods, FoodFileName, "Foods", x => x.GetXElement);
|
|
||||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
|
||||||
|
|
||||||
private DataFileSingleton()
|
|
||||||
{
|
|
||||||
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
|
||||||
Foods = LoadData(FoodFileName, "Food", x => Food.Create(x)!)!;
|
|
||||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
|
||||||
{
|
|
||||||
if (File.Exists(filename))
|
|
||||||
{
|
|
||||||
return XDocument.Load(filename)?.Root?.Elements(xmlNodeName)?.Select(selectFunction)?.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new List<T>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void SaveData<T>(List<T> data, string filename, string xmlNodeName, Func<T, XElement> selectFunction)
|
|
||||||
{
|
|
||||||
if (data != null)
|
|
||||||
{
|
|
||||||
new XDocument(new XElement(xmlNodeName, data.Select(selectFunction).ToArray())).Save(filename);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\FoodOrdersContracts\FoodOrdersContracts.csproj" />
|
|
||||||
<ProjectReference Include="..\FoodOrdersDataModel\FoodOrdersDataModel.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,91 +0,0 @@
|
|||||||
using FoodOrderFileImplement.Models;
|
|
||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.SearchModels;
|
|
||||||
using FoodOrdersContracts.StoragesContracts;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrderFileImplement.Implements
|
|
||||||
{
|
|
||||||
public class ComponentStorage : IComponentStorage
|
|
||||||
{
|
|
||||||
private readonly DataFileSingleton source;
|
|
||||||
|
|
||||||
public ComponentStorage()
|
|
||||||
{
|
|
||||||
source = DataFileSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ComponentViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
return source.Components.Select(x => x.GetViewModel).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ComponentViewModel> GetFilteredList(ComponentSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.ComponentName))
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
|
|
||||||
return source.Components.Where(x => x.ComponentName.Contains(model.ComponentName)).Select(x => x.GetViewModel).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ComponentViewModel? GetElement(ComponentSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return source.Components.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ComponentName) && x.ComponentName == model.ComponentName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ComponentViewModel? Insert(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = source.Components.Count > 0 ? source.Components.Max(x => x.Id) + 1 : 1;
|
|
||||||
var newComponent = Component.Create(model);
|
|
||||||
|
|
||||||
if (newComponent == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
source.Components.Add(newComponent);
|
|
||||||
source.SaveComponents();
|
|
||||||
|
|
||||||
return newComponent.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ComponentViewModel? Update(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
var component = source.Components.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
if (component == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
component.Update(model);
|
|
||||||
source.SaveComponents();
|
|
||||||
|
|
||||||
return component.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ComponentViewModel? Delete(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
var element = source.Components.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
|
|
||||||
if (element != null)
|
|
||||||
{
|
|
||||||
source.Components.Remove(element);
|
|
||||||
source.SaveComponents();
|
|
||||||
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,94 +0,0 @@
|
|||||||
using FoodOrderFileImplement.Models;
|
|
||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.SearchModels;
|
|
||||||
using FoodOrdersContracts.StoragesContracts;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrderFileImplement.Implements
|
|
||||||
{
|
|
||||||
public class FoodStorage : IFoodStorage
|
|
||||||
{
|
|
||||||
private readonly DataFileSingleton source;
|
|
||||||
|
|
||||||
public FoodStorage()
|
|
||||||
{
|
|
||||||
source = DataFileSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<FoodViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
return source.Foods.Select(x => x.GetViewModel).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<FoodViewModel> GetFilteredList(FoodSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.FoodName))
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
|
|
||||||
return source.Foods.Where(x => x.FoodName.Contains(model.FoodName)).Select(x => x.GetViewModel).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public FoodViewModel? GetElement(FoodSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.FoodName) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return source.Foods.FirstOrDefault(x => (!string.IsNullOrEmpty(model.FoodName) && x.FoodName == model.FoodName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FoodViewModel? Insert(FoodBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = source.Foods.Count > 0 ? source.Foods.Max(x => x.Id) + 1 : 1;
|
|
||||||
var newFood = Food.Create(model);
|
|
||||||
|
|
||||||
if (newFood == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
source.Foods.Add(newFood);
|
|
||||||
source.SaveFoods();
|
|
||||||
|
|
||||||
return newFood.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FoodViewModel? Update(FoodBindingModel model)
|
|
||||||
{
|
|
||||||
var food = source.Foods.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
|
|
||||||
if (food == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
food.Update(model);
|
|
||||||
source.SaveFoods();
|
|
||||||
|
|
||||||
return food.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FoodViewModel? Delete(FoodBindingModel model)
|
|
||||||
{
|
|
||||||
var element = source.Foods.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
|
|
||||||
if (element != null)
|
|
||||||
{
|
|
||||||
source.Foods.Remove(element);
|
|
||||||
source.SaveFoods();
|
|
||||||
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,94 +0,0 @@
|
|||||||
using FoodOrderFileImplement.Models;
|
|
||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.SearchModels;
|
|
||||||
using FoodOrdersContracts.StoragesContracts;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrderFileImplement.Implements
|
|
||||||
{
|
|
||||||
public class OrderStorage : IOrderStorage
|
|
||||||
{
|
|
||||||
private readonly DataFileSingleton source;
|
|
||||||
|
|
||||||
public OrderStorage()
|
|
||||||
{
|
|
||||||
source = DataFileSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<OrderViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
return source.Orders.Select(x => x.GetViewModel).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
|
||||||
{
|
|
||||||
if (!model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
|
|
||||||
return source.Orders.Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
|
||||||
{
|
|
||||||
if (!model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return source.Orders.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = source.Orders.Count > 0 ? source.Orders.Max(x => x.Id) + 1 : 1;
|
|
||||||
var newOrder = Order.Create(model);
|
|
||||||
|
|
||||||
if (newOrder == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
source.Orders.Add(newOrder);
|
|
||||||
source.SaveOrders();
|
|
||||||
|
|
||||||
return newOrder.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? Update(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
var order = source.Orders.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
|
|
||||||
if (order == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
order.Update(model);
|
|
||||||
source.SaveOrders();
|
|
||||||
|
|
||||||
return order.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? Delete(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
var element = source.Orders.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
|
|
||||||
if (element != null)
|
|
||||||
{
|
|
||||||
source.Orders.Remove(element);
|
|
||||||
source.SaveOrders();
|
|
||||||
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
using FoodOrdersDataModel.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace FoodOrderFileImplement.Models
|
|
||||||
{
|
|
||||||
public class Component : IComponentModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public string ComponentName { get; private set; } = string.Empty;
|
|
||||||
public double Cost { get; set; }
|
|
||||||
public static Component? Create(ComponentBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Component()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
ComponentName = model.ComponentName,
|
|
||||||
Cost = model.Cost
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public static Component? Create(XElement element)
|
|
||||||
{
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Component()
|
|
||||||
{
|
|
||||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
|
||||||
ComponentName = element.Element("ComponentName")!.Value,
|
|
||||||
Cost = Convert.ToInt32(element.Element("Cost")!.Value)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public void Update(ComponentBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ComponentName = model.ComponentName;
|
|
||||||
Cost = model.Cost;
|
|
||||||
}
|
|
||||||
public ComponentViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
ComponentName = ComponentName,
|
|
||||||
Cost = Cost
|
|
||||||
};
|
|
||||||
public XElement GetXElement => new("Component",
|
|
||||||
new XAttribute("Id", Id),
|
|
||||||
new XElement("ComponentName", ComponentName),
|
|
||||||
new XElement("Cost", Cost.ToString()));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,98 +0,0 @@
|
|||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
using FoodOrdersDataModel.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace FoodOrderFileImplement.Models
|
|
||||||
{
|
|
||||||
public class Food : IFoodModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public string FoodName { get; private set; } = string.Empty;
|
|
||||||
public double Price { get; private set; }
|
|
||||||
|
|
||||||
public Dictionary<int, int> Components { get; private set; } = new();
|
|
||||||
|
|
||||||
public Dictionary<int, (IComponentModel, int)> _foodComponents = null;
|
|
||||||
|
|
||||||
public Dictionary<int, (IComponentModel, int)> FoodComponents
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_foodComponents == null)
|
|
||||||
{
|
|
||||||
var source = DataFileSingleton.GetInstance();
|
|
||||||
_foodComponents = Components.ToDictionary(x => x.Key, y =>
|
|
||||||
((source.Components.FirstOrDefault(z => z.Id == y.Key) as IComponentModel)!, y.Value));
|
|
||||||
}
|
|
||||||
return _foodComponents;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Food? Create(FoodBindingModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Food()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
FoodName = model.FoodName,
|
|
||||||
Price = model.Price,
|
|
||||||
Components = model.FoodComponents.ToDictionary(x => x.Key, x => x.Value.Item2)
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Food? Create(XElement element)
|
|
||||||
{
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Food()
|
|
||||||
{
|
|
||||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
|
||||||
FoodName = element.Element("FoodName")!.Value,
|
|
||||||
Price = Convert.ToDouble(element.Element("Price")!.Value),
|
|
||||||
Components = element.Element("FoodComponents")!.Elements("FoodComponent").ToDictionary(x => Convert.ToInt32(x.Element("Key")?.Value), x => Convert.ToInt32(x.Element("Value")?.Value))
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update(FoodBindingModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
FoodName = model.FoodName;
|
|
||||||
Price = model.Price;
|
|
||||||
Components = model.FoodComponents.ToDictionary(x => x.Key, x => x.Value.Item2);
|
|
||||||
_foodComponents = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FoodViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
FoodName = FoodName,
|
|
||||||
Price = Price,
|
|
||||||
FoodComponents = FoodComponents
|
|
||||||
};
|
|
||||||
|
|
||||||
public XElement GetXElement => new("Food",
|
|
||||||
new XAttribute("Id", Id),
|
|
||||||
new XElement("FoodName", FoodName),
|
|
||||||
new XElement("Price", Price.ToString()),
|
|
||||||
new XElement("FoodComponents", Components.Select(x =>
|
|
||||||
new XElement("FoodComponent",
|
|
||||||
new XElement("Key", x.Key),
|
|
||||||
new XElement("Value", x.Value))).ToArray()));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,103 +0,0 @@
|
|||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
using FoodOrdersDataModel.Enums;
|
|
||||||
using FoodOrdersDataModel.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Http.Headers;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace FoodOrderFileImplement.Models
|
|
||||||
{
|
|
||||||
public class Order : IOrderModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public int FoodId { get; private set; }
|
|
||||||
public string FoodName { get; private set; } = string.Empty;
|
|
||||||
public int Count { get; private set; }
|
|
||||||
public double Sum { get; private set; }
|
|
||||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
|
||||||
public DateTime DateCreate { get; private set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
|
||||||
public DateTime? DateImplement { get; private set; }
|
|
||||||
|
|
||||||
public static Order? Create(OrderBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Order()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
FoodId = model.FoodId,
|
|
||||||
FoodName = model.FoodName,
|
|
||||||
Count = model.Count,
|
|
||||||
Sum = model.Sum,
|
|
||||||
Status = model.Status,
|
|
||||||
DateCreate = model.DateCreate,
|
|
||||||
DateImplement = model.DateImplement
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public static Order? Create(XElement element)
|
|
||||||
{
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var order = new Order()
|
|
||||||
{
|
|
||||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
|
||||||
FoodId = Convert.ToInt32(element.Element("FoodId")!.Value),
|
|
||||||
FoodName = element.Element("FoodName")!.Value,
|
|
||||||
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
|
||||||
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
|
||||||
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
|
|
||||||
DateCreate = DateTime.ParseExact(element.Element("DateCreate")!.Value, "G", null)
|
|
||||||
};
|
|
||||||
|
|
||||||
DateTime.TryParse(element.Element("DateImplement")!.Value, out DateTime dateImpl);
|
|
||||||
order.DateImplement = dateImpl;
|
|
||||||
|
|
||||||
return order;
|
|
||||||
}
|
|
||||||
public void Update(OrderBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
FoodId = model.FoodId;
|
|
||||||
FoodName = model.FoodName;
|
|
||||||
Count = model.Count;
|
|
||||||
Sum = model.Sum;
|
|
||||||
Status = model.Status;
|
|
||||||
DateCreate = model.DateCreate;
|
|
||||||
DateImplement = model.DateImplement;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
FoodId = FoodId,
|
|
||||||
FoodName = FoodName,
|
|
||||||
Count = Count,
|
|
||||||
Sum = Sum,
|
|
||||||
Status = Status,
|
|
||||||
DateCreate = DateCreate,
|
|
||||||
DateImplement = DateImplement
|
|
||||||
};
|
|
||||||
public XElement GetXElement => new("Order",
|
|
||||||
new XAttribute("Id", Id),
|
|
||||||
new XElement("FoodName", FoodName),
|
|
||||||
new XElement("FoodId", FoodId.ToString()),
|
|
||||||
new XElement("Count", Count.ToString()),
|
|
||||||
new XElement("Sum", Sum.ToString()),
|
|
||||||
new XElement("Status", Status.ToString()),
|
|
||||||
new XElement("DateCreate", DateCreate.ToString()),
|
|
||||||
new XElement("DateImplement", DateImplement.ToString()));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
# Visual Studio Version 17
|
|
||||||
VisualStudioVersion = 17.3.32929.385
|
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FoodOrdersView", "FoodOrdersView\FoodOrdersView.csproj", "{831CD419-7329-4082-9B2F-9EA0EE2EA4AC}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FoodOrdersDataModel", "FoodOrdersDataModel\FoodOrdersDataModel.csproj", "{FC864A68-E5FF-4015-A4B3-85B7CDD584FE}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FoodOrdersContracts", "FoodOrdersContracts\FoodOrdersContracts.csproj", "{D189A77F-A5BF-4C88-A412-97D160F73062}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FoodOrdersListImplement", "FoodOrdersListImplement\FoodOrdersListImplement.csproj", "{9F3DC091-FE2A-461A-92CE-8289205E6AAC}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FoodOrderBusinessLogic", "FoodOrdersBusinessLogic\FoodOrderBusinessLogic.csproj", "{B3E18E56-A55D-47DC-8BFD-51689EE95375}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FoodOrderFileImplement", "FoodOrderFileImplement\FoodOrderFileImplement.csproj", "{0F8C8473-B376-4D36-88DA-478AFBE81BFB}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FoodOrderDatabaseImplement", "FoodOrderDatabaseImplement\FoodOrderDatabaseImplement.csproj", "{A865D709-C083-4A58-98EC-DFF4F7C20AF4}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|Any CPU = Debug|Any CPU
|
|
||||||
Release|Any CPU = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{831CD419-7329-4082-9B2F-9EA0EE2EA4AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{831CD419-7329-4082-9B2F-9EA0EE2EA4AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{831CD419-7329-4082-9B2F-9EA0EE2EA4AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{831CD419-7329-4082-9B2F-9EA0EE2EA4AC}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{FC864A68-E5FF-4015-A4B3-85B7CDD584FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{FC864A68-E5FF-4015-A4B3-85B7CDD584FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{FC864A68-E5FF-4015-A4B3-85B7CDD584FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{FC864A68-E5FF-4015-A4B3-85B7CDD584FE}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{D189A77F-A5BF-4C88-A412-97D160F73062}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{D189A77F-A5BF-4C88-A412-97D160F73062}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{D189A77F-A5BF-4C88-A412-97D160F73062}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{D189A77F-A5BF-4C88-A412-97D160F73062}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{9F3DC091-FE2A-461A-92CE-8289205E6AAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{9F3DC091-FE2A-461A-92CE-8289205E6AAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{9F3DC091-FE2A-461A-92CE-8289205E6AAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{9F3DC091-FE2A-461A-92CE-8289205E6AAC}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{B3E18E56-A55D-47DC-8BFD-51689EE95375}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{B3E18E56-A55D-47DC-8BFD-51689EE95375}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{B3E18E56-A55D-47DC-8BFD-51689EE95375}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{B3E18E56-A55D-47DC-8BFD-51689EE95375}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{0F8C8473-B376-4D36-88DA-478AFBE81BFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{0F8C8473-B376-4D36-88DA-478AFBE81BFB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{0F8C8473-B376-4D36-88DA-478AFBE81BFB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{0F8C8473-B376-4D36-88DA-478AFBE81BFB}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{A865D709-C083-4A58-98EC-DFF4F7C20AF4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{A865D709-C083-4A58-98EC-DFF4F7C20AF4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{A865D709-C083-4A58-98EC-DFF4F7C20AF4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{A865D709-C083-4A58-98EC-DFF4F7C20AF4}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
|
||||||
SolutionGuid = {B6811B4E-9459-44E1-80D8-752C2718AB6A}
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
@ -1,109 +0,0 @@
|
|||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.BusinessLogicsContracts;
|
|
||||||
using FoodOrdersContracts.SearchModels;
|
|
||||||
using FoodOrdersContracts.StoragesContracts;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
namespace FoodOrdersBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
public class ComponentLogic : IComponentLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IComponentStorage _componentStorage;
|
|
||||||
public ComponentLogic(ILogger<ComponentLogic> logger, IComponentStorage
|
|
||||||
componentStorage)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_componentStorage = componentStorage;
|
|
||||||
}
|
|
||||||
public List<ComponentViewModel>? ReadList(ComponentSearchModel? model)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("ReadList. ComponentName:{ComponentName}. Id:{ Id}", model?.ComponentName, model?.Id);
|
|
||||||
var list = model == null ? _componentStorage.GetFullList() :
|
|
||||||
_componentStorage.GetFilteredList(model);
|
|
||||||
if (list == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadList return null list");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
public ComponentViewModel? ReadElement(ComponentSearchModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement. ComponentName:{ComponentName}. Id:{ Id} ", model.ComponentName, model.Id);
|
|
||||||
var element = _componentStorage.GetElement(model);
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadElement element not found");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
public bool Create(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_componentStorage.Insert(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public bool Update(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_componentStorage.Update(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Update operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public bool Delete(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model, false);
|
|
||||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
|
||||||
if (_componentStorage.Delete(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Delete operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
private void CheckModel(ComponentBindingModel model, bool withParams =
|
|
||||||
true)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
if (!withParams)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.ComponentName))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет названия компонента",nameof(model.ComponentName));
|
|
||||||
}
|
|
||||||
if (model.Cost <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Component. ComponentName:{ComponentName}.Cost:{ Cost}. Id: { Id}", model.ComponentName, model.Cost, model.Id);
|
|
||||||
var element = _componentStorage.GetElement(new ComponentSearchModel
|
|
||||||
{
|
|
||||||
ComponentName = model.ComponentName
|
|
||||||
});
|
|
||||||
if (element != null && element.Id != model.Id)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Компонент с таким названием уже есть");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,142 +0,0 @@
|
|||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.BusinessLogicsContracts;
|
|
||||||
using FoodOrdersContracts.SearchModels;
|
|
||||||
using FoodOrdersContracts.StoragesContracts;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrdersBusinessLogic.BusinessLogic
|
|
||||||
{
|
|
||||||
public class FoodLogic : IFoodLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
|
|
||||||
private readonly IFoodStorage _foodStorage;
|
|
||||||
|
|
||||||
public FoodLogic(ILogger<FoodLogic> logger, IFoodStorage foodStorage)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_foodStorage = foodStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Create(FoodBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
|
|
||||||
if (_foodStorage.Insert(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Delete(FoodBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model, false);
|
|
||||||
|
|
||||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
|
||||||
|
|
||||||
if (_foodStorage.Delete(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Delete operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FoodViewModel? ReadElement(FoodSearchModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("ReadElement. FoodName:{FoodName}.Id:{ Id}", model.FoodName, model.Id);
|
|
||||||
|
|
||||||
var element = _foodStorage.GetElement(model);
|
|
||||||
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadElement element not found");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
|
||||||
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<FoodViewModel>? ReadList(FoodSearchModel? model)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("ReadList. FoodName:{FoodName}.Id:{ Id}", model?.FoodName, model?.Id);
|
|
||||||
|
|
||||||
var list = model == null ? _foodStorage.GetFullList() : _foodStorage.GetFilteredList(model);
|
|
||||||
|
|
||||||
if (list == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadList return null list");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Update(FoodBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
|
|
||||||
if (_foodStorage.Update(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Update operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CheckModel(FoodBindingModel model, bool withParams = true)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!withParams)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(model.FoodName))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет названия изделия", nameof(model.FoodName));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (model.Price <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Цена изделия должна быть больше 0", nameof(model.Price));
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Work. FoodName:{FoodName}.Price:{ Cost}. Id: { Id}", model.FoodName, model.Price, model.Id);
|
|
||||||
|
|
||||||
var element = _foodStorage.GetElement(new FoodSearchModel
|
|
||||||
{
|
|
||||||
FoodName = model.FoodName
|
|
||||||
});
|
|
||||||
|
|
||||||
if (element != null && element.Id != model.Id)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Изделие с таким названием уже есть");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,135 +0,0 @@
|
|||||||
using FoodOrdersDataModel.Enums;
|
|
||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.BusinessLogicsContracts;
|
|
||||||
using FoodOrdersContracts.SearchModels;
|
|
||||||
using FoodOrdersContracts.StoragesContracts;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace PlumbingRepairBusinessLogic.BusinessLogic
|
|
||||||
{
|
|
||||||
public class OrderLogic : IOrderLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IOrderStorage _orderStorage;
|
|
||||||
|
|
||||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_orderStorage = orderStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool CreateOrder(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
|
|
||||||
if (model.Status != OrderStatus.Неизвестен)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed. Order status incorrect.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
model.Status = OrderStatus.Принят;
|
|
||||||
|
|
||||||
if (_orderStorage.Insert(model) == null)
|
|
||||||
{
|
|
||||||
model.Status = OrderStatus.Неизвестен;
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
|
|
||||||
if (model.Status + 1 != newStatus)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
model.Status = newStatus;
|
|
||||||
|
|
||||||
if (model.Status == OrderStatus.Выдан)
|
|
||||||
model.DateImplement = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
|
||||||
|
|
||||||
if (_orderStorage.Update(model) == null)
|
|
||||||
{
|
|
||||||
model.Status--;
|
|
||||||
_logger.LogWarning("Update operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool TakeOrderInWork(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
return StatusUpdate(model, OrderStatus.Выполняется);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool DeliveryOrder(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
return StatusUpdate(model, OrderStatus.Готов);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool FinishOrder(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
return StatusUpdate(model, OrderStatus.Выдан);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Order. OrderId:{Id}", model?.Id);
|
|
||||||
|
|
||||||
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
|
||||||
|
|
||||||
if (list == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadList return null list");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!withParams)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (model.FoodId < 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Некорректный идентификатор изделия", nameof(model.FoodId));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (model.Count <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Количество изделий в заказе должно быть больше 0", nameof(model.Count));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (model.Sum <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum));
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Order. OrderId:{Id}.Sum:{ Sum}. FoodId: { FoodId}", model.Id, model.Sum, model.FoodId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
|
||||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.2" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\FoodOrdersContracts\FoodOrdersContracts.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,19 +0,0 @@
|
|||||||
using FoodOrdersDataModel.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrdersContracts.BindingModels
|
|
||||||
{
|
|
||||||
public class ComponentBindingModel : IComponentModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string ComponentName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public double Cost { get; set; }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
using FoodOrdersDataModel.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrdersContracts.BindingModels
|
|
||||||
{
|
|
||||||
public class FoodBindingModel : IFoodModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string FoodName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public double Price { get; set; }
|
|
||||||
|
|
||||||
public Dictionary<int, (IComponentModel, int)> FoodComponents { get; set; } = new();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
using FoodOrdersDataModel.Enums;
|
|
||||||
using FoodOrdersDataModel.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrdersContracts.BindingModels
|
|
||||||
{
|
|
||||||
public class OrderBindingModel : IOrderModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public int FoodId { get; set; }
|
|
||||||
public string FoodName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public int Count { get; set; }
|
|
||||||
|
|
||||||
public double Sum { get; set; }
|
|
||||||
|
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
|
||||||
|
|
||||||
public DateTime DateCreate { get; set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
|
||||||
|
|
||||||
public DateTime? DateImplement { get; set; }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.SearchModels;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrdersContracts.BusinessLogicsContracts
|
|
||||||
{
|
|
||||||
public interface IComponentLogic
|
|
||||||
{
|
|
||||||
List<ComponentViewModel>? ReadList(ComponentSearchModel? model);
|
|
||||||
ComponentViewModel? ReadElement(ComponentSearchModel? model);
|
|
||||||
bool Create(ComponentBindingModel? model);
|
|
||||||
bool Update(ComponentBindingModel? model);
|
|
||||||
bool Delete(ComponentBindingModel? model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.SearchModels;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
|
|
||||||
namespace FoodOrdersContracts.BusinessLogicsContracts
|
|
||||||
{
|
|
||||||
public interface IFoodLogic
|
|
||||||
{
|
|
||||||
List<FoodViewModel>? ReadList(FoodSearchModel? model);
|
|
||||||
FoodViewModel? ReadElement(FoodSearchModel? model);
|
|
||||||
bool Create(FoodBindingModel? model);
|
|
||||||
bool Update(FoodBindingModel? model);
|
|
||||||
bool Delete(FoodBindingModel? model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.SearchModels;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
|
|
||||||
namespace FoodOrdersContracts.BusinessLogicsContracts
|
|
||||||
{
|
|
||||||
public interface IOrderLogic
|
|
||||||
{
|
|
||||||
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
|
||||||
bool CreateOrder(OrderBindingModel? model);
|
|
||||||
bool TakeOrderInWork(OrderBindingModel? model);
|
|
||||||
bool FinishOrder(OrderBindingModel? model);
|
|
||||||
bool DeliveryOrder(OrderBindingModel? model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
|
||||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.2" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\FoodOrdersDataModel\FoodOrdersDataModel.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,14 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrdersContracts.SearchModels
|
|
||||||
{
|
|
||||||
public class ComponentSearchModel
|
|
||||||
{
|
|
||||||
public int? Id { get; set; }
|
|
||||||
public string? ComponentName { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrdersContracts.SearchModels
|
|
||||||
{
|
|
||||||
public class FoodSearchModel
|
|
||||||
{
|
|
||||||
public int? Id { get; set; }
|
|
||||||
public string? FoodName { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrdersContracts.SearchModels
|
|
||||||
{
|
|
||||||
public class OrderSearchModel
|
|
||||||
{
|
|
||||||
public int? Id { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.SearchModels;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
|
|
||||||
namespace FoodOrdersContracts.StoragesContracts
|
|
||||||
{
|
|
||||||
public interface IComponentStorage
|
|
||||||
{
|
|
||||||
List<ComponentViewModel> GetFullList();
|
|
||||||
List<ComponentViewModel> GetFilteredList(ComponentSearchModel model);
|
|
||||||
ComponentViewModel? GetElement(ComponentSearchModel model);
|
|
||||||
ComponentViewModel? Insert (ComponentBindingModel model);
|
|
||||||
ComponentViewModel? Update (ComponentBindingModel model);
|
|
||||||
ComponentViewModel? Delete (ComponentBindingModel model);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.SearchModels;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrdersContracts.StoragesContracts
|
|
||||||
{
|
|
||||||
public interface IFoodStorage
|
|
||||||
{
|
|
||||||
List<FoodViewModel> GetFullList();
|
|
||||||
List<FoodViewModel> GetFilteredList(FoodSearchModel model);
|
|
||||||
FoodViewModel? GetElement(FoodSearchModel model);
|
|
||||||
FoodViewModel? Insert(FoodBindingModel model);
|
|
||||||
FoodViewModel? Update(FoodBindingModel model);
|
|
||||||
FoodViewModel? Delete(FoodBindingModel model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.SearchModels;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrdersContracts.StoragesContracts
|
|
||||||
{
|
|
||||||
public interface IOrderStorage
|
|
||||||
{
|
|
||||||
List<OrderViewModel> GetFullList();
|
|
||||||
List<OrderViewModel> GetFilteredList(OrderSearchModel model);
|
|
||||||
OrderViewModel? GetElement(OrderSearchModel model);
|
|
||||||
OrderViewModel? Insert(OrderBindingModel model);
|
|
||||||
OrderViewModel? Update(OrderBindingModel model);
|
|
||||||
OrderViewModel? Delete(OrderBindingModel model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
using FoodOrdersDataModel.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrdersContracts.ViewModels
|
|
||||||
{
|
|
||||||
public class ComponentViewModel : IComponentModel
|
|
||||||
{
|
|
||||||
public int Id {get; set;}
|
|
||||||
[DisplayName("Название компонента")]
|
|
||||||
public string ComponentName { get; set; } = string.Empty;
|
|
||||||
[DisplayName("Цена")]
|
|
||||||
public double Cost { get; set; }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
using FoodOrdersDataModel.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrdersContracts.ViewModels
|
|
||||||
{
|
|
||||||
public class FoodViewModel : IFoodModel
|
|
||||||
{
|
|
||||||
public int Id {get; set; }
|
|
||||||
|
|
||||||
[DisplayName("Название продукта")]
|
|
||||||
public string FoodName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[DisplayName("Цена")]
|
|
||||||
public double Price { get; set; }
|
|
||||||
|
|
||||||
public Dictionary<int, (IComponentModel, int)> FoodComponents { get; set; } = new();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
using FoodOrdersDataModel.Enums;
|
|
||||||
using FoodOrdersDataModel.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrdersContracts.ViewModels
|
|
||||||
{
|
|
||||||
public class OrderViewModel : IOrderModel
|
|
||||||
{
|
|
||||||
[DisplayName(" Номер ")]
|
|
||||||
public int Id { get; set; }
|
|
||||||
public int FoodId { get; set; }
|
|
||||||
[DisplayName(" Изделие ")]
|
|
||||||
public string FoodName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[DisplayName(" Кол-во ")]
|
|
||||||
public int Count { get; set; }
|
|
||||||
|
|
||||||
[DisplayName(" Сумма ")]
|
|
||||||
public double Sum { get; set; }
|
|
||||||
|
|
||||||
[DisplayName(" Статус ")]
|
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
|
||||||
|
|
||||||
[DisplayName(" Дата создания ")]
|
|
||||||
public DateTime DateCreate { get; set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
|
||||||
|
|
||||||
[DisplayName(" Дата выполнения ")]
|
|
||||||
public DateTime? DateImplement { get; set; }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrdersDataModel.Enums
|
|
||||||
{
|
|
||||||
public enum OrderStatus
|
|
||||||
{
|
|
||||||
Неизвестен = -1,
|
|
||||||
Принят = 0,
|
|
||||||
Выполняется = 1,
|
|
||||||
Готов = 2,
|
|
||||||
Выдан = 3
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
|
||||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.2" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,13 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrdersDataModel
|
|
||||||
{
|
|
||||||
public interface IId
|
|
||||||
{
|
|
||||||
int Id { get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrdersDataModel.Models
|
|
||||||
{
|
|
||||||
public interface IComponentModel : IId
|
|
||||||
{
|
|
||||||
string ComponentName { get;}
|
|
||||||
double Cost { get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrdersDataModel.Models
|
|
||||||
{
|
|
||||||
public interface IFoodModel : IId
|
|
||||||
{
|
|
||||||
string FoodName { get; }
|
|
||||||
double Price { get; }
|
|
||||||
Dictionary<int, (IComponentModel, int)> FoodComponents { get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
using FoodOrdersDataModel.Enums;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrdersDataModel.Models
|
|
||||||
{
|
|
||||||
public interface IOrderModel : IId
|
|
||||||
{
|
|
||||||
int FoodId { get; }
|
|
||||||
int Count { get; }
|
|
||||||
double Sum { get; }
|
|
||||||
OrderStatus Status { get; }
|
|
||||||
DateTime DateCreate { get; }
|
|
||||||
DateTime? DateImplement { get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
using FoodOrdersListImplement.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrdersListImplement
|
|
||||||
{
|
|
||||||
internal class DataListSingleton
|
|
||||||
{
|
|
||||||
private static DataListSingleton? _instance;
|
|
||||||
public List<Component> Components { get; set; }
|
|
||||||
public List<Order> Orders { get; set; }
|
|
||||||
public List<Food> Foods { get; set; }
|
|
||||||
private DataListSingleton()
|
|
||||||
{
|
|
||||||
Components = new List<Component>();
|
|
||||||
Orders = new List<Order>();
|
|
||||||
Foods = new List<Food>();
|
|
||||||
}
|
|
||||||
public static DataListSingleton GetInstance()
|
|
||||||
{
|
|
||||||
if (_instance == null)
|
|
||||||
{
|
|
||||||
_instance = new DataListSingleton();
|
|
||||||
}
|
|
||||||
return _instance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
|
||||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.2" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\FoodOrdersDataModel\FoodOrdersDataModel.csproj" />
|
|
||||||
<ProjectReference Include="..\FoodOrdersContracts\FoodOrdersContracts.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,108 +0,0 @@
|
|||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.SearchModels;
|
|
||||||
using FoodOrdersContracts.StoragesContracts;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
using FoodOrdersListImplement.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrdersListImplement.Implements
|
|
||||||
{
|
|
||||||
public class ComponentStorage : IComponentStorage
|
|
||||||
{
|
|
||||||
private readonly DataListSingleton _source;
|
|
||||||
public ComponentStorage()
|
|
||||||
{
|
|
||||||
_source = DataListSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
public List<ComponentViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
var result = new List<ComponentViewModel>();
|
|
||||||
foreach (var component in _source.Components)
|
|
||||||
{
|
|
||||||
result.Add(component.GetViewModel);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
public List<ComponentViewModel> GetFilteredList(ComponentSearchModel
|
|
||||||
model)
|
|
||||||
{
|
|
||||||
var result = new List<ComponentViewModel>();
|
|
||||||
if (string.IsNullOrEmpty(model.ComponentName))
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
foreach (var component in _source.Components)
|
|
||||||
{
|
|
||||||
if (component.ComponentName.Contains(model.ComponentName))
|
|
||||||
{
|
|
||||||
result.Add(component.GetViewModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
public ComponentViewModel? GetElement(ComponentSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
foreach (var component in _source.Components)
|
|
||||||
{
|
|
||||||
if ((!string.IsNullOrEmpty(model.ComponentName) &&
|
|
||||||
component.ComponentName == model.ComponentName) ||
|
|
||||||
(model.Id.HasValue && component.Id == model.Id))
|
|
||||||
{
|
|
||||||
return component.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
public ComponentViewModel? Insert(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = 1;
|
|
||||||
foreach (var component in _source.Components)
|
|
||||||
{
|
|
||||||
if (model.Id <= component.Id)
|
|
||||||
{
|
|
||||||
model.Id = component.Id + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var newComponent = Component.Create(model);
|
|
||||||
if (newComponent == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_source.Components.Add(newComponent);
|
|
||||||
return newComponent.GetViewModel;
|
|
||||||
}
|
|
||||||
public ComponentViewModel? Update(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
foreach (var component in _source.Components)
|
|
||||||
{
|
|
||||||
if (component.Id == model.Id)
|
|
||||||
{
|
|
||||||
component.Update(model);
|
|
||||||
return component.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
public ComponentViewModel? Delete(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _source.Components.Count; ++i)
|
|
||||||
{
|
|
||||||
if (_source.Components[i].Id == model.Id)
|
|
||||||
{
|
|
||||||
var element = _source.Components[i];
|
|
||||||
_source.Components.RemoveAt(i);
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,125 +0,0 @@
|
|||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.SearchModels;
|
|
||||||
using FoodOrdersContracts.StoragesContracts;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
using FoodOrdersListImplement.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrdersListImplement.Implements
|
|
||||||
{
|
|
||||||
public class FoodStorage : IFoodStorage
|
|
||||||
{
|
|
||||||
private readonly DataListSingleton _source;
|
|
||||||
public FoodStorage()
|
|
||||||
{
|
|
||||||
_source = DataListSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
public List<FoodViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
var result = new List<FoodViewModel>();
|
|
||||||
|
|
||||||
foreach (var work in _source.Foods)
|
|
||||||
{
|
|
||||||
result.Add(work.GetViewModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<FoodViewModel> GetFilteredList(FoodSearchModel model)
|
|
||||||
{
|
|
||||||
var result = new List<FoodViewModel>();
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(model.FoodName))
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var work in _source.Foods)
|
|
||||||
{
|
|
||||||
if (work.FoodName.Contains(model.FoodName))
|
|
||||||
{
|
|
||||||
result.Add(work.GetViewModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FoodViewModel? GetElement(FoodSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.FoodName) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var work in _source.Foods)
|
|
||||||
{
|
|
||||||
if ((!string.IsNullOrEmpty(model.FoodName) && work.FoodName == model.FoodName) || (model.Id.HasValue && work.Id == model.Id))
|
|
||||||
{
|
|
||||||
return work.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FoodViewModel? Insert(FoodBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = 1;
|
|
||||||
|
|
||||||
foreach (var work in _source.Foods)
|
|
||||||
{
|
|
||||||
if (model.Id <= work.Id)
|
|
||||||
{
|
|
||||||
model.Id = work.Id + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var newWork = Food.Create(model);
|
|
||||||
|
|
||||||
if (newWork == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
_source.Foods.Add(newWork);
|
|
||||||
|
|
||||||
return newWork.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FoodViewModel? Update(FoodBindingModel model)
|
|
||||||
{
|
|
||||||
foreach (var work in _source.Foods)
|
|
||||||
{
|
|
||||||
if (work.Id == model.Id)
|
|
||||||
{
|
|
||||||
work.Update(model);
|
|
||||||
return work.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FoodViewModel? Delete(FoodBindingModel model)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _source.Foods.Count; ++i)
|
|
||||||
{
|
|
||||||
if (_source.Foods[i].Id == model.Id)
|
|
||||||
{
|
|
||||||
var element = _source.Foods[i];
|
|
||||||
_source.Foods.RemoveAt(i);
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,124 +0,0 @@
|
|||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.SearchModels;
|
|
||||||
using FoodOrdersContracts.StoragesContracts;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
using FoodOrdersListImplement.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrdersListImplement.Implements
|
|
||||||
{
|
|
||||||
public class OrderStorage : IOrderStorage
|
|
||||||
{
|
|
||||||
private readonly DataListSingleton _source;
|
|
||||||
public OrderStorage()
|
|
||||||
{
|
|
||||||
_source = DataListSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<OrderViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
var result = new List<OrderViewModel>();
|
|
||||||
|
|
||||||
foreach (var order in _source.Orders)
|
|
||||||
{
|
|
||||||
result.Add(order.GetViewModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
|
||||||
{
|
|
||||||
var result = new List<OrderViewModel>();
|
|
||||||
|
|
||||||
if (!model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var order in _source.Orders)
|
|
||||||
{
|
|
||||||
if (model.Id.HasValue && order.Id == model.Id)
|
|
||||||
{
|
|
||||||
result.Add(order.GetViewModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
|
||||||
{
|
|
||||||
if (!model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var order in _source.Orders)
|
|
||||||
{
|
|
||||||
if (model.Id.HasValue && order.Id == model.Id)
|
|
||||||
{
|
|
||||||
return order.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = 1;
|
|
||||||
|
|
||||||
foreach (var order in _source.Orders)
|
|
||||||
{
|
|
||||||
if (model.Id <= order.Id)
|
|
||||||
{
|
|
||||||
model.Id = order.Id + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var newOrder = Order.Create(model);
|
|
||||||
|
|
||||||
if (newOrder == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
_source.Orders.Add(newOrder);
|
|
||||||
|
|
||||||
return newOrder.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? Update(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
foreach (var order in _source.Orders)
|
|
||||||
{
|
|
||||||
if (order.Id == model.Id)
|
|
||||||
{
|
|
||||||
order.Update(model);
|
|
||||||
return order.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
public OrderViewModel? Delete(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _source.Orders.Count; ++i)
|
|
||||||
{
|
|
||||||
if (_source.Orders[i].Id == model.Id)
|
|
||||||
{
|
|
||||||
var element = _source.Orders[i];
|
|
||||||
_source.Orders.RemoveAt(i);
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
using FoodOrdersDataModel.Models;
|
|
||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrdersListImplement.Models
|
|
||||||
{
|
|
||||||
internal class Component : IComponentModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public string ComponentName { get; private set; } = string.Empty;
|
|
||||||
public double Cost { get; set; }
|
|
||||||
public static Component? Create(ComponentBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Component()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
ComponentName = model.ComponentName,
|
|
||||||
Cost = model.Cost
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public void Update(ComponentBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ComponentName = model.ComponentName;
|
|
||||||
Cost = model.Cost;
|
|
||||||
}
|
|
||||||
public ComponentViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
ComponentName = ComponentName,
|
|
||||||
Cost = Cost
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
using FoodOrdersDataModel.Models;
|
|
||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrdersListImplement.Models
|
|
||||||
{
|
|
||||||
public class Food : IFoodModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public string FoodName { get; private set; } = string.Empty;
|
|
||||||
public double Price { get; private set; }
|
|
||||||
public Dictionary<int, (IComponentModel, int)> FoodComponents
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
private set;
|
|
||||||
} = new Dictionary<int, (IComponentModel, int)>();
|
|
||||||
public static Food? Create(FoodBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Food()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
FoodName = model.FoodName,
|
|
||||||
Price = model.Price,
|
|
||||||
FoodComponents = model.FoodComponents
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public void Update(FoodBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
FoodName = model.FoodName;
|
|
||||||
Price = model.Price;
|
|
||||||
FoodComponents = model.FoodComponents;
|
|
||||||
}
|
|
||||||
public FoodViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
FoodName = FoodName,
|
|
||||||
Price = Price,
|
|
||||||
FoodComponents = FoodComponents
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,71 +0,0 @@
|
|||||||
using FoodOrdersDataModel.Enums;
|
|
||||||
using FoodOrdersDataModel.Models;
|
|
||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrdersListImplement.Models
|
|
||||||
{
|
|
||||||
internal class Order : IOrderModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public int FoodId { get; private set; }
|
|
||||||
public string FoodName { get; private set; }
|
|
||||||
public int Count { get; private set; }
|
|
||||||
public double Sum { get; private set; }
|
|
||||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
|
||||||
public DateTime DateCreate { get; private set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
|
||||||
public DateTime? DateImplement { get; private set; }
|
|
||||||
|
|
||||||
public static Order? Create(OrderBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Order()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
FoodId = model.FoodId,
|
|
||||||
FoodName = model.FoodName,
|
|
||||||
Count = model.Count,
|
|
||||||
Sum = model.Sum,
|
|
||||||
Status = model.Status,
|
|
||||||
DateCreate = model.DateCreate,
|
|
||||||
DateImplement = model.DateImplement
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update(OrderBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
FoodId = model.FoodId;
|
|
||||||
FoodName = model.FoodName;
|
|
||||||
Count = model.Count;
|
|
||||||
Sum = model.Sum;
|
|
||||||
Status = model.Status;
|
|
||||||
DateCreate = model.DateCreate;
|
|
||||||
DateImplement = model.DateImplement;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
FoodId = FoodId,
|
|
||||||
FoodName = FoodName,
|
|
||||||
Count = Count,
|
|
||||||
Sum = Sum,
|
|
||||||
Status = Status,
|
|
||||||
DateCreate = DateCreate,
|
|
||||||
DateImplement = DateImplement
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>WinExe</OutputType>
|
|
||||||
<TargetFramework>net6.0-windows</TargetFramework>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.5">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
|
||||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.2" />
|
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\FoodOrderDatabaseImplement\FoodOrderDatabaseImplement.csproj" />
|
|
||||||
<ProjectReference Include="..\FoodOrderFileImplement\FoodOrderFileImplement.csproj" />
|
|
||||||
<ProjectReference Include="..\FoodOrdersBusinessLogic\FoodOrderBusinessLogic.csproj" />
|
|
||||||
<ProjectReference Include="..\FoodOrdersContracts\FoodOrdersContracts.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Update="Properties\Resources.Designer.cs">
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>Resources.resx</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<EmbeddedResource Update="Properties\Resources.resx">
|
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
|
||||||
</EmbeddedResource>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
118
FoodOrders/FoodOrdersView/FormComponent.Designer.cs
generated
118
FoodOrders/FoodOrdersView/FormComponent.Designer.cs
generated
@ -1,118 +0,0 @@
|
|||||||
namespace FoodOrdersView
|
|
||||||
{
|
|
||||||
partial class FormComponent
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.ComponentNameTextBox = new System.Windows.Forms.TextBox();
|
|
||||||
this.labelName = new System.Windows.Forms.Label();
|
|
||||||
this.labelCost = new System.Windows.Forms.Label();
|
|
||||||
this.CostTextBox = new System.Windows.Forms.TextBox();
|
|
||||||
this.SaveButton = new System.Windows.Forms.Button();
|
|
||||||
this.ButtonCancel = new System.Windows.Forms.Button();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// ComponentNameTextBox
|
|
||||||
//
|
|
||||||
this.ComponentNameTextBox.Location = new System.Drawing.Point(83, 12);
|
|
||||||
this.ComponentNameTextBox.Name = "ComponentNameTextBox";
|
|
||||||
this.ComponentNameTextBox.Size = new System.Drawing.Size(236, 23);
|
|
||||||
this.ComponentNameTextBox.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// labelName
|
|
||||||
//
|
|
||||||
this.labelName.AutoSize = true;
|
|
||||||
this.labelName.Location = new System.Drawing.Point(13, 15);
|
|
||||||
this.labelName.Name = "labelName";
|
|
||||||
this.labelName.Size = new System.Drawing.Size(62, 15);
|
|
||||||
this.labelName.TabIndex = 1;
|
|
||||||
this.labelName.Text = "Название:";
|
|
||||||
//
|
|
||||||
// labelCost
|
|
||||||
//
|
|
||||||
this.labelCost.AutoSize = true;
|
|
||||||
this.labelCost.Location = new System.Drawing.Point(37, 64);
|
|
||||||
this.labelCost.Name = "labelCost";
|
|
||||||
this.labelCost.Size = new System.Drawing.Size(38, 15);
|
|
||||||
this.labelCost.TabIndex = 3;
|
|
||||||
this.labelCost.Text = "Цена:";
|
|
||||||
//
|
|
||||||
// CostTextBox
|
|
||||||
//
|
|
||||||
this.CostTextBox.Location = new System.Drawing.Point(83, 61);
|
|
||||||
this.CostTextBox.Name = "CostTextBox";
|
|
||||||
this.CostTextBox.Size = new System.Drawing.Size(234, 23);
|
|
||||||
this.CostTextBox.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// SaveButton
|
|
||||||
//
|
|
||||||
this.SaveButton.Location = new System.Drawing.Point(83, 99);
|
|
||||||
this.SaveButton.Name = "SaveButton";
|
|
||||||
this.SaveButton.Size = new System.Drawing.Size(84, 23);
|
|
||||||
this.SaveButton.TabIndex = 4;
|
|
||||||
this.SaveButton.Text = "Сохранить";
|
|
||||||
this.SaveButton.UseVisualStyleBackColor = true;
|
|
||||||
this.SaveButton.Click += new System.EventHandler(this.SaveButton_Click);
|
|
||||||
//
|
|
||||||
// ButtonCancel
|
|
||||||
//
|
|
||||||
this.ButtonCancel.Location = new System.Drawing.Point(233, 99);
|
|
||||||
this.ButtonCancel.Name = "ButtonCancel";
|
|
||||||
this.ButtonCancel.Size = new System.Drawing.Size(84, 23);
|
|
||||||
this.ButtonCancel.TabIndex = 5;
|
|
||||||
this.ButtonCancel.Text = "Отмена";
|
|
||||||
this.ButtonCancel.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
|
||||||
//
|
|
||||||
// FormComponent
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(332, 144);
|
|
||||||
this.Controls.Add(this.ButtonCancel);
|
|
||||||
this.Controls.Add(this.SaveButton);
|
|
||||||
this.Controls.Add(this.labelCost);
|
|
||||||
this.Controls.Add(this.CostTextBox);
|
|
||||||
this.Controls.Add(this.labelName);
|
|
||||||
this.Controls.Add(this.ComponentNameTextBox);
|
|
||||||
this.Name = "FormComponent";
|
|
||||||
this.Text = "FormComponent";
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private TextBox ComponentNameTextBox;
|
|
||||||
private Label labelName;
|
|
||||||
private Label labelCost;
|
|
||||||
private TextBox CostTextBox;
|
|
||||||
private Button SaveButton;
|
|
||||||
private Button ButtonCancel;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,102 +0,0 @@
|
|||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.BusinessLogicsContracts;
|
|
||||||
using FoodOrdersContracts.SearchModels;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace FoodOrdersView
|
|
||||||
{
|
|
||||||
public partial class FormComponent : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IComponentLogic _logic;
|
|
||||||
private int? _id;
|
|
||||||
public int Id { set { _id = value; } }
|
|
||||||
|
|
||||||
public FormComponent(ILogger<FormComponent> logger, IComponentLogic logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logic = logic;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormComponent_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_id.HasValue)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение компонента");
|
|
||||||
|
|
||||||
var view = _logic.ReadElement(new ComponentSearchModel
|
|
||||||
{
|
|
||||||
Id = _id.Value
|
|
||||||
});
|
|
||||||
|
|
||||||
if (view != null)
|
|
||||||
{
|
|
||||||
ComponentNameTextBox.Text = view.ComponentName;
|
|
||||||
CostTextBox.Text = view.Cost.ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка получения компонента");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
|
||||||
MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SaveButton_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(ComponentNameTextBox.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Сохранение компонента");
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var model = new ComponentBindingModel
|
|
||||||
{
|
|
||||||
Id = _id ?? 0,
|
|
||||||
ComponentName = ComponentNameTextBox.Text,
|
|
||||||
Cost = Convert.ToDouble(CostTextBox.Text)
|
|
||||||
};
|
|
||||||
|
|
||||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
|
||||||
|
|
||||||
if (!operationResult)
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
|
|
||||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
DialogResult = DialogResult.OK;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка сохранения компонента");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
DialogResult = DialogResult.Cancel;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
120
FoodOrders/FoodOrdersView/FormComponents.Designer.cs
generated
120
FoodOrders/FoodOrdersView/FormComponents.Designer.cs
generated
@ -1,120 +0,0 @@
|
|||||||
namespace FoodOrdersView
|
|
||||||
{
|
|
||||||
partial class FormComponents
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.dataGridView1 = new System.Windows.Forms.DataGridView();
|
|
||||||
this.buttonAdd = new System.Windows.Forms.Button();
|
|
||||||
this.buttonChange = new System.Windows.Forms.Button();
|
|
||||||
this.buttonDelete = new System.Windows.Forms.Button();
|
|
||||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// dataGridView1
|
|
||||||
//
|
|
||||||
this.dataGridView1.AllowUserToAddRows = false;
|
|
||||||
this.dataGridView1.AllowUserToDeleteRows = false;
|
|
||||||
this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.ButtonHighlight;
|
|
||||||
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Left;
|
|
||||||
this.dataGridView1.Location = new System.Drawing.Point(0, 0);
|
|
||||||
this.dataGridView1.Name = "dataGridView1";
|
|
||||||
this.dataGridView1.RowHeadersVisible = false;
|
|
||||||
this.dataGridView1.RowTemplate.Height = 25;
|
|
||||||
this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
|
||||||
this.dataGridView1.Size = new System.Drawing.Size(392, 383);
|
|
||||||
this.dataGridView1.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// buttonAdd
|
|
||||||
//
|
|
||||||
this.buttonAdd.Location = new System.Drawing.Point(398, 12);
|
|
||||||
this.buttonAdd.Name = "buttonAdd";
|
|
||||||
this.buttonAdd.Size = new System.Drawing.Size(139, 29);
|
|
||||||
this.buttonAdd.TabIndex = 1;
|
|
||||||
this.buttonAdd.Text = "Добавить";
|
|
||||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
|
||||||
//
|
|
||||||
// buttonChange
|
|
||||||
//
|
|
||||||
this.buttonChange.Location = new System.Drawing.Point(398, 47);
|
|
||||||
this.buttonChange.Name = "buttonChange";
|
|
||||||
this.buttonChange.Size = new System.Drawing.Size(139, 29);
|
|
||||||
this.buttonChange.TabIndex = 2;
|
|
||||||
this.buttonChange.Text = "Изменить";
|
|
||||||
this.buttonChange.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonChange.Click += new System.EventHandler(this.ChangeButton_Click);
|
|
||||||
//
|
|
||||||
// buttonDelete
|
|
||||||
//
|
|
||||||
this.buttonDelete.Location = new System.Drawing.Point(398, 82);
|
|
||||||
this.buttonDelete.Name = "buttonDelete";
|
|
||||||
this.buttonDelete.Size = new System.Drawing.Size(139, 29);
|
|
||||||
this.buttonDelete.TabIndex = 3;
|
|
||||||
this.buttonDelete.Text = "Удалить";
|
|
||||||
this.buttonDelete.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click);
|
|
||||||
//
|
|
||||||
// buttonUpdate
|
|
||||||
//
|
|
||||||
this.buttonUpdate.Location = new System.Drawing.Point(398, 117);
|
|
||||||
this.buttonUpdate.Name = "buttonUpdate";
|
|
||||||
this.buttonUpdate.Size = new System.Drawing.Size(139, 29);
|
|
||||||
this.buttonUpdate.TabIndex = 4;
|
|
||||||
this.buttonUpdate.Text = "Обновить";
|
|
||||||
this.buttonUpdate.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
|
|
||||||
//
|
|
||||||
// FormComponents
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(540, 383);
|
|
||||||
this.Controls.Add(this.buttonUpdate);
|
|
||||||
this.Controls.Add(this.buttonDelete);
|
|
||||||
this.Controls.Add(this.buttonChange);
|
|
||||||
this.Controls.Add(this.buttonAdd);
|
|
||||||
this.Controls.Add(this.dataGridView1);
|
|
||||||
this.Name = "FormComponents";
|
|
||||||
this.Text = "Компоненты";
|
|
||||||
this.Load += new System.EventHandler(this.FormComponents_Load);
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private DataGridView dataGridView1;
|
|
||||||
private Button buttonAdd;
|
|
||||||
private Button buttonChange;
|
|
||||||
private Button buttonDelete;
|
|
||||||
private Button buttonUpdate;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,106 +0,0 @@
|
|||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.BusinessLogicsContracts;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace FoodOrdersView
|
|
||||||
{
|
|
||||||
public partial class FormComponents : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IComponentLogic _logic;
|
|
||||||
public FormComponents(ILogger<FormComponents> logger, IComponentLogic
|
|
||||||
logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logic = logic;
|
|
||||||
}
|
|
||||||
private void FormComponents_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var list = _logic.ReadList(null);
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView1.DataSource = list;
|
|
||||||
dataGridView1.Columns["Id"].Visible = false;
|
|
||||||
dataGridView1.Columns["ComponentName"].AutoSizeMode =
|
|
||||||
DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка компонентов");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки компонентов");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
|
||||||
MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var service =
|
|
||||||
Program.ServiceProvider?.GetService(typeof(FormComponent));
|
|
||||||
if (service is FormComponent form)
|
|
||||||
{
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ChangeButton_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView1.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
var service =
|
|
||||||
Program.ServiceProvider?.GetService(typeof(FormComponent));
|
|
||||||
if (service is FormComponent form)
|
|
||||||
{
|
|
||||||
form.Id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonDel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView1.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
if (MessageBox.Show("Удалить запись?", "Вопрос",
|
|
||||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
||||||
{
|
|
||||||
int id =
|
|
||||||
Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
_logger.LogInformation("Удаление компонента");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!_logic.Delete(new ComponentBindingModel
|
|
||||||
{
|
|
||||||
Id = id
|
|
||||||
}))
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка удаления компонента");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void buttonUpdate_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
144
FoodOrders/FoodOrdersView/FormCreateOrder.Designer.cs
generated
144
FoodOrders/FoodOrdersView/FormCreateOrder.Designer.cs
generated
@ -1,144 +0,0 @@
|
|||||||
namespace FoodOrdersView
|
|
||||||
{
|
|
||||||
partial class FormCreateOrder
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.WorkNameLabel = new System.Windows.Forms.Label();
|
|
||||||
this.CountLabel = new System.Windows.Forms.Label();
|
|
||||||
this.SumLabel = new System.Windows.Forms.Label();
|
|
||||||
this.FoodComboBox = new System.Windows.Forms.ComboBox();
|
|
||||||
this.CountTextBox = new System.Windows.Forms.TextBox();
|
|
||||||
this.SumTextBox = new System.Windows.Forms.TextBox();
|
|
||||||
this.SaveButton = new System.Windows.Forms.Button();
|
|
||||||
this.ButtonCancel = new System.Windows.Forms.Button();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// WorkNameLabel
|
|
||||||
//
|
|
||||||
this.WorkNameLabel.AutoSize = true;
|
|
||||||
this.WorkNameLabel.Location = new System.Drawing.Point(25, 15);
|
|
||||||
this.WorkNameLabel.Name = "WorkNameLabel";
|
|
||||||
this.WorkNameLabel.Size = new System.Drawing.Size(59, 15);
|
|
||||||
this.WorkNameLabel.TabIndex = 0;
|
|
||||||
this.WorkNameLabel.Text = "Изделие: ";
|
|
||||||
//
|
|
||||||
// CountLabel
|
|
||||||
//
|
|
||||||
this.CountLabel.AutoSize = true;
|
|
||||||
this.CountLabel.Location = new System.Drawing.Point(25, 44);
|
|
||||||
this.CountLabel.Name = "CountLabel";
|
|
||||||
this.CountLabel.Size = new System.Drawing.Size(78, 15);
|
|
||||||
this.CountLabel.TabIndex = 1;
|
|
||||||
this.CountLabel.Text = "Количество: ";
|
|
||||||
//
|
|
||||||
// SumLabel
|
|
||||||
//
|
|
||||||
this.SumLabel.AutoSize = true;
|
|
||||||
this.SumLabel.Location = new System.Drawing.Point(25, 76);
|
|
||||||
this.SumLabel.Name = "SumLabel";
|
|
||||||
this.SumLabel.Size = new System.Drawing.Size(51, 15);
|
|
||||||
this.SumLabel.TabIndex = 2;
|
|
||||||
this.SumLabel.Text = "Сумма: ";
|
|
||||||
//
|
|
||||||
// FoodComboBox
|
|
||||||
//
|
|
||||||
this.FoodComboBox.FormattingEnabled = true;
|
|
||||||
this.FoodComboBox.Location = new System.Drawing.Point(111, 15);
|
|
||||||
this.FoodComboBox.Name = "FoodComboBox";
|
|
||||||
this.FoodComboBox.Size = new System.Drawing.Size(214, 23);
|
|
||||||
this.FoodComboBox.TabIndex = 4;
|
|
||||||
this.FoodComboBox.SelectedIndexChanged += new System.EventHandler(this.FoodComboBox_SelectedIndexChanged);
|
|
||||||
//
|
|
||||||
// CountTextBox
|
|
||||||
//
|
|
||||||
this.CountTextBox.Location = new System.Drawing.Point(111, 44);
|
|
||||||
this.CountTextBox.Name = "CountTextBox";
|
|
||||||
this.CountTextBox.Size = new System.Drawing.Size(214, 23);
|
|
||||||
this.CountTextBox.TabIndex = 5;
|
|
||||||
this.CountTextBox.TextChanged += new System.EventHandler(this.CountTextBox_TextChanged);
|
|
||||||
//
|
|
||||||
// SumTextBox
|
|
||||||
//
|
|
||||||
this.SumTextBox.Enabled = false;
|
|
||||||
this.SumTextBox.Location = new System.Drawing.Point(111, 73);
|
|
||||||
this.SumTextBox.Name = "SumTextBox";
|
|
||||||
this.SumTextBox.Size = new System.Drawing.Size(214, 23);
|
|
||||||
this.SumTextBox.TabIndex = 6;
|
|
||||||
//
|
|
||||||
// SaveButton
|
|
||||||
//
|
|
||||||
this.SaveButton.Location = new System.Drawing.Point(111, 115);
|
|
||||||
this.SaveButton.Name = "SaveButton";
|
|
||||||
this.SaveButton.Size = new System.Drawing.Size(95, 23);
|
|
||||||
this.SaveButton.TabIndex = 7;
|
|
||||||
this.SaveButton.Text = "Сохранить";
|
|
||||||
this.SaveButton.UseVisualStyleBackColor = true;
|
|
||||||
this.SaveButton.MouseClick += new System.Windows.Forms.MouseEventHandler(this.SaveButton_Click);
|
|
||||||
//
|
|
||||||
// ButtonCancel
|
|
||||||
//
|
|
||||||
this.ButtonCancel.Location = new System.Drawing.Point(230, 115);
|
|
||||||
this.ButtonCancel.Name = "ButtonCancel";
|
|
||||||
this.ButtonCancel.Size = new System.Drawing.Size(95, 23);
|
|
||||||
this.ButtonCancel.TabIndex = 8;
|
|
||||||
this.ButtonCancel.Text = "Отменить";
|
|
||||||
this.ButtonCancel.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonCancel.MouseClick += new System.Windows.Forms.MouseEventHandler(this.ButtonCancel_Click);
|
|
||||||
//
|
|
||||||
// FormCreateOrder
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(350, 146);
|
|
||||||
this.Controls.Add(this.ButtonCancel);
|
|
||||||
this.Controls.Add(this.SaveButton);
|
|
||||||
this.Controls.Add(this.SumTextBox);
|
|
||||||
this.Controls.Add(this.CountTextBox);
|
|
||||||
this.Controls.Add(this.FoodComboBox);
|
|
||||||
this.Controls.Add(this.SumLabel);
|
|
||||||
this.Controls.Add(this.CountLabel);
|
|
||||||
this.Controls.Add(this.WorkNameLabel);
|
|
||||||
this.Name = "FormCreateOrder";
|
|
||||||
this.Text = "Заказ";
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label WorkNameLabel;
|
|
||||||
private Label CountLabel;
|
|
||||||
private Label SumLabel;
|
|
||||||
private ComboBox FoodComboBox;
|
|
||||||
private TextBox CountTextBox;
|
|
||||||
private TextBox SumTextBox;
|
|
||||||
private Button SaveButton;
|
|
||||||
private Button ButtonCancel;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,144 +0,0 @@
|
|||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.BusinessLogicsContracts;
|
|
||||||
using FoodOrdersContracts.SearchModels;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace FoodOrdersView
|
|
||||||
{
|
|
||||||
public partial class FormCreateOrder : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IFoodLogic _logicW;
|
|
||||||
private readonly IOrderLogic _logicO;
|
|
||||||
|
|
||||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, IFoodLogic logicF, IOrderLogic logicO)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logicW = logicF;
|
|
||||||
_logicO = logicO;
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormCreateOrder_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Загрузка изделий для заказа");
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var list = _logicW.ReadList(null);
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
FoodComboBox.DisplayMember = "FoodName";
|
|
||||||
FoodComboBox.ValueMember = "Id";
|
|
||||||
FoodComboBox.DataSource = list;
|
|
||||||
FoodComboBox.SelectedItem = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки списка изделий");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CalcSum()
|
|
||||||
{
|
|
||||||
if (FoodComboBox.SelectedValue != null && !string.IsNullOrEmpty(CountTextBox.Text))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
int id = Convert.ToInt32(FoodComboBox.SelectedValue);
|
|
||||||
|
|
||||||
var product = _logicW.ReadElement(new FoodSearchModel
|
|
||||||
{
|
|
||||||
Id = id
|
|
||||||
});
|
|
||||||
|
|
||||||
int count = Convert.ToInt32(CountTextBox.Text);
|
|
||||||
SumTextBox.Text = Math.Round(count * (product?.Price ?? 0), 2).ToString();
|
|
||||||
_logger.LogInformation("Расчет суммы заказа");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка расчета суммы заказа");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CountTextBox_TextChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CalcSum();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FoodComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CalcSum();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SaveButton_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(CountTextBox.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FoodComboBox.SelectedValue == null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Создание заказа");
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
|
||||||
{
|
|
||||||
FoodId = Convert.ToInt32(FoodComboBox.SelectedValue),
|
|
||||||
FoodName = FoodComboBox.Text,
|
|
||||||
Count = Convert.ToInt32(CountTextBox.Text),
|
|
||||||
Sum = Convert.ToDouble(SumTextBox.Text)
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!operationResult)
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
|
|
||||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
DialogResult = DialogResult.OK;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка создания заказа");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
DialogResult = DialogResult.Cancel;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
226
FoodOrders/FoodOrdersView/FormFood.Designer.cs
generated
226
FoodOrders/FoodOrdersView/FormFood.Designer.cs
generated
@ -1,226 +0,0 @@
|
|||||||
namespace FoodOrdersView
|
|
||||||
{
|
|
||||||
partial class FormFood
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.FoodNameLabel = new System.Windows.Forms.Label();
|
|
||||||
this.PriceLabel = new System.Windows.Forms.Label();
|
|
||||||
this.FoodNameTextBox = new System.Windows.Forms.TextBox();
|
|
||||||
this.PriceTextBox = new System.Windows.Forms.TextBox();
|
|
||||||
this.ComponentsGroupBox = new System.Windows.Forms.GroupBox();
|
|
||||||
this.ButtonCancel = new System.Windows.Forms.Button();
|
|
||||||
this.SaveButton = new System.Windows.Forms.Button();
|
|
||||||
this.DeleteButton = new System.Windows.Forms.Button();
|
|
||||||
this.UpdateButton = new System.Windows.Forms.Button();
|
|
||||||
this.ChangeButton = new System.Windows.Forms.Button();
|
|
||||||
this.AddButton = new System.Windows.Forms.Button();
|
|
||||||
this.dataGridView1 = new System.Windows.Forms.DataGridView();
|
|
||||||
this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
|
||||||
this.ComponentNameField = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
|
||||||
this.CountField = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
|
||||||
this.ComponentsGroupBox.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// FoodNameLabel
|
|
||||||
//
|
|
||||||
this.FoodNameLabel.AutoSize = true;
|
|
||||||
this.FoodNameLabel.Location = new System.Drawing.Point(12, 9);
|
|
||||||
this.FoodNameLabel.Name = "FoodNameLabel";
|
|
||||||
this.FoodNameLabel.Size = new System.Drawing.Size(65, 15);
|
|
||||||
this.FoodNameLabel.TabIndex = 0;
|
|
||||||
this.FoodNameLabel.Text = "Название: ";
|
|
||||||
//
|
|
||||||
// PriceLabel
|
|
||||||
//
|
|
||||||
this.PriceLabel.AutoSize = true;
|
|
||||||
this.PriceLabel.Location = new System.Drawing.Point(12, 47);
|
|
||||||
this.PriceLabel.Name = "PriceLabel";
|
|
||||||
this.PriceLabel.Size = new System.Drawing.Size(73, 15);
|
|
||||||
this.PriceLabel.TabIndex = 1;
|
|
||||||
this.PriceLabel.Text = "Стоимость: ";
|
|
||||||
//
|
|
||||||
// FoodNameTextBox
|
|
||||||
//
|
|
||||||
this.FoodNameTextBox.Location = new System.Drawing.Point(83, 6);
|
|
||||||
this.FoodNameTextBox.Name = "FoodNameTextBox";
|
|
||||||
this.FoodNameTextBox.Size = new System.Drawing.Size(250, 23);
|
|
||||||
this.FoodNameTextBox.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// PriceTextBox
|
|
||||||
//
|
|
||||||
this.PriceTextBox.Enabled = false;
|
|
||||||
this.PriceTextBox.Location = new System.Drawing.Point(83, 44);
|
|
||||||
this.PriceTextBox.Name = "PriceTextBox";
|
|
||||||
this.PriceTextBox.Size = new System.Drawing.Size(250, 23);
|
|
||||||
this.PriceTextBox.TabIndex = 3;
|
|
||||||
//
|
|
||||||
// ComponentsGroupBox
|
|
||||||
//
|
|
||||||
this.ComponentsGroupBox.Controls.Add(this.ButtonCancel);
|
|
||||||
this.ComponentsGroupBox.Controls.Add(this.SaveButton);
|
|
||||||
this.ComponentsGroupBox.Controls.Add(this.DeleteButton);
|
|
||||||
this.ComponentsGroupBox.Controls.Add(this.UpdateButton);
|
|
||||||
this.ComponentsGroupBox.Controls.Add(this.ChangeButton);
|
|
||||||
this.ComponentsGroupBox.Controls.Add(this.AddButton);
|
|
||||||
this.ComponentsGroupBox.Controls.Add(this.dataGridView1);
|
|
||||||
this.ComponentsGroupBox.Location = new System.Drawing.Point(12, 73);
|
|
||||||
this.ComponentsGroupBox.Name = "ComponentsGroupBox";
|
|
||||||
this.ComponentsGroupBox.Size = new System.Drawing.Size(677, 352);
|
|
||||||
this.ComponentsGroupBox.TabIndex = 4;
|
|
||||||
this.ComponentsGroupBox.TabStop = false;
|
|
||||||
this.ComponentsGroupBox.Text = "Компоненты";
|
|
||||||
//
|
|
||||||
// ButtonCancel
|
|
||||||
//
|
|
||||||
this.ButtonCancel.Location = new System.Drawing.Point(573, 321);
|
|
||||||
this.ButtonCancel.Name = "ButtonCancel";
|
|
||||||
this.ButtonCancel.Size = new System.Drawing.Size(98, 23);
|
|
||||||
this.ButtonCancel.TabIndex = 6;
|
|
||||||
this.ButtonCancel.Text = "Отмена";
|
|
||||||
this.ButtonCancel.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
|
||||||
//
|
|
||||||
// SaveButton
|
|
||||||
//
|
|
||||||
this.SaveButton.Location = new System.Drawing.Point(469, 321);
|
|
||||||
this.SaveButton.Name = "SaveButton";
|
|
||||||
this.SaveButton.Size = new System.Drawing.Size(98, 23);
|
|
||||||
this.SaveButton.TabIndex = 5;
|
|
||||||
this.SaveButton.Text = "Сохранить";
|
|
||||||
this.SaveButton.UseVisualStyleBackColor = true;
|
|
||||||
this.SaveButton.Click += new System.EventHandler(this.SaveButton_Click);
|
|
||||||
//
|
|
||||||
// DeleteButton
|
|
||||||
//
|
|
||||||
this.DeleteButton.Location = new System.Drawing.Point(521, 137);
|
|
||||||
this.DeleteButton.Name = "DeleteButton";
|
|
||||||
this.DeleteButton.Size = new System.Drawing.Size(150, 38);
|
|
||||||
this.DeleteButton.TabIndex = 4;
|
|
||||||
this.DeleteButton.Text = "Удалить";
|
|
||||||
this.DeleteButton.UseVisualStyleBackColor = true;
|
|
||||||
this.DeleteButton.Click += new System.EventHandler(this.DeleteButton_Click);
|
|
||||||
//
|
|
||||||
// UpdateButton
|
|
||||||
//
|
|
||||||
this.UpdateButton.Location = new System.Drawing.Point(521, 192);
|
|
||||||
this.UpdateButton.Name = "UpdateButton";
|
|
||||||
this.UpdateButton.Size = new System.Drawing.Size(150, 38);
|
|
||||||
this.UpdateButton.TabIndex = 3;
|
|
||||||
this.UpdateButton.Text = "Обновить";
|
|
||||||
this.UpdateButton.UseVisualStyleBackColor = true;
|
|
||||||
this.UpdateButton.Click += new System.EventHandler(this.UpdateButton_Click);
|
|
||||||
//
|
|
||||||
// ChangeButton
|
|
||||||
//
|
|
||||||
this.ChangeButton.Location = new System.Drawing.Point(521, 79);
|
|
||||||
this.ChangeButton.Name = "ChangeButton";
|
|
||||||
this.ChangeButton.Size = new System.Drawing.Size(150, 38);
|
|
||||||
this.ChangeButton.TabIndex = 2;
|
|
||||||
this.ChangeButton.Text = "Изменить";
|
|
||||||
this.ChangeButton.UseVisualStyleBackColor = true;
|
|
||||||
this.ChangeButton.Click += new System.EventHandler(this.ChangeButton_Click);
|
|
||||||
//
|
|
||||||
// AddButton
|
|
||||||
//
|
|
||||||
this.AddButton.Location = new System.Drawing.Point(521, 22);
|
|
||||||
this.AddButton.Name = "AddButton";
|
|
||||||
this.AddButton.Size = new System.Drawing.Size(150, 38);
|
|
||||||
this.AddButton.TabIndex = 1;
|
|
||||||
this.AddButton.Text = "Добавить";
|
|
||||||
this.AddButton.UseVisualStyleBackColor = true;
|
|
||||||
this.AddButton.Click += new System.EventHandler(this.AddButton_Click);
|
|
||||||
//
|
|
||||||
// dataGridView1
|
|
||||||
//
|
|
||||||
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
|
||||||
this.ID,
|
|
||||||
this.ComponentNameField,
|
|
||||||
this.CountField});
|
|
||||||
this.dataGridView1.Location = new System.Drawing.Point(6, 22);
|
|
||||||
this.dataGridView1.Name = "dataGridView1";
|
|
||||||
this.dataGridView1.RowTemplate.Height = 25;
|
|
||||||
this.dataGridView1.Size = new System.Drawing.Size(509, 285);
|
|
||||||
this.dataGridView1.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// ID
|
|
||||||
//
|
|
||||||
this.ID.HeaderText = "ID";
|
|
||||||
this.ID.Name = "ID";
|
|
||||||
this.ID.Visible = false;
|
|
||||||
//
|
|
||||||
// ComponentNameField
|
|
||||||
//
|
|
||||||
this.ComponentNameField.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
this.ComponentNameField.HeaderText = "Компонент";
|
|
||||||
this.ComponentNameField.Name = "ComponentNameField";
|
|
||||||
//
|
|
||||||
// CountField
|
|
||||||
//
|
|
||||||
this.CountField.HeaderText = "Количество";
|
|
||||||
this.CountField.Name = "CountField";
|
|
||||||
//
|
|
||||||
// FormFood
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(701, 429);
|
|
||||||
this.Controls.Add(this.ComponentsGroupBox);
|
|
||||||
this.Controls.Add(this.PriceTextBox);
|
|
||||||
this.Controls.Add(this.FoodNameTextBox);
|
|
||||||
this.Controls.Add(this.PriceLabel);
|
|
||||||
this.Controls.Add(this.FoodNameLabel);
|
|
||||||
this.Name = "FormFood";
|
|
||||||
this.Text = "Изделие";
|
|
||||||
this.ComponentsGroupBox.ResumeLayout(false);
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label FoodNameLabel;
|
|
||||||
private Label PriceLabel;
|
|
||||||
private TextBox FoodNameTextBox;
|
|
||||||
private TextBox PriceTextBox;
|
|
||||||
private GroupBox ComponentsGroupBox;
|
|
||||||
private Button ChangeButton;
|
|
||||||
private Button AddButton;
|
|
||||||
private DataGridView dataGridView1;
|
|
||||||
private DataGridViewTextBoxColumn ID;
|
|
||||||
private DataGridViewTextBoxColumn ComponentNameField;
|
|
||||||
private DataGridViewTextBoxColumn CountField;
|
|
||||||
private Button DeleteButton;
|
|
||||||
private Button UpdateButton;
|
|
||||||
private Button ButtonCancel;
|
|
||||||
private Button SaveButton;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,238 +0,0 @@
|
|||||||
using FoodOrdersDataModel.Models;
|
|
||||||
using FoodOrdersView;
|
|
||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.BusinessLogicsContracts;
|
|
||||||
using FoodOrdersContracts.SearchModels;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace FoodOrdersView
|
|
||||||
{
|
|
||||||
public partial class FormFood : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
|
|
||||||
private readonly IFoodLogic _logic;
|
|
||||||
|
|
||||||
private int? _id;
|
|
||||||
|
|
||||||
private Dictionary<int, (IComponentModel, int)> _workComponents;
|
|
||||||
|
|
||||||
public int Id { set { _id = value; } }
|
|
||||||
public FormFood(ILogger<FormFood> logger, IFoodLogic logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logic = logic;
|
|
||||||
_workComponents = new Dictionary<int, (IComponentModel, int)>();
|
|
||||||
}
|
|
||||||
private void FormFood_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_id.HasValue)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Загрузка изделия");
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var view = _logic.ReadElement(new FoodSearchModel
|
|
||||||
{
|
|
||||||
Id = _id.Value
|
|
||||||
});
|
|
||||||
|
|
||||||
if (view != null)
|
|
||||||
{
|
|
||||||
FoodNameTextBox.Text = view.FoodName;
|
|
||||||
PriceTextBox.Text = view.Price.ToString();
|
|
||||||
_workComponents = view.FoodComponents ?? new Dictionary<int, (IComponentModel, int)>();
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки изделия");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Загрузка компонент изделия");
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_workComponents != null)
|
|
||||||
{
|
|
||||||
dataGridView1.Rows.Clear();
|
|
||||||
foreach (var pc in _workComponents)
|
|
||||||
{
|
|
||||||
dataGridView1.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 });
|
|
||||||
}
|
|
||||||
PriceTextBox.Text = CalcPrice().ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки компонент изделия");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void AddButton_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormFoodComponent));
|
|
||||||
|
|
||||||
if (service is FormFoodComponent form)
|
|
||||||
{
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
if (form.ComponentModel == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Добавление нового компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
|
|
||||||
|
|
||||||
if (_workComponents.ContainsKey(form.Id))
|
|
||||||
{
|
|
||||||
_workComponents[form.Id] = (form.ComponentModel, form.Count);
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_workComponents.Add(form.Id, (form.ComponentModel, form.Count));
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ChangeButton_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView1.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormFoodComponent));
|
|
||||||
|
|
||||||
if (service is FormFoodComponent form)
|
|
||||||
{
|
|
||||||
int id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[0].Value);
|
|
||||||
form.Id = id;
|
|
||||||
form.Count = _workComponents[id].Item2;
|
|
||||||
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
if (form.ComponentModel == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Изменение компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
|
|
||||||
_workComponents[form.Id] = (form.ComponentModel, form.Count);
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DeleteButton_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView1.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Удаление компонента: { ComponentName} - { Count}", dataGridView1.SelectedRows[0].Cells[1].Value);
|
|
||||||
_workComponents?.Remove(Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[0].Value));
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateButton_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SaveButton_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(FoodNameTextBox.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(PriceTextBox.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_workComponents == null || _workComponents.Count == 0)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Сохранение изделия");
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var model = new FoodBindingModel
|
|
||||||
{
|
|
||||||
Id = _id ?? 0,
|
|
||||||
FoodName = FoodNameTextBox.Text,
|
|
||||||
Price = Convert.ToDouble(PriceTextBox.Text),
|
|
||||||
FoodComponents = _workComponents
|
|
||||||
};
|
|
||||||
|
|
||||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
|
||||||
|
|
||||||
if (!operationResult)
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
|
|
||||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
DialogResult = DialogResult.OK;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка сохранения изделия");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
DialogResult = DialogResult.Cancel;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
private double CalcPrice()
|
|
||||||
{
|
|
||||||
double price = 0;
|
|
||||||
|
|
||||||
foreach (var elem in _workComponents)
|
|
||||||
{
|
|
||||||
price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Math.Round(price * 1.1, 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,69 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<metadata name="ID.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="ComponentNameField.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="CountField.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
|
119
FoodOrders/FoodOrdersView/FormFoodComponent.Designer.cs
generated
119
FoodOrders/FoodOrdersView/FormFoodComponent.Designer.cs
generated
@ -1,119 +0,0 @@
|
|||||||
namespace FoodOrdersView
|
|
||||||
{
|
|
||||||
partial class FormFoodComponent
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.ComponentComboBox = new System.Windows.Forms.ComboBox();
|
|
||||||
this.ComponentSelectLabel = new System.Windows.Forms.Label();
|
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
|
||||||
this.CountTextBox = new System.Windows.Forms.TextBox();
|
|
||||||
this.SaveButton = new System.Windows.Forms.Button();
|
|
||||||
this.ButtonCancel = new System.Windows.Forms.Button();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// ComponentComboBox
|
|
||||||
//
|
|
||||||
this.ComponentComboBox.FormattingEnabled = true;
|
|
||||||
this.ComponentComboBox.Location = new System.Drawing.Point(108, 12);
|
|
||||||
this.ComponentComboBox.Name = "ComponentComboBox";
|
|
||||||
this.ComponentComboBox.Size = new System.Drawing.Size(234, 23);
|
|
||||||
this.ComponentComboBox.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// ComponentSelectLabel
|
|
||||||
//
|
|
||||||
this.ComponentSelectLabel.AutoSize = true;
|
|
||||||
this.ComponentSelectLabel.Location = new System.Drawing.Point(27, 15);
|
|
||||||
this.ComponentSelectLabel.Name = "ComponentSelectLabel";
|
|
||||||
this.ComponentSelectLabel.Size = new System.Drawing.Size(75, 15);
|
|
||||||
this.ComponentSelectLabel.TabIndex = 1;
|
|
||||||
this.ComponentSelectLabel.Text = "Компонент: ";
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
this.label1.AutoSize = true;
|
|
||||||
this.label1.Location = new System.Drawing.Point(27, 53);
|
|
||||||
this.label1.Name = "label1";
|
|
||||||
this.label1.Size = new System.Drawing.Size(75, 15);
|
|
||||||
this.label1.TabIndex = 2;
|
|
||||||
this.label1.Text = "Количество:";
|
|
||||||
//
|
|
||||||
// CountTextBox
|
|
||||||
//
|
|
||||||
this.CountTextBox.Location = new System.Drawing.Point(108, 50);
|
|
||||||
this.CountTextBox.Name = "CountTextBox";
|
|
||||||
this.CountTextBox.Size = new System.Drawing.Size(234, 23);
|
|
||||||
this.CountTextBox.TabIndex = 3;
|
|
||||||
//
|
|
||||||
// SaveButton
|
|
||||||
//
|
|
||||||
this.SaveButton.Location = new System.Drawing.Point(108, 87);
|
|
||||||
this.SaveButton.Name = "SaveButton";
|
|
||||||
this.SaveButton.Size = new System.Drawing.Size(89, 23);
|
|
||||||
this.SaveButton.TabIndex = 4;
|
|
||||||
this.SaveButton.Text = "Сохранить";
|
|
||||||
this.SaveButton.UseVisualStyleBackColor = true;
|
|
||||||
this.SaveButton.Click += new System.EventHandler(this.SaveButton_Click);
|
|
||||||
//
|
|
||||||
// ButtonCancel
|
|
||||||
//
|
|
||||||
this.ButtonCancel.Location = new System.Drawing.Point(253, 87);
|
|
||||||
this.ButtonCancel.Name = "ButtonCancel";
|
|
||||||
this.ButtonCancel.Size = new System.Drawing.Size(89, 23);
|
|
||||||
this.ButtonCancel.TabIndex = 5;
|
|
||||||
this.ButtonCancel.Text = "Отмена";
|
|
||||||
this.ButtonCancel.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
|
||||||
//
|
|
||||||
// FormFoodComponent
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(354, 122);
|
|
||||||
this.Controls.Add(this.ButtonCancel);
|
|
||||||
this.Controls.Add(this.SaveButton);
|
|
||||||
this.Controls.Add(this.CountTextBox);
|
|
||||||
this.Controls.Add(this.label1);
|
|
||||||
this.Controls.Add(this.ComponentSelectLabel);
|
|
||||||
this.Controls.Add(this.ComponentComboBox);
|
|
||||||
this.Name = "FormFoodComponent";
|
|
||||||
this.Text = "Компоненты изделия";
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private ComboBox ComponentComboBox;
|
|
||||||
private Label ComponentSelectLabel;
|
|
||||||
private Label label1;
|
|
||||||
private TextBox CountTextBox;
|
|
||||||
private Button SaveButton;
|
|
||||||
private Button ButtonCancel;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,90 +0,0 @@
|
|||||||
using FoodOrdersDataModel.Models;
|
|
||||||
using FoodOrdersContracts.BusinessLogicsContracts;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace FoodOrdersView
|
|
||||||
{
|
|
||||||
public partial class FormFoodComponent : Form
|
|
||||||
{
|
|
||||||
private readonly List<ComponentViewModel>? _list;
|
|
||||||
public int Id
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return Convert.ToInt32(ComponentComboBox.SelectedValue);
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
ComponentComboBox.SelectedValue = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IComponentModel? ComponentModel
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_list == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
foreach (var elem in _list)
|
|
||||||
{
|
|
||||||
if (elem.Id == Id)
|
|
||||||
{
|
|
||||||
return elem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public int Count
|
|
||||||
{
|
|
||||||
get { return Convert.ToInt32(CountTextBox.Text); }
|
|
||||||
set { CountTextBox.Text = value.ToString(); }
|
|
||||||
}
|
|
||||||
public FormFoodComponent(IComponentLogic logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_list = logic.ReadList(null);
|
|
||||||
if (_list != null)
|
|
||||||
{
|
|
||||||
ComponentComboBox.DisplayMember = "ComponentName";
|
|
||||||
ComponentComboBox.ValueMember = "Id";
|
|
||||||
ComponentComboBox.DataSource = _list;
|
|
||||||
ComponentComboBox.SelectedItem = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void SaveButton_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(CountTextBox.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ComponentComboBox.SelectedValue == null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Выберите компонент", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
DialogResult = DialogResult.OK;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
DialogResult = DialogResult.Cancel;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
121
FoodOrders/FoodOrdersView/FormFoods.Designer.cs
generated
121
FoodOrders/FoodOrdersView/FormFoods.Designer.cs
generated
@ -1,121 +0,0 @@
|
|||||||
namespace FoodOrdersView
|
|
||||||
{
|
|
||||||
partial class Изделия
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.dataGridView1 = new System.Windows.Forms.DataGridView();
|
|
||||||
this.AddButton = new System.Windows.Forms.Button();
|
|
||||||
this.ChangeButton = new System.Windows.Forms.Button();
|
|
||||||
this.DeleteButton = new System.Windows.Forms.Button();
|
|
||||||
this.UpdateButtoan = new System.Windows.Forms.Button();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// dataGridView1
|
|
||||||
//
|
|
||||||
this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
|
||||||
| System.Windows.Forms.AnchorStyles.Left)
|
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
this.dataGridView1.Location = new System.Drawing.Point(12, 12);
|
|
||||||
this.dataGridView1.Name = "dataGridView1";
|
|
||||||
this.dataGridView1.RowTemplate.Height = 25;
|
|
||||||
this.dataGridView1.Size = new System.Drawing.Size(572, 426);
|
|
||||||
this.dataGridView1.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// AddButton
|
|
||||||
//
|
|
||||||
this.AddButton.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
|
||||||
this.AddButton.Location = new System.Drawing.Point(590, 13);
|
|
||||||
this.AddButton.Name = "AddButton";
|
|
||||||
this.AddButton.Size = new System.Drawing.Size(109, 35);
|
|
||||||
this.AddButton.TabIndex = 1;
|
|
||||||
this.AddButton.Text = "Добавить";
|
|
||||||
this.AddButton.UseVisualStyleBackColor = true;
|
|
||||||
this.AddButton.Click += new System.EventHandler(this.AddButton_Click);
|
|
||||||
//
|
|
||||||
// ChangeButton
|
|
||||||
//
|
|
||||||
this.ChangeButton.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
|
||||||
this.ChangeButton.Location = new System.Drawing.Point(590, 63);
|
|
||||||
this.ChangeButton.Name = "ChangeButton";
|
|
||||||
this.ChangeButton.Size = new System.Drawing.Size(109, 35);
|
|
||||||
this.ChangeButton.TabIndex = 2;
|
|
||||||
this.ChangeButton.Text = "Изменить";
|
|
||||||
this.ChangeButton.UseVisualStyleBackColor = true;
|
|
||||||
this.ChangeButton.Click += new System.EventHandler(this.ChangeButton_Click);
|
|
||||||
//
|
|
||||||
// DeleteButton
|
|
||||||
//
|
|
||||||
this.DeleteButton.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
|
||||||
this.DeleteButton.Location = new System.Drawing.Point(590, 113);
|
|
||||||
this.DeleteButton.Name = "DeleteButton";
|
|
||||||
this.DeleteButton.Size = new System.Drawing.Size(109, 35);
|
|
||||||
this.DeleteButton.TabIndex = 3;
|
|
||||||
this.DeleteButton.Text = "Удалить";
|
|
||||||
this.DeleteButton.UseVisualStyleBackColor = true;
|
|
||||||
this.DeleteButton.Click += new System.EventHandler(this.DeleteButton_Click);
|
|
||||||
//
|
|
||||||
// UpdateButtoan
|
|
||||||
//
|
|
||||||
this.UpdateButtoan.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
|
||||||
this.UpdateButtoan.Location = new System.Drawing.Point(590, 163);
|
|
||||||
this.UpdateButtoan.Name = "UpdateButtoan";
|
|
||||||
this.UpdateButtoan.Size = new System.Drawing.Size(109, 35);
|
|
||||||
this.UpdateButtoan.TabIndex = 4;
|
|
||||||
this.UpdateButtoan.Text = "Обновить";
|
|
||||||
this.UpdateButtoan.UseVisualStyleBackColor = true;
|
|
||||||
this.UpdateButtoan.Click += new System.EventHandler(this.UpdateButton_Click);
|
|
||||||
//
|
|
||||||
// Изделия
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(711, 450);
|
|
||||||
this.Controls.Add(this.UpdateButtoan);
|
|
||||||
this.Controls.Add(this.DeleteButton);
|
|
||||||
this.Controls.Add(this.ChangeButton);
|
|
||||||
this.Controls.Add(this.AddButton);
|
|
||||||
this.Controls.Add(this.dataGridView1);
|
|
||||||
this.Name = "Изделия";
|
|
||||||
this.Text = "Изделия";
|
|
||||||
this.Load += new System.EventHandler(this.FormComponents_Load);
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private DataGridView dataGridView1;
|
|
||||||
private Button AddButton;
|
|
||||||
private Button ChangeButton;
|
|
||||||
private Button DeleteButton;
|
|
||||||
private Button UpdateButtoan;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,121 +0,0 @@
|
|||||||
using FoodOrdersView;
|
|
||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.BusinessLogicsContracts;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace FoodOrdersView
|
|
||||||
{
|
|
||||||
public partial class Изделия : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IFoodLogic _logic;
|
|
||||||
|
|
||||||
public Изделия(ILogger<Изделия> logger, IFoodLogic logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logic = logic;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormComponents_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var list = _logic.ReadList(null);
|
|
||||||
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView1.DataSource = list;
|
|
||||||
dataGridView1.Columns["Id"].Visible = false;
|
|
||||||
dataGridView1.Columns["FoodName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
dataGridView1.Columns["FoodComponents"].Visible = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Загрузка изделий");
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки изделий");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void AddButton_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormFood));
|
|
||||||
|
|
||||||
if (service is FormFood form)
|
|
||||||
{
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ChangeButton_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView1.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormFood));
|
|
||||||
|
|
||||||
if (service is FormFood form)
|
|
||||||
{
|
|
||||||
form.Id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void DeleteButton_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView1.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
||||||
{
|
|
||||||
int id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
_logger.LogInformation("Удаление изделия");
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!_logic.Delete(new FoodBindingModel
|
|
||||||
{
|
|
||||||
Id = id
|
|
||||||
}))
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка удаления изделия");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void UpdateButton_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
182
FoodOrders/FoodOrdersView/FormMain.Designer.cs
generated
182
FoodOrders/FoodOrdersView/FormMain.Designer.cs
generated
@ -1,182 +0,0 @@
|
|||||||
namespace FoodOrdersView
|
|
||||||
{
|
|
||||||
partial class FormMain
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
|
||||||
this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.изделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.dataGridView1 = new System.Windows.Forms.DataGridView();
|
|
||||||
this.CreateOrderButton = new System.Windows.Forms.Button();
|
|
||||||
this.TakeOrderInWorkButton = new System.Windows.Forms.Button();
|
|
||||||
this.OrderReadyButton = new System.Windows.Forms.Button();
|
|
||||||
this.IssuedOrderButton = new System.Windows.Forms.Button();
|
|
||||||
this.UpdateListButton = new System.Windows.Forms.Button();
|
|
||||||
this.menuStrip1.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// menuStrip1
|
|
||||||
//
|
|
||||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
|
||||||
this.справочникиToolStripMenuItem});
|
|
||||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
|
||||||
this.menuStrip1.Name = "menuStrip1";
|
|
||||||
this.menuStrip1.Size = new System.Drawing.Size(700, 24);
|
|
||||||
this.menuStrip1.TabIndex = 0;
|
|
||||||
this.menuStrip1.Text = "menuStrip1";
|
|
||||||
//
|
|
||||||
// справочникиToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
|
||||||
this.изделияToolStripMenuItem,
|
|
||||||
this.компонентыToolStripMenuItem});
|
|
||||||
this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
|
||||||
this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(94, 20);
|
|
||||||
this.справочникиToolStripMenuItem.Text = "Справочники";
|
|
||||||
//
|
|
||||||
// изделияToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.изделияToolStripMenuItem.Name = "изделияToolStripMenuItem";
|
|
||||||
this.изделияToolStripMenuItem.Size = new System.Drawing.Size(145, 22);
|
|
||||||
this.изделияToolStripMenuItem.Text = "Изделия";
|
|
||||||
this.изделияToolStripMenuItem.Click += new System.EventHandler(this.ИзделияToolStripMenuItem_Click);
|
|
||||||
//
|
|
||||||
// компонентыToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
|
||||||
this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(145, 22);
|
|
||||||
this.компонентыToolStripMenuItem.Text = "Компоненты";
|
|
||||||
this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.КомпонентыToolStripMenuItem_Click);
|
|
||||||
//
|
|
||||||
// dataGridView1
|
|
||||||
//
|
|
||||||
this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
|
||||||
| System.Windows.Forms.AnchorStyles.Left)
|
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
this.dataGridView1.Location = new System.Drawing.Point(0, 27);
|
|
||||||
this.dataGridView1.Name = "dataGridView1";
|
|
||||||
this.dataGridView1.RowTemplate.Height = 25;
|
|
||||||
this.dataGridView1.Size = new System.Drawing.Size(568, 341);
|
|
||||||
this.dataGridView1.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// CreateOrderButton
|
|
||||||
//
|
|
||||||
this.CreateOrderButton.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
|
||||||
this.CreateOrderButton.Location = new System.Drawing.Point(574, 27);
|
|
||||||
this.CreateOrderButton.Name = "CreateOrderButton";
|
|
||||||
this.CreateOrderButton.Size = new System.Drawing.Size(122, 41);
|
|
||||||
this.CreateOrderButton.TabIndex = 2;
|
|
||||||
this.CreateOrderButton.Text = "Создать заказ";
|
|
||||||
this.CreateOrderButton.UseVisualStyleBackColor = true;
|
|
||||||
this.CreateOrderButton.Click += new System.EventHandler(this.CreateOrderButton_Click);
|
|
||||||
//
|
|
||||||
// TakeOrderInWorkButton
|
|
||||||
//
|
|
||||||
this.TakeOrderInWorkButton.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
|
||||||
this.TakeOrderInWorkButton.Location = new System.Drawing.Point(574, 74);
|
|
||||||
this.TakeOrderInWorkButton.Name = "TakeOrderInWorkButton";
|
|
||||||
this.TakeOrderInWorkButton.Size = new System.Drawing.Size(122, 41);
|
|
||||||
this.TakeOrderInWorkButton.TabIndex = 3;
|
|
||||||
this.TakeOrderInWorkButton.Text = "Отдать на выполнение";
|
|
||||||
this.TakeOrderInWorkButton.UseVisualStyleBackColor = true;
|
|
||||||
this.TakeOrderInWorkButton.Click += new System.EventHandler(this.TakeOrderInWorkButton_Click);
|
|
||||||
//
|
|
||||||
// OrderReadyButton
|
|
||||||
//
|
|
||||||
this.OrderReadyButton.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
|
||||||
this.OrderReadyButton.Location = new System.Drawing.Point(574, 121);
|
|
||||||
this.OrderReadyButton.Name = "OrderReadyButton";
|
|
||||||
this.OrderReadyButton.Size = new System.Drawing.Size(122, 41);
|
|
||||||
this.OrderReadyButton.TabIndex = 4;
|
|
||||||
this.OrderReadyButton.Text = "Заказ готов";
|
|
||||||
this.OrderReadyButton.UseVisualStyleBackColor = true;
|
|
||||||
this.OrderReadyButton.Click += new System.EventHandler(this.OrderReadyButton_Click);
|
|
||||||
//
|
|
||||||
// IssuedOrderButton
|
|
||||||
//
|
|
||||||
this.IssuedOrderButton.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
|
||||||
this.IssuedOrderButton.Location = new System.Drawing.Point(574, 168);
|
|
||||||
this.IssuedOrderButton.Name = "IssuedOrderButton";
|
|
||||||
this.IssuedOrderButton.Size = new System.Drawing.Size(122, 41);
|
|
||||||
this.IssuedOrderButton.TabIndex = 5;
|
|
||||||
this.IssuedOrderButton.Text = "Заказ выдан";
|
|
||||||
this.IssuedOrderButton.UseVisualStyleBackColor = true;
|
|
||||||
this.IssuedOrderButton.Click += new System.EventHandler(this.IssuedOrderButton_Click);
|
|
||||||
//
|
|
||||||
// UpdateListButton
|
|
||||||
//
|
|
||||||
this.UpdateListButton.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
|
||||||
this.UpdateListButton.Location = new System.Drawing.Point(574, 215);
|
|
||||||
this.UpdateListButton.Name = "UpdateListButton";
|
|
||||||
this.UpdateListButton.Size = new System.Drawing.Size(122, 41);
|
|
||||||
this.UpdateListButton.TabIndex = 6;
|
|
||||||
this.UpdateListButton.Text = "Обновить список";
|
|
||||||
this.UpdateListButton.UseVisualStyleBackColor = true;
|
|
||||||
this.UpdateListButton.Click += new System.EventHandler(this.UpdateListButton_Click);
|
|
||||||
//
|
|
||||||
// FormMain
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(700, 380);
|
|
||||||
this.Controls.Add(this.UpdateListButton);
|
|
||||||
this.Controls.Add(this.IssuedOrderButton);
|
|
||||||
this.Controls.Add(this.OrderReadyButton);
|
|
||||||
this.Controls.Add(this.TakeOrderInWorkButton);
|
|
||||||
this.Controls.Add(this.CreateOrderButton);
|
|
||||||
this.Controls.Add(this.dataGridView1);
|
|
||||||
this.Controls.Add(this.menuStrip1);
|
|
||||||
this.MainMenuStrip = this.menuStrip1;
|
|
||||||
this.Name = "FormMain";
|
|
||||||
this.Text = "Заказ еды";
|
|
||||||
this.Load += new System.EventHandler(this.FormMain_Load);
|
|
||||||
this.menuStrip1.ResumeLayout(false);
|
|
||||||
this.menuStrip1.PerformLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private MenuStrip menuStrip1;
|
|
||||||
private ToolStripMenuItem справочникиToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem изделияToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem компонентыToolStripMenuItem;
|
|
||||||
private DataGridView dataGridView1;
|
|
||||||
private Button CreateOrderButton;
|
|
||||||
private Button TakeOrderInWorkButton;
|
|
||||||
private Button OrderReadyButton;
|
|
||||||
private Button IssuedOrderButton;
|
|
||||||
private Button UpdateListButton;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,191 +0,0 @@
|
|||||||
using FoodOrdersDataModel.Enums;
|
|
||||||
using FoodOrdersView;
|
|
||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.BusinessLogicsContracts;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace FoodOrdersView
|
|
||||||
{
|
|
||||||
public partial class FormMain : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IOrderLogic _orderLogic;
|
|
||||||
|
|
||||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_orderLogic = orderLogic;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormMain_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Загрузка заказов");
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var list = _orderLogic.ReadList(null);
|
|
||||||
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView1.DataSource = list;
|
|
||||||
dataGridView1.Columns["FoodId"].Visible = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Загрузка заказов");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки заказов");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
|
||||||
|
|
||||||
if (service is FormComponents form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(Изделия));
|
|
||||||
|
|
||||||
if (service is Изделия form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CreateOrderButton_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
|
||||||
|
|
||||||
if (service is FormCreateOrder form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TakeOrderInWorkButton_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView1.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
int id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Принят'", id);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
|
|
||||||
{
|
|
||||||
Id = id,
|
|
||||||
FoodId = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["FoodId"].Value),
|
|
||||||
FoodName = dataGridView1.SelectedRows[0].Cells["FoodName"].Value.ToString(),
|
|
||||||
Status = Enum.Parse<OrderStatus>(dataGridView1.SelectedRows[0].Cells["Status"].Value.ToString()),
|
|
||||||
Count = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Count"].Value),
|
|
||||||
Sum = double.Parse(dataGridView1.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
|
||||||
DateCreate = DateTime.Parse(dataGridView1.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!operationResult)
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка передачи заказа в работу");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void IssuedOrderButton_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView1.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
int id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
|
|
||||||
{
|
|
||||||
Id = id,
|
|
||||||
FoodId = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["FoodId"].Value),
|
|
||||||
FoodName = dataGridView1.SelectedRows[0].Cells["FoodName"].Value.ToString(),
|
|
||||||
Status = Enum.Parse<OrderStatus>(dataGridView1.SelectedRows[0].Cells["Status"].Value.ToString()),
|
|
||||||
Count = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Count"].Value),
|
|
||||||
Sum = double.Parse(dataGridView1.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
|
||||||
DateCreate = DateTime.Parse(dataGridView1.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!operationResult)
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка отметки о готовности заказа");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OrderReadyButton_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView1.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
int id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel
|
|
||||||
{
|
|
||||||
Id = id,
|
|
||||||
FoodId = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["FoodId"].Value),
|
|
||||||
FoodName = dataGridView1.SelectedRows[0].Cells["FoodName"].Value.ToString(),
|
|
||||||
Status = Enum.Parse<OrderStatus>(dataGridView1.SelectedRows[0].Cells["Status"].Value.ToString()),
|
|
||||||
Count = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Count"].Value),
|
|
||||||
Sum = double.Parse(dataGridView1.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
|
||||||
DateCreate = DateTime.Parse(dataGridView1.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!operationResult)
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Заказ №{id} выдан", id);
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка отметки о выдачи заказа");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateListButton_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,66 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>17, 17</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>25</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
|
@ -1,51 +0,0 @@
|
|||||||
using FoodOrdersBusinessLogic.BusinessLogic;
|
|
||||||
using FoodOrdersBusinessLogic.BusinessLogics;
|
|
||||||
using FoodOrdersContracts.BusinessLogicsContracts;
|
|
||||||
using FoodOrdersContracts.StoragesContracts;
|
|
||||||
using FoodOrderDatabaseImplement.Implements;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using NLog.Extensions.Logging;
|
|
||||||
using PlumbingRepairBusinessLogic.BusinessLogic;
|
|
||||||
|
|
||||||
namespace FoodOrdersView
|
|
||||||
{
|
|
||||||
internal static class Program
|
|
||||||
{
|
|
||||||
private static IServiceProvider? _serviceProvider;
|
|
||||||
public static IServiceProvider? ServiceProvider => _serviceProvider;
|
|
||||||
/// <summary>
|
|
||||||
/// The main entry point for the application.
|
|
||||||
/// </summary>
|
|
||||||
[STAThread]
|
|
||||||
static void Main()
|
|
||||||
{
|
|
||||||
ApplicationConfiguration.Initialize();
|
|
||||||
var services = new ServiceCollection();
|
|
||||||
ConfigureServices(services);
|
|
||||||
_serviceProvider = services.BuildServiceProvider();
|
|
||||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
|
||||||
}
|
|
||||||
private static void ConfigureServices(ServiceCollection services)
|
|
||||||
{
|
|
||||||
services.AddLogging(option =>
|
|
||||||
{
|
|
||||||
option.SetMinimumLevel(LogLevel.Information);
|
|
||||||
option.AddNLog("nlog.config");
|
|
||||||
});
|
|
||||||
services.AddTransient<IComponentStorage, ComponentStorage>();
|
|
||||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
|
||||||
services.AddTransient<IFoodStorage, FoodStorage>();
|
|
||||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
|
||||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
|
||||||
services.AddTransient<IFoodLogic, FoodLogic>();
|
|
||||||
services.AddTransient<FormMain>();
|
|
||||||
services.AddTransient<FormComponent>();
|
|
||||||
services.AddTransient<FormComponents>();
|
|
||||||
services.AddTransient<FormCreateOrder>();
|
|
||||||
services.AddTransient<FormFood>();
|
|
||||||
services.AddTransient<FormFoodComponent>();
|
|
||||||
services.AddTransient<Èçäåëèÿ>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
// <auto-generated>
|
|
||||||
// Этот код создан программой.
|
|
||||||
// Исполняемая версия:4.0.30319.42000
|
|
||||||
//
|
|
||||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
|
||||||
// повторной генерации кода.
|
|
||||||
// </auto-generated>
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
namespace FoodOrdersView.Properties {
|
|
||||||
using System;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
|
|
||||||
/// </summary>
|
|
||||||
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
|
|
||||||
// с помощью такого средства, как ResGen или Visual Studio.
|
|
||||||
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
|
|
||||||
// с параметром /str или перестройте свой проект VS.
|
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
|
||||||
internal class Resources {
|
|
||||||
|
|
||||||
private static global::System.Resources.ResourceManager resourceMan;
|
|
||||||
|
|
||||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
|
||||||
|
|
||||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
|
||||||
internal Resources() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
|
||||||
get {
|
|
||||||
if (object.ReferenceEquals(resourceMan, null)) {
|
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FoodOrdersView.Properties.Resources", typeof(Resources).Assembly);
|
|
||||||
resourceMan = temp;
|
|
||||||
}
|
|
||||||
return resourceMan;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
|
||||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
internal static global::System.Globalization.CultureInfo Culture {
|
|
||||||
get {
|
|
||||||
return resourceCulture;
|
|
||||||
}
|
|
||||||
set {
|
|
||||||
resourceCulture = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
|
||||||
<configuration>
|
|
||||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
autoReload="true" internalLogLevel="Info">
|
|
||||||
|
|
||||||
<targets>
|
|
||||||
<target xsi:type="File" name="tofile" fileName="${basedir}/carlog-${shortdate}.log" />
|
|
||||||
</targets>
|
|
||||||
|
|
||||||
<rules>
|
|
||||||
<logger name="*" minlevel="Debug" writeTo="tofile" />
|
|
||||||
</rules>
|
|
||||||
</nlog>
|
|
||||||
</configuration>
|
|
Loading…
x
Reference in New Issue
Block a user