This commit is contained in:
Илья Федотов 2024-05-01 21:05:07 +04:00
parent c2faa8cfe5
commit 64ba40c90c
33 changed files with 1042 additions and 470 deletions

View File

@ -15,7 +15,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DineryBusinessLogic", "Dine
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DinerFileImplement", "DinerShopImplement\DinerFileImplement.csproj", "{E46007E3-F3EC-4551-A203-19361E7B1B8D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DinerDataBaseImplement", "DinerDataBaseImplement\DinerDataBaseImplement.csproj", "{42A59EB5-A475-4CEF-AE2F-1396D6BFD143}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DinerDataBaseImplement", "DinerDataBaseImplement\DinerDataBaseImplement.csproj", "{42A59EB5-A475-4CEF-AE2F-1396D6BFD143}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DinerRestApi", "DinerRestAPI\DinerRestApi.csproj", "{68493262-499C-4677-ADAD-F7FFEF4F448F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -51,6 +53,10 @@ Global
{42A59EB5-A475-4CEF-AE2F-1396D6BFD143}.Debug|Any CPU.Build.0 = Debug|Any CPU
{42A59EB5-A475-4CEF-AE2F-1396D6BFD143}.Release|Any CPU.ActiveCfg = Release|Any CPU
{42A59EB5-A475-4CEF-AE2F-1396D6BFD143}.Release|Any CPU.Build.0 = Release|Any CPU
{68493262-499C-4677-ADAD-F7FFEF4F448F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{68493262-499C-4677-ADAD-F7FFEF4F448F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{68493262-499C-4677-ADAD-F7FFEF4F448F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{68493262-499C-4677-ADAD-F7FFEF4F448F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -15,5 +15,6 @@ namespace DinerDataBaseImplement
public virtual DbSet<Snack> Products { get; set; }
public virtual DbSet<SnackFood> ProductComponents { get; set; }
public virtual DbSet<Order> Orders { get; set; }
public virtual DbSet<Client> Clients { get; set; }
}
}

View File

@ -2,6 +2,7 @@
using DinerContracts.SearchModels;
using DinerContracts.StoragesContracts;
using DinerContracts.ViewModels;
using DinerDataBaseImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
@ -10,28 +11,61 @@ using System.Threading.Tasks;
namespace DinerDataBaseImplement.Implements {
public class ClientStorage : IClientStorage {
public ClientViewModel? Delete(ClientBindingModel model) {
throw new NotImplementedException();
}
public ClientViewModel? GetElement(ClientSearchModel model) {
throw new NotImplementedException();
}
public List<ClientViewModel> GetFilteredList(ClientSearchModel model) {
throw new NotImplementedException();
}
public List<ClientViewModel> GetFullList() {
throw new NotImplementedException();
}
public ClientViewModel? Insert(ClientBindingModel model) {
throw new NotImplementedException();
var newClient = Client.Create(model);
if (newClient == null) {
return null;
}
using var context = new DinerDataBase();
context.Clients.Add(newClient);
context.SaveChanges();
return newClient.GetViewModel;
}
public ClientViewModel? Update(ClientBindingModel model) {
throw new NotImplementedException();
using var context = new DinerDataBase();
var client = context.Clients.FirstOrDefault(x => x.ID == model.ID);
if (client == null) {
return null;
}
client.Update(model);
context.SaveChanges();
return client.GetViewModel;
}
public ClientViewModel? Delete(ClientBindingModel model) {
using var context = new DinerDataBase();
var element = context.Clients.FirstOrDefault(x => x.ID == model.ID);
if (element != null) {
context.Clients.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
public ClientViewModel? GetElement(ClientSearchModel model) {
if (string.IsNullOrEmpty(model.ClientFIO) && !model.ID.HasValue) {
return null;
}
using var context = new DinerDataBase();
return context.Clients.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ClientFIO) &&
x.ClientFIO == model.ClientFIO) || model.ID.HasValue &&
x.ID == model.ID)?.GetViewModel;
}
public List<ClientViewModel> GetFilteredList(ClientSearchModel model) {
if (string.IsNullOrEmpty(model.ClientFIO)) {
return new();
}
using var context = new DinerDataBase();
return context.Clients.Where(x => x.ClientFIO.Contains(model.ClientFIO)).Select(x => x.GetViewModel).ToList();
}
public List<ClientViewModel> GetFullList() {
using var context = new DinerDataBase();
return context.Clients.Select(x => x.GetViewModel).ToList();
}
}
}

View File

@ -2,7 +2,6 @@
using DinerContracts.SearchModels;
using DinerContracts.StoragesContracts;
using DinerContracts.ViewModels;
using DinerDataBaseImplement.Migrations;
using DinerDataBaseImplement.Models;
using System;
using System.Collections.Generic;

View File

@ -1,157 +0,0 @@
// <auto-generated />
using System;
using DinerDataBaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace DinerDataBaseImplement.Migrations
{
[DbContext(typeof(DinerDataBase))]
[Migration("20240321182759_InitMigration")]
partial class InitMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("DinerDataBaseImplement.Models.Food", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<string>("ProductName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("ID");
b.ToTable("Components");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.Order", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement")
.IsRequired()
.HasColumnType("datetime2");
b.Property<int>("ProductID")
.HasColumnType("int");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<double>("Sum")
.HasColumnType("float");
b.HasKey("ID");
b.ToTable("Orders");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.Snack", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<double>("Price")
.HasColumnType("float");
b.Property<string>("ProductName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.ToTable("Components");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.SnackFood", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int>("ComponentID")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("ProductID")
.HasColumnType("int");
b.HasKey("ID");
b.HasIndex("ComponentID");
b.HasIndex("ProductID");
b.ToTable("ProductComponents");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.SnackFood", b =>
{
b.HasOne("DinerDataBaseImplement.Models.Food", "Component")
.WithMany("SnackFood")
.HasForeignKey("ComponentID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DinerDataBaseImplement.Models.Snack", "Product")
.WithMany("Components")
.HasForeignKey("ProductID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Product");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.Food", b =>
{
b.Navigation("SnackFood");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.Snack", b =>
{
b.Navigation("Components");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,156 +0,0 @@
// <auto-generated />
using System;
using DinerDataBaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace DinerDataBaseImplement.Migrations
{
[DbContext(typeof(DinerDataBase))]
[Migration("20240403124835_Migration02")]
partial class Migration02
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("DinerDataBaseImplement.Models.Food", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<string>("ProductName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("ID");
b.ToTable("Components");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.Order", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<int>("ProductID")
.HasColumnType("int");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<double>("Sum")
.HasColumnType("float");
b.HasKey("ID");
b.ToTable("Orders");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.Snack", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<double>("Price")
.HasColumnType("float");
b.Property<string>("ProductName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.ToTable("Components");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.SnackFood", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int>("ComponentID")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("ProductID")
.HasColumnType("int");
b.HasKey("ID");
b.HasIndex("ComponentID");
b.HasIndex("ProductID");
b.ToTable("ProductComponents");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.SnackFood", b =>
{
b.HasOne("DinerDataBaseImplement.Models.Food", "Component")
.WithMany("SnackFood")
.HasForeignKey("ComponentID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DinerDataBaseImplement.Models.Snack", "Product")
.WithMany("Components")
.HasForeignKey("ProductID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Product");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.Food", b =>
{
b.Navigation("SnackFood");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.Snack", b =>
{
b.Navigation("Components");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,37 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DinerDataBaseImplement.Migrations
{
/// <inheritdoc />
public partial class Migration02 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<DateTime>(
name: "DateImplement",
table: "Orders",
type: "datetime2",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "datetime2");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<DateTime>(
name: "DateImplement",
table: "Orders",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldNullable: true);
}
}
}

View File

@ -1,48 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DinerDataBaseImplement.Migrations
{
/// <inheritdoc />
public partial class Migration03 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "SnackID",
table: "Orders",
type: "int",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_Orders_SnackID",
table: "Orders",
column: "SnackID");
migrationBuilder.AddForeignKey(
name: "FK_Orders_Products_SnackID",
table: "Orders",
column: "SnackID",
principalTable: "Components",
principalColumn: "ID");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Orders_Products_SnackID",
table: "Orders");
migrationBuilder.DropIndex(
name: "IX_Orders_SnackID",
table: "Orders");
migrationBuilder.DropColumn(
name: "SnackID",
table: "Orders");
}
}
}

View File

@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace DinerDataBaseImplement.Migrations
{
[DbContext(typeof(DinerDataBase))]
[Migration("20240405063803_Migration03")]
partial class Migration03
[Migration("20240501160144_InitMigration")]
partial class InitMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -25,6 +25,31 @@ namespace DinerDataBaseImplement.Migrations
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("DinerDataBaseImplement.Models.Client", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<string>("ClientFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.ToTable("Clients");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.Food", b =>
{
b.Property<int>("ID")
@ -33,7 +58,7 @@ namespace DinerDataBaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<string>("ProductName")
b.Property<string>("ComponentName")
.IsRequired()
.HasColumnType("nvarchar(max)");
@ -53,6 +78,9 @@ namespace DinerDataBaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int?>("ClientID")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
@ -76,6 +104,8 @@ namespace DinerDataBaseImplement.Migrations
b.HasKey("ID");
b.HasIndex("ClientID");
b.HasIndex("SnackID");
b.ToTable("Orders");
@ -98,7 +128,7 @@ namespace DinerDataBaseImplement.Migrations
b.HasKey("ID");
b.ToTable("Components");
b.ToTable("Products");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.SnackFood", b =>
@ -129,6 +159,10 @@ namespace DinerDataBaseImplement.Migrations
modelBuilder.Entity("DinerDataBaseImplement.Models.Order", b =>
{
b.HasOne("DinerDataBaseImplement.Models.Client", null)
.WithMany("Orders")
.HasForeignKey("ClientID");
b.HasOne("DinerDataBaseImplement.Models.Snack", "Snack")
.WithMany()
.HasForeignKey("SnackID");
@ -155,6 +189,11 @@ namespace DinerDataBaseImplement.Migrations
b.Navigation("Product");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.Client", b =>
{
b.Navigation("Orders");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.Food", b =>
{
b.Navigation("SnackFood");

View File

@ -11,6 +11,21 @@ namespace DinerDataBaseImplement.Migrations
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Clients",
columns: table => new
{
ID = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ClientFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Clients", x => x.ID);
});
migrationBuilder.CreateTable(
name: "Components",
columns: table => new
@ -26,25 +41,7 @@ namespace DinerDataBaseImplement.Migrations
});
migrationBuilder.CreateTable(
name: "Orders",
columns: table => new
{
ID = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ProductID = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(type: "int", nullable: false),
Sum = table.Column<double>(type: "float", nullable: false),
Status = table.Column<int>(type: "int", nullable: false),
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Orders", x => x.ID);
});
migrationBuilder.CreateTable(
name: "Components",
name: "Products",
columns: table => new
{
ID = table.Column<int>(type: "int", nullable: false)
@ -57,6 +54,36 @@ namespace DinerDataBaseImplement.Migrations
table.PrimaryKey("PK_Products", x => x.ID);
});
migrationBuilder.CreateTable(
name: "Orders",
columns: table => new
{
ID = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ProductID = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(type: "int", nullable: false),
Sum = table.Column<double>(type: "float", nullable: false),
Status = table.Column<int>(type: "int", nullable: false),
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true),
SnackID = table.Column<int>(type: "int", nullable: true),
ClientID = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Orders", x => x.ID);
table.ForeignKey(
name: "FK_Orders_Clients_ClientID",
column: x => x.ClientID,
principalTable: "Clients",
principalColumn: "ID");
table.ForeignKey(
name: "FK_Orders_Products_SnackID",
column: x => x.SnackID,
principalTable: "Products",
principalColumn: "ID");
});
migrationBuilder.CreateTable(
name: "ProductComponents",
columns: table => new
@ -79,11 +106,21 @@ namespace DinerDataBaseImplement.Migrations
table.ForeignKey(
name: "FK_ProductComponents_Products_ProductID",
column: x => x.ProductID,
principalTable: "Components",
principalTable: "Products",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Orders_ClientID",
table: "Orders",
column: "ClientID");
migrationBuilder.CreateIndex(
name: "IX_Orders_SnackID",
table: "Orders",
column: "SnackID");
migrationBuilder.CreateIndex(
name: "IX_ProductComponents_ComponentID",
table: "ProductComponents",
@ -105,10 +142,13 @@ namespace DinerDataBaseImplement.Migrations
name: "ProductComponents");
migrationBuilder.DropTable(
name: "Components");
name: "Clients");
migrationBuilder.DropTable(
name: "Components");
migrationBuilder.DropTable(
name: "Products");
}
}
}

View File

@ -22,6 +22,31 @@ namespace DinerDataBaseImplement.Migrations
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("DinerDataBaseImplement.Models.Client", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<string>("ClientFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.ToTable("Clients");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.Food", b =>
{
b.Property<int>("ID")
@ -30,7 +55,7 @@ namespace DinerDataBaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<string>("ProductName")
b.Property<string>("ComponentName")
.IsRequired()
.HasColumnType("nvarchar(max)");
@ -39,7 +64,7 @@ namespace DinerDataBaseImplement.Migrations
b.HasKey("ID");
b.ToTable("Components", (string)null);
b.ToTable("Components");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.Order", b =>
@ -50,6 +75,9 @@ namespace DinerDataBaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int?>("ClientID")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
@ -73,9 +101,11 @@ namespace DinerDataBaseImplement.Migrations
b.HasKey("ID");
b.HasIndex("ClientID");
b.HasIndex("SnackID");
b.ToTable("Orders", (string)null);
b.ToTable("Orders");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.Snack", b =>
@ -95,7 +125,7 @@ namespace DinerDataBaseImplement.Migrations
b.HasKey("ID");
b.ToTable("Components", (string)null);
b.ToTable("Products");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.SnackFood", b =>
@ -121,11 +151,15 @@ namespace DinerDataBaseImplement.Migrations
b.HasIndex("ProductID");
b.ToTable("ProductComponents", (string)null);
b.ToTable("ProductComponents");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.Order", b =>
{
b.HasOne("DinerDataBaseImplement.Models.Client", null)
.WithMany("Orders")
.HasForeignKey("ClientID");
b.HasOne("DinerDataBaseImplement.Models.Snack", "Snack")
.WithMany()
.HasForeignKey("SnackID");
@ -152,6 +186,11 @@ namespace DinerDataBaseImplement.Migrations
b.Navigation("Product");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.Client", b =>
{
b.Navigation("Orders");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.Food", b =>
{
b.Navigation("SnackFood");

View File

@ -0,0 +1,57 @@
using DinerContracts.BindingModels;
using DinerContracts.ViewModels;
using DinerDataModels.Models;
using Microsoft.EntityFrameworkCore.Query.Internal;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DinerDataBaseImplement.Models {
public class Client : IClientModel {
[Required]
public string ClientFIO { get; set; } = string.Empty;
[Required]
public string Email { get; set; } = string.Empty;
[Required]
public string Password { get; set; } = string.Empty;
public int ID { get; private set; }
[ForeignKey("ClientID")]
public virtual List<Order> Orders { get; set; } = new();
public static Client? Create(ClientBindingModel? model) {
if (model == null) {
return null;
}
return new Client() {
ClientFIO = model.ClientFIO,
Email = model.Email,
Password = model.Password,
ID = model.ID,
};
}
public void Update(ClientBindingModel? model) {
if (model == null) {
return;
}
ClientFIO = model.ClientFIO;
Email = model.Email;
Password = model.Password;
}
public ClientViewModel GetViewModel => new() {
ClientFIO = ClientFIO,
Email = Email,
Password = Password,
ID = ID
};
}
}

View File

@ -14,11 +14,13 @@ namespace DinerListImplement
public List<Food> Foods { get; set; }
public List<Snack> Snacks { get; set; }
public List<Order> Orders { get; set; }
public List<Client> Clients { get; set; }
private DataListSingleton() {
Foods = new List<Food>();
Snacks = new List<Snack>();
Orders = new List<Order>();
Clients = new List<Client>();
}
public static DataListSingleton GetInstance() {
if (_instance == null) _instance = new DataListSingleton();

View File

@ -2,6 +2,7 @@
using DinerContracts.SearchModels;
using DinerContracts.StoragesContracts;
using DinerContracts.ViewModels;
using DinerListImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
@ -18,27 +19,74 @@ namespace DinerListImplement.Implements {
}
public ClientViewModel? Insert(ClientBindingModel model) {
throw new NotImplementedException();
model.ID = 1;
foreach (var client in _source.Clients) {
if (model.ID <= client.ID) {
model.ID = client.ID;
}
}
var newClient = Client.Create(model);
if (newClient == null) {
return null;
}
_source.Clients.Add(newClient);
return newClient.GetViewModel;
}
public ClientViewModel? Update(ClientBindingModel model) {
throw new NotImplementedException();
foreach (var client in _source.Clients) {
if (client.ID == model.ID) {
client.Update(model);
return client.GetViewModel;
}
}
return null;
}
public ClientViewModel? Delete(ClientBindingModel model) {
throw new NotImplementedException();
for (int i = 0; i < _source.Clients.Count; ++i) {
if (_source.Clients[i].ID == model.ID) {
var element = _source.Clients[i];
_source.Clients.RemoveAt(i);
return element.GetViewModel;
}
}
return null;
}
public ClientViewModel? GetElement(ClientSearchModel model) {
throw new NotImplementedException();
if (string.IsNullOrEmpty(model.ClientFIO) && !model.ID.HasValue) {
return null;
}
foreach (var client in _source.Clients) {
if ((!string.IsNullOrEmpty(model.ClientFIO) &&
client.ClientFIO == model.ClientFIO) ||
(model.ID.HasValue && client.ID == model.ID)) {
return client.GetViewModel;
}
}
return null;
}
public List<ClientViewModel> GetFilteredList(ClientSearchModel model) {
throw new NotImplementedException();
var result = new List<ClientViewModel>();
if (string.IsNullOrEmpty(model.ClientFIO)) {
return result;
}
foreach (var client in _source.Clients) {
if (client.ClientFIO.Contains(model.ClientFIO)) {
result.Add(client.GetViewModel);
}
}
return result;
}
public List<ClientViewModel> GetFullList() {
throw new NotImplementedException();
var result = new List<ClientViewModel>();
foreach (var client in _source.Clients) {
result.Add(client.GetViewModel);
}
return result;
}
}
}

View File

@ -0,0 +1,44 @@
using DinerContracts.BindingModels;
using DinerContracts.ViewModels;
using DinerDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DinerListImplement.Models {
public class Client : IClientModel {
public string ClientFIO { get; private set; } = string.Empty;
public string Email { get; private set; } = string.Empty;
public string Password { get; private set; } = string.Empty;
public int ID { get; private set; }
public static Client? Create(ClientBindingModel? model) {
if (model == null) {
return null;
}
return new Client() {
ClientFIO = model.ClientFIO,
Email = model.Email,
Password = model.Password,
ID = model.ID,
};
}
public void Update(ClientBindingModel? model) {
if (model == null) return;
ClientFIO = model.ClientFIO;
Email = model.Email;
Password = model.Password;
}
public ClientViewModel GetViewModel => new() {
ClientFIO = ClientFIO,
Email = Email,
Password = Password,
ID = ID
};
}
}

View File

@ -33,7 +33,7 @@ namespace DinerListImplement.Models
public FoodViewModel GetViewModel => new(){
ID = ID,
ComponentName = ComponentName,
Price = Price,
Price = Price
};
}
}

View File

@ -52,7 +52,7 @@ namespace DinerListImplement.Models
Sum = Sum,
Status = Status,
DateCreate = DateCreate,
DateImplement = DateImplement,
DateImplement = DateImplement
};
}
}

View File

@ -0,0 +1,59 @@
using DinerContracts.BindingModels;
using DinerContracts.BusinessLogicsContracts;
using DinerContracts.SearchModels;
using DinerContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
namespace DinerRestApi.Controllers {
[Route("Api/[controller]/[action]")]
[ApiController]
public class ClientController : Controller {
private readonly ILogger _logger;
private readonly IClientLogic _logic;
public ClientController(ILogger<ClientController> logger, IClientLogic logic) {
_logger = logger;
_logic = logic;
}
[HttpGet]
public ClientViewModel? Login(string login, string password) {
try {
return _logic.ReadELement(new ClientSearchModel {
Email = login,
Password = password
});
}
catch (Exception ex) {
_logger.LogError(ex, "Ошибка входа в систему");
throw;
}
}
[HttpPost]
public void Register(ClientBindingModel model) {
try {
_logic.Create(model);
}
catch (Exception ex) {
_logger.LogError(ex, "Ошибка регистрации");
throw;
}
}
[HttpPost]
public void UpdateData(ClientBindingModel model) {
try {
_logic.Update(model);
}
catch (Exception ex) {
_logger.LogError(ex, "Ошибка обновления данных");
throw;
}
}
}
}

View File

@ -0,0 +1,66 @@
using DinerContracts.BindingModels;
using DinerContracts.BusinessLogicsContacts;
using DinerContracts.SearchModels;
using DinerContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
namespace DinerRestApi.Controllers {
[Route("api/[controller]/[action]")]
[ApiController]
public class MainController : Controller {
private readonly ILogger _logger;
private readonly IOrderLogic _order;
private readonly ISnackLogic _product;
public MainController(ILogger<MainController> logger, IOrderLogic order, ISnackLogic product) {
_logger = logger;
_order = order;
_product = product;
}
[HttpGet]
public List<SnackViewModel>? GetProductLis() {
try {
return _product.ReadList(null);
}
catch (Exception ex) {
_logger.LogError(ex, "Ошибка получения списка продукции");
throw;
}
}
[HttpGet]
public SnackViewModel? GetProduct(int ProductID) {
try {
return _product.ReadElement(new SnackSearchModel { ID = ProductID });
}
catch (Exception ex) {
_logger.LogError(ex, $"Ошибка получения продуктапо ID={ProductID}");
throw;
}
}
[HttpGet]
public List<OrderViewModel>? GetOrders(int ClientID) {
try {
return _order.ReadList(new OrderSearchModel { ID = ClientID });
}
catch (Exception ex) {
_logger.LogError(ex, $"Ошибка получения списка закаозов клиента ID={ClientID}");
throw;
}
}
[HttpPost]
public void CreateOrder(OrderBindingModel model) {
try {
_order.CreateOrder(model);
}
catch (Exception ex) {
_logger.LogError(ex, "Ошибка создания заказа");
throw;
}
}
}
}

View File

@ -0,0 +1,6 @@
@DinerRestAPI_HostAddress = http://localhost:5023
GET {{DinerRestAPI_HostAddress}}/weatherforecast/
Accept: application/json
###

View File

@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="8.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DinerContracts\DinerContracts.csproj" />
<ProjectReference Include="..\DinerDataBaseImplement\DinerDataBaseImplement.csproj" />
<ProjectReference Include="..\DineryBusinessLogic\DineryBusinessLogic.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,50 @@
using DinerContracts.BusinessLogicsContacts;
using DinerContracts.BusinessLogicsContracts;
using DinerContracts.StoragesContracts;
using DinerDataBaseImplement.Implements;
using DineryBusinessLogic.BusinessLogic;
using Microsoft.OpenApi.Models;
namespace DinerRestAPI {
public class Program {
public static void Main(string[] args) {
var builder = WebApplication.CreateBuilder(args);
builder.Logging.SetMinimumLevel(LogLevel.Trace);
builder.Logging.AddLog4Net("log4net.config");
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
builder.Services.AddTransient<ISnackStorage, SnackStorage>();
builder.Services.AddTransient<IClientStorage, ClientStorage>();
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
builder.Services.AddTransient<ISnackLogic, SnackLogic>();
builder.Services.AddTransient<IClientLogic, ClientLogic>();
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(x => x.SwaggerDoc("v1", new OpenApiInfo { Title = "DinerRestApi", Version = "v1" }));
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment()) {
app.UseSwagger();
app.UseSwaggerUI(x => x.SwaggerEndpoint("/swagger/v1/swagger.json", "DinerRestApi v1"));
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();
}
}
}

View File

@ -0,0 +1,41 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:21216",
"sslPort": 44347
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5023",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7267;http://localhost:5023",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<log4net>
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<file value="C:\Users\fedot\source\repos\ISEbd-21.Fedotov.I.A.Diner\Diner\DinerView\bin\Debug\net8.0-windows7.0\DinerRestApi.log" />
<appendToFile value="true" />
<maximumFileSize value="100KB" />
<maxSizeRollBackups value="2" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %5level %logger.%method [%line] - MESSAGE: %message%newline %exception" />
</layout>
</appender>
<root>
<level value="TRACE" />
<appender-ref ref="RollingFile" />
</root>
</log4net>

View File

@ -18,14 +18,18 @@ namespace DinerFileImplement
private readonly string SnackFileName = "Snack.xml";
private readonly string ClientFileName = "Client.xml";
public List<Food> Foods { get; set; }
public List<Order> Orders { get; private set; }
public List<Snack> Snacks { get; private set; }
public List<Client> Clients { get; private set; }
private DataFileSingleton() {
Foods = LoadData(FoodFileName, "Food", x => Food.Create(x)!)!;
Snacks = LoadData(SnackFileName, "Snack", x => Snack.Create(x)!)!;
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
}
public static DataFileSingleton GetInstance() {
if (instance == null) instance = new DataFileSingleton();
@ -37,7 +41,10 @@ namespace DinerFileImplement
x => x.GetXElement);
public void SaveOrder() => SaveData(Orders, OrderFileName, "Orders",
x => x.GetXElement);
private static void SaveData<T>(List<T> data, string filename, string xmlNodeName,
public void SaveClient() => SaveData(Clients, ClientFileName, "Clients",
x => x.GetXElement);
private static void SaveData<T>(List<T> data, string filename, string xmlNodeName,
Func<T, XElement> selectFunction)
{
if (data != null) {

View File

@ -2,6 +2,7 @@
using DinerContracts.SearchModels;
using DinerContracts.StoragesContracts;
using DinerContracts.ViewModels;
using DinerFileImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
@ -10,28 +11,63 @@ using System.Threading.Tasks;
namespace DinerFileImplement.Implements {
public class ClientStorage : IClientStorage {
public ClientViewModel? Delete(ClientBindingModel model) {
throw new NotImplementedException();
}
public ClientViewModel? GetElement(ClientSearchModel model) {
throw new NotImplementedException();
}
private readonly DataFileSingleton _source;
public List<ClientViewModel> GetFilteredList(ClientSearchModel model) {
throw new NotImplementedException();
}
public List<ClientViewModel> GetFullList() {
throw new NotImplementedException();
public ClientStorage() {
_source = DataFileSingleton.GetInstance();
}
public ClientViewModel? Insert(ClientBindingModel model) {
throw new NotImplementedException();
model.ID = _source.Clients.Count > 0 ? _source.Clients.Max(x => x.ID) + 1 : 1;
var newClient = Client.Create(model);
if (newClient == null) {
return null;
}
_source.Clients.Add(newClient);
_source.SaveClient();
return newClient.GetViewModel;
}
public ClientViewModel? Update(ClientBindingModel model) {
throw new NotImplementedException();
var client = _source.Clients.FirstOrDefault(x => x.ID == model.ID);
if (client == null) {
return null;
}
client.Update(model);
_source.SaveClient();
return client.GetViewModel;
}
public ClientViewModel? Delete(ClientBindingModel model) {
var element = _source.Clients.FirstOrDefault(x => x.ID == model.ID);
if (element != null) {
_source.Clients.Remove(element);
_source.SaveClient();
return element.GetViewModel;
}
return null;
}
public ClientViewModel? GetElement(ClientSearchModel model) {
if (string.IsNullOrEmpty(model.ClientFIO) && !model.ID.HasValue) {
return null;
}
return _source.Clients.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ClientFIO) &&
x.ClientFIO == model.ClientFIO) || model.ID.HasValue &&
x.ID == model.ID)?.GetViewModel;
}
public List<ClientViewModel> GetFilteredList(ClientSearchModel model) {
if (string.IsNullOrEmpty(model.ClientFIO)) {
return new();
}
return _source.Clients.Where(x => x.ClientFIO.Contains(model.ClientFIO))
.Select(x => x.GetViewModel).ToList();
}
public List<ClientViewModel> GetFullList() {
return _source.Clients.Select(x => x.GetViewModel).ToList();
}
}
}

View File

@ -0,0 +1,62 @@
using DinerContracts.BindingModels;
using DinerContracts.ViewModels;
using DinerDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace DinerFileImplement.Models {
public class Client : IClientModel {
public string ClientFIO { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
public int ID { get; set; }
public static Client? Create(ClientBindingModel? model) {
if (model == null) {
return null;
}
return new Client() {
ClientFIO = model.ClientFIO,
Email = model.Email,
Password = model.Password,
ID = model.ID,
};
}
public static Client? Create(XElement element) {
if (element == null) {
return null;
}
return new Client() {
ClientFIO = element.Element("ClientFIO")!.Value,
Email = element.Element("Email")!.Value,
Password = element.Element("Password")!.Value,
ID = Convert.ToInt32(element.Attribute("ID")!.Value)
};
}
public void Update (ClientBindingModel? model) {
if (model == null) return;
ClientFIO = model.ClientFIO;
Email = model.Email;
Password = model.Password;
}
public ClientViewModel GetViewModel => new() {
ClientFIO = ClientFIO,
Email = Email,
Password = Password,
ID = ID
};
public XElement GetXElement => new("Client", new XAttribute("ID", ID),
new XElement("ClientFIO", ClientFIO),
new XElement("Email", Email),
new XElement("Password", Password.ToString()));
}
}

89
Diner/DinerView/FormClient.Designer.cs generated Normal file
View File

@ -0,0 +1,89 @@
namespace DinerView {
partial class FormClient {
/// <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() {
dataGridView = new DataGridView();
buttonDelete = new Button();
buttonUpdate = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.BackgroundColor = SystemColors.ButtonFace;
dataGridView.BorderStyle = BorderStyle.None;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Left;
dataGridView.Location = new Point(0, 0);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersVisible = false;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(468, 450);
dataGridView.TabIndex = 0;
//
// buttonDelete
//
buttonDelete.Location = new Point(509, 12);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(95, 35);
buttonDelete.TabIndex = 1;
buttonDelete.Text = "Удалить";
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += buttonDelete_Click;
//
// buttonUpdate
//
buttonUpdate.Location = new Point(509, 53);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(95, 35);
buttonUpdate.TabIndex = 2;
buttonUpdate.Text = "Обновить";
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += buttonUpdate_Click;
//
// FormClient
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
BackColor = SystemColors.ActiveBorder;
ClientSize = new Size(635, 450);
Controls.Add(buttonUpdate);
Controls.Add(buttonDelete);
Controls.Add(dataGridView);
Name = "FormClient";
Text = "Обновить";
Load += FormClient_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Button buttonDelete;
private Button buttonUpdate;
}
}

View File

@ -0,0 +1,69 @@
using DinerContracts.BindingModels;
using DinerContracts.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 DinerView {
public partial class FormClient : Form {
private readonly ILogger _logger;
private readonly IClientLogic _logic;
public FormClient(ILogger<FormClient> logger, IClientLogic logic) {
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void LoadData() {
try {
var list = _logic.ReadList(null);
if (list != null) {
dataGridView.DataSource = list;
dataGridView.Columns["ID"].Visible = false;
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка клиентов");
}
catch (Exception ex) {
_logger.LogError(ex, "Ошибка загрузки клиентов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FormClient_Load(object sender, EventArgs e) {
LoadData();
}
private void buttonDelete_Click(object sender, EventArgs e) {
if (dataGridView.SelectedRows.Count == 1) {
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) {
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ID"].Value);
try {
if (!_logic.Delete(new ClientBindingModel { ID = id })) {
throw new Exception("Ошиюка при удалении. Дополнительная информация в логах.");
}
_logger.LogInformation("Удаление клиента");
}
catch (Exception ex) {
_logger.LogError(ex, "Ошибка удалении клиента");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
LoadData();
}
}
}
private void buttonUpdate_Click(object sender, EventArgs e) {
LoadData();
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd: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>

View File

@ -40,7 +40,9 @@ namespace DinerView
services.AddTransient<IFoodStorage, FoodStorage>();
services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<ISnackStorage, SnackStorage>();
services.AddTransient<IClientStorage, ClientStorage>();
services.AddTransient<IClientLogic, ClientLogic>();
services.AddTransient<IFoodLogic, FoodLogic>();
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<ISnackLogic, SnackLogic>();
@ -59,6 +61,7 @@ namespace DinerView
services.AddTransient<FormSnacks>();
services.AddTransient<FormReportSnackFoods>();
services.AddTransient<FormReportOrders>();
services.AddTransient<FormClient>();
}
}
}