Add_Client in BD

This commit is contained in:
Игорь Гордеев 2024-05-01 13:12:40 +04:00
parent 64b7363a86
commit f8b0a536ea
21 changed files with 380 additions and 14 deletions

View File

@ -31,6 +31,7 @@ namespace SushiBarView
{ {
dataGridView.DataSource = list; dataGridView.DataSource = list;
dataGridView.Columns["SushiId"].Visible = false; dataGridView.Columns["SushiId"].Visible = false;
} }
_logger.LogInformation("Загрузка заказов"); _logger.LogInformation("Загрузка заказов");
} }

View File

@ -7,6 +7,7 @@ using SushiBarBusinessLogic.OfficePackage;
using SushiBarContracts.BusinessLogicsContracts; using SushiBarContracts.BusinessLogicsContracts;
using SushiBarContracts.StoragesContracts; using SushiBarContracts.StoragesContracts;
using SushiBarDatabaseImplement.Implements; using SushiBarDatabaseImplement.Implements;
using SushiBarBusinessLogic;
namespace SushiBarView namespace SushiBarView
{ {
@ -41,11 +42,15 @@ namespace SushiBarView
services.AddTransient<IIngredientStorage, IngredientStorage>(); services.AddTransient<IIngredientStorage, IngredientStorage>();
services.AddTransient<IOrderStorage, OrderStorage>(); services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<ISushiStorage, SushiStorage>(); services.AddTransient<ISushiStorage, SushiStorage>();
services.AddTransient<IClientStorage, ClientStorage>();
services.AddTransient<IIngredientLogic, IngredientLogic>(); services.AddTransient<IIngredientLogic, IngredientLogic>();
services.AddTransient<IOrderLogic, OrderLogic>(); services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<ISushiLogic, SushiLogic>(); services.AddTransient<ISushiLogic, SushiLogic>();
services.AddTransient<IClientLogic, ClientLogic>();
services.AddTransient<IReportLogic, ReportLogic>(); services.AddTransient<IReportLogic, ReportLogic>();
services.AddTransient<FormMain>(); services.AddTransient<FormMain>();
services.AddTransient<FormIngredient>(); services.AddTransient<FormIngredient>();
services.AddTransient<FormIngredients>(); services.AddTransient<FormIngredients>();
@ -53,6 +58,7 @@ namespace SushiBarView
services.AddTransient<FormSushi>(); services.AddTransient<FormSushi>();
services.AddTransient<FormSushiIngredients>(); services.AddTransient<FormSushiIngredients>();
services.AddTransient<FormListSushi>(); services.AddTransient<FormListSushi>();
services.AddTransient<FormClients>();
services.AddTransient<FormReportSushiIngredients>(); services.AddTransient<FormReportSushiIngredients>();
services.AddTransient<FormReportOrders>(); services.AddTransient<FormReportOrders>();

View File

@ -11,8 +11,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.5.0" /> <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.5.0" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="4.5.0" /> <PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="4.5.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.3" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.3" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.3"> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.3">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

View File

@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using SushiBarClientApp.Models; using SushiBarClientApp.Models;
using SushiBarContracts.BindingModel; using SushiBarContracts.BindingModel;
using SushiBarContracts.BindingModels;
using SushiBarContracts.ViewModels; using SushiBarContracts.ViewModels;
using System.Diagnostics; using System.Diagnostics;

View File

@ -9,7 +9,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.26" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.4" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.9.2" /> <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.9.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup> </ItemGroup>

View File

@ -12,5 +12,8 @@ namespace SushiBarContracts.BindingModels
public DateTime DateCreate { get; set; } = DateTime.Now; public DateTime DateCreate { get; set; } = DateTime.Now;
public DateTime? DateImplement { get; set; } public DateTime? DateImplement { get; set; }
public int Id { get; set; } public int Id { get; set; }
public int ClientId { get; set; }
public string ClientFIO { get; set; } = string.Empty;
} }
} }

View File

@ -6,6 +6,7 @@ namespace SushiBarContracts.SearchModels
public int? Id { get; set; } public int? Id { get; set; }
public DateTime? DateTo { get; set; } public DateTime? DateTo { get; set; }
public DateTime? DateFrom { get; set; } public DateTime? DateFrom { get; set; }
public int ClientId { get; set; }
} }
} }

View File

@ -8,9 +8,13 @@ namespace SushiBarContracts.ViewModels
{ {
[DisplayName("Номер")] [DisplayName("Номер")]
public int Id { get; set; } public int Id { get; set; }
public int ClientId { get; set; }
[DisplayName("Имя клиента")]
public string ClientFIO { get; set; } = string.Empty;
public int SushiId { get; set; } public int SushiId { get; set; }
[DisplayName("Суши")] [DisplayName("Суши")]
public string SushiName { get; set; } = string.Empty; public string SushiName { get; set; } = string.Empty;
[DisplayName("Количество")] [DisplayName("Количество")]
public int Count { get; set; } public int Count { get; set; }
[DisplayName("Сумма")] [DisplayName("Сумма")]

View File

@ -5,6 +5,7 @@ namespace SushiBarDataModels.Models
public interface IOrderModel : IId public interface IOrderModel : IId
{ {
int SushiId { get; } int SushiId { get; }
int ClientId { get; }
int Count { get; } int Count { get; }
double Sum { get; } double Sum { get; }
OrderStatus Status { get; } OrderStatus Status { get; }

View File

@ -32,7 +32,7 @@ namespace SushiBarDatabaseImplement.Implements
} }
using var context = new SushiBarDatabase(); using var context = new SushiBarDatabase();
return context.Orders return context.Orders
.Include(x => x.Sushi) .Include(x => x.Sushi).Include(x => x.Client)
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id) .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
?.GetViewModel; ?.GetViewModel;
} }
@ -48,6 +48,7 @@ namespace SushiBarDatabaseImplement.Implements
{ {
return context.Orders return context.Orders
.Include(x => x.Sushi) .Include(x => x.Sushi)
.Include(x => x.Client)
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo) .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
@ -74,6 +75,7 @@ namespace SushiBarDatabaseImplement.Implements
context.SaveChanges(); context.SaveChanges();
return context.Orders return context.Orders
.Include(x => x.Sushi) .Include(x => x.Sushi)
.Include(x => x.Client)
.FirstOrDefault(x => x.Id == newOrder.Id) .FirstOrDefault(x => x.Id == newOrder.Id)
?.GetViewModel; ?.GetViewModel;
} }
@ -83,6 +85,7 @@ namespace SushiBarDatabaseImplement.Implements
using var context = new SushiBarDatabase(); using var context = new SushiBarDatabase();
var order = context.Orders var order = context.Orders
.Include(x => x.Sushi) .Include(x => x.Sushi)
.Include(x => x.Client)
.FirstOrDefault(x => x.Id == model.Id); .FirstOrDefault(x => x.Id == model.Id);
if (order == null) if (order == null)
{ {

View File

@ -0,0 +1,214 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using SushiBarDatabaseImplement;
#nullable disable
namespace SushiBarDatabaseImplement.Migrations
{
[DbContext(typeof(SushiBarDatabase))]
[Migration("20240501085423_Add_client")]
partial class Add_client
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.4")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("SushiBarDatabaseImplement.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("SushiBarDatabaseImplement.Models.Ingredient", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<double>("Cost")
.HasColumnType("float");
b.Property<string>("IngredientName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Ingredients");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<double>("Sum")
.HasColumnType("float");
b.Property<int>("SushiId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ClientId");
b.HasIndex("SushiId");
b.ToTable("Orders");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Sushi", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<double>("Price")
.HasColumnType("float");
b.Property<string>("SushiName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("ListSushi");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.SushiIngredient", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("IngredientId")
.HasColumnType("int");
b.Property<int>("SushiId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("IngredientId");
b.HasIndex("SushiId");
b.ToTable("SushiIngredients");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Order", b =>
{
b.HasOne("SushiBarDatabaseImplement.Models.Client", "Client")
.WithMany("Orders")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SushiBarDatabaseImplement.Models.Sushi", "Sushi")
.WithMany("Orders")
.HasForeignKey("SushiId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
b.Navigation("Sushi");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.SushiIngredient", b =>
{
b.HasOne("SushiBarDatabaseImplement.Models.Ingredient", "Ingredient")
.WithMany("SushiIngredients")
.HasForeignKey("IngredientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SushiBarDatabaseImplement.Models.Sushi", "Sushi")
.WithMany("Ingredients")
.HasForeignKey("SushiId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ingredient");
b.Navigation("Sushi");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Client", b =>
{
b.Navigation("Orders");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Ingredient", b =>
{
b.Navigation("SushiIngredients");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Sushi", b =>
{
b.Navigation("Ingredients");
b.Navigation("Orders");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,68 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SushiBarDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class Add_client : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "ClientId",
table: "Orders",
type: "int",
nullable: false,
defaultValue: 0);
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.CreateIndex(
name: "IX_Orders_ClientId",
table: "Orders",
column: "ClientId");
migrationBuilder.AddForeignKey(
name: "FK_Orders_Clients_ClientId",
table: "Orders",
column: "ClientId",
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Orders_Clients_ClientId",
table: "Orders");
migrationBuilder.DropTable(
name: "Clients");
migrationBuilder.DropIndex(
name: "IX_Orders_ClientId",
table: "Orders");
migrationBuilder.DropColumn(
name: "ClientId",
table: "Orders");
}
}
}

View File

@ -17,11 +17,36 @@ namespace SushiBarDatabaseImplement.Migrations
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "8.0.3") .HasAnnotation("ProductVersion", "8.0.4")
.HasAnnotation("Relational:MaxIdentifierLength", 128); .HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("SushiBarDatabaseImplement.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("SushiBarDatabaseImplement.Models.Ingredient", b => modelBuilder.Entity("SushiBarDatabaseImplement.Models.Ingredient", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@ -50,6 +75,9 @@ namespace SushiBarDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<int>("Count") b.Property<int>("Count")
.HasColumnType("int"); .HasColumnType("int");
@ -70,6 +98,8 @@ namespace SushiBarDatabaseImplement.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("ClientId");
b.HasIndex("SushiId"); b.HasIndex("SushiId");
b.ToTable("Orders"); b.ToTable("Orders");
@ -123,12 +153,20 @@ namespace SushiBarDatabaseImplement.Migrations
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Order", b => modelBuilder.Entity("SushiBarDatabaseImplement.Models.Order", b =>
{ {
b.HasOne("SushiBarDatabaseImplement.Models.Client", "Client")
.WithMany("Orders")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SushiBarDatabaseImplement.Models.Sushi", "Sushi") b.HasOne("SushiBarDatabaseImplement.Models.Sushi", "Sushi")
.WithMany("Orders") .WithMany("Orders")
.HasForeignKey("SushiId") .HasForeignKey("SushiId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("Client");
b.Navigation("Sushi"); b.Navigation("Sushi");
}); });
@ -151,6 +189,11 @@ namespace SushiBarDatabaseImplement.Migrations
b.Navigation("Sushi"); b.Navigation("Sushi");
}); });
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Client", b =>
{
b.Navigation("Orders");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Ingredient", b => modelBuilder.Entity("SushiBarDatabaseImplement.Models.Ingredient", b =>
{ {
b.Navigation("SushiIngredients"); b.Navigation("SushiIngredients");

View File

@ -19,7 +19,7 @@ namespace SushiBarDatabaseImplement.Models
[Required] [Required]
public string Password { get; private set; } = string.Empty; public string Password { get; private set; } = string.Empty;
[ForeignKey("ID")] [ForeignKey("ClientId")]
public virtual List<Order> Orders { get; set; } = new(); public virtual List<Order> Orders { get; set; } = new();
public static Client? Create(ClientBindingModel? model) public static Client? Create(ClientBindingModel? model)

View File

@ -3,6 +3,7 @@ using SushiBarContracts.ViewModels;
using SushiBarDataModels.Enums; using SushiBarDataModels.Enums;
using SushiBarDataModels.Models; using SushiBarDataModels.Models;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace SushiBarDatabaseImplement.Models namespace SushiBarDatabaseImplement.Models
{ {
@ -13,6 +14,8 @@ namespace SushiBarDatabaseImplement.Models
[Required] [Required]
public int Count { get; set; } public int Count { get; set; }
[Required] [Required]
public int ClientId { get; set; }
[Required]
public double Sum { get; set; } public double Sum { get; set; }
[Required] [Required]
public OrderStatus Status { get; set; } public OrderStatus Status { get; set; }
@ -20,7 +23,8 @@ namespace SushiBarDatabaseImplement.Models
public DateTime DateCreate { get; set; } public DateTime DateCreate { get; set; }
public DateTime? DateImplement { get; set; } public DateTime? DateImplement { get; set; }
public int Id { get; set; } public int Id { get; set; }
public Sushi Sushi { get; set; } public virtual Client? Client { get; set; }
public Sushi? Sushi { get; set; }
public static Order? Create(OrderBindingModel? model) public static Order? Create(OrderBindingModel? model)
{ {
if (model == null) if (model == null)
@ -36,6 +40,7 @@ namespace SushiBarDatabaseImplement.Models
Status = model.Status, Status = model.Status,
DateCreate = model.DateCreate, DateCreate = model.DateCreate,
DateImplement = model.DateImplement, DateImplement = model.DateImplement,
ClientId = model.ClientId
}; };
} }
@ -59,6 +64,8 @@ namespace SushiBarDatabaseImplement.Models
Id = Id, Id = Id,
Status = Status, Status = Status,
SushiName = Sushi.SushiName, SushiName = Sushi.SushiName,
ClientId = ClientId,
ClientFIO = Client.ClientFIO
}; };
} }
} }

View File

@ -19,7 +19,6 @@ namespace SushiBarDatabaseImplement
public virtual DbSet<Sushi> ListSushi { set; get; } public virtual DbSet<Sushi> ListSushi { set; get; }
public virtual DbSet<SushiIngredient> SushiIngredients { set; get; } public virtual DbSet<SushiIngredient> SushiIngredients { set; get; }
public virtual DbSet<Order> Orders { set; get; } public virtual DbSet<Order> Orders { set; get; }
public virtual DbSet<Client> Clients { set; get; } public virtual DbSet<Client> Clients { set; get; }
} }

View File

@ -7,9 +7,9 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.3" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.3" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.3"> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.4">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

View File

@ -10,6 +10,7 @@ namespace SushiBarFileImplement.Models
{ {
public int Id { get; private set; } public int Id { get; private set; }
public int SushiId { get; private set; } public int SushiId { get; private set; }
public int ClientId { get; private set; }
public int Count { get; private set; } public int Count { get; private set; }
public double Sum { get; private set; } public double Sum { get; private set; }
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен; public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
@ -25,6 +26,7 @@ namespace SushiBarFileImplement.Models
{ {
Id = model.Id, Id = model.Id,
SushiId = model.SushiId, SushiId = model.SushiId,
ClientId = model.ClientId,
Count = model.Count, Count = model.Count,
Sum = model.Sum, Sum = model.Sum,
Status = model.Status, Status = model.Status,
@ -43,6 +45,7 @@ namespace SushiBarFileImplement.Models
{ {
Id = Convert.ToInt32(element.Attribute("Id")!.Value), Id = Convert.ToInt32(element.Attribute("Id")!.Value),
SushiId = Convert.ToInt32(element.Element("SushiId")!.Value), SushiId = Convert.ToInt32(element.Element("SushiId")!.Value),
ClientId = Convert.ToInt32(element.Element("ClientId")!.Value),
Sum = Convert.ToDouble(element.Element("Sum")!.Value), Sum = Convert.ToDouble(element.Element("Sum")!.Value),
Count = Convert.ToInt32(element.Element("Count")!.Value), Count = Convert.ToInt32(element.Element("Count")!.Value),
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value), Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
@ -70,11 +73,13 @@ namespace SushiBarFileImplement.Models
DateImplement = DateImplement, DateImplement = DateImplement,
Id = Id, Id = Id,
Status = Status, Status = Status,
ClientId = ClientId,
}; };
public XElement GetXElement => new("Order", public XElement GetXElement => new("Order",
new XAttribute("Id", Id), new XAttribute("Id", Id),
new XElement("SushiId", SushiId), new XElement("SushiId", SushiId),
new XElement("ClientId", ClientId.ToString()),
new XElement("Count", Count.ToString()), new XElement("Count", Count.ToString()),
new XElement("Sum", Sum.ToString()), new XElement("Sum", Sum.ToString()),
new XElement("Status", Status.ToString()), new XElement("Status", Status.ToString()),

View File

@ -9,6 +9,7 @@ namespace SushiBarListImplement.Models
{ {
public int Id { get; private set; } public int Id { get; private set; }
public int SushiId { get; private set; } public int SushiId { get; private set; }
public int ClientId { get; private set; }
public int Count { get; private set; } public int Count { get; private set; }
public double Sum { get; private set; } public double Sum { get; private set; }
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен; public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
@ -29,6 +30,7 @@ namespace SushiBarListImplement.Models
DateCreate = model.DateCreate, DateCreate = model.DateCreate,
DateImplement = model.DateImplement, DateImplement = model.DateImplement,
Id = model.Id, Id = model.Id,
ClientId = model.ClientId,
}; };
} }
public void Update(OrderBindingModel? model) public void Update(OrderBindingModel? model)
@ -37,18 +39,24 @@ namespace SushiBarListImplement.Models
{ {
return; return;
} }
SushiId = model.SushiId;
Count = model.Count;
Sum = model.Sum;
Status = model.Status; Status = model.Status;
DateCreate = model.DateCreate;
DateImplement = model.DateImplement; DateImplement = model.DateImplement;
ClientId = model.ClientId;
} }
public OrderViewModel GetViewModel => new() public OrderViewModel GetViewModel => new()
{ {
Id = Id,
SushiId = SushiId, SushiId = SushiId,
Count = Count, Count = Count,
Sum = Sum, Sum = Sum,
Status = Status,
DateCreate = DateCreate, DateCreate = DateCreate,
DateImplement = DateImplement, DateImplement = DateImplement,
Id = Id, ClientId = ClientId,
Status = Status,
}; };
} }
} }

View File

@ -1,8 +1,10 @@
using DocumentFormat.OpenXml.Office2010.Excel; using DocumentFormat.OpenXml.Office2010.Excel;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using SushiBarContracts.BindingModel; using SushiBarContracts.BindingModel;
using SushiBarContracts.BindingModels;
using SushiBarContracts.BusinessLogicsContracts; using SushiBarContracts.BusinessLogicsContracts;
using SushiBarContracts.SearchModel; using SushiBarContracts.SearchModel;
using SushiBarContracts.SearchModels;
using SushiBarContracts.ViewModels; using SushiBarContracts.ViewModels;
namespace SushiBarRestApi.Controllers namespace SushiBarRestApi.Controllers

View File

@ -2,8 +2,8 @@ using SushiBarContracts.BusinessLogicsContracts;
using SushiBarContracts.StoragesContracts; using SushiBarContracts.StoragesContracts;
using SushiBarDatabaseImplement.Implements; using SushiBarDatabaseImplement.Implements;
using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models;
using SushiBarBusinessLogic.BusinessLogic;
using SushiBarBusinessLogic; using SushiBarBusinessLogic;
using SushiBarBusinessLogic.BusinessLogics;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
builder.Logging.SetMinimumLevel(LogLevel.Trace); builder.Logging.SetMinimumLevel(LogLevel.Trace);