выводится тривью на главной форме
This commit is contained in:
parent
e5dd7184ed
commit
e507aa62a2
@ -11,9 +11,17 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Components" Version="1.0.0" />
|
||||
<PackageReference Include="FixedWinFormsLibrary1" Version="1.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ShopBusinessLogic\ShopBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\ShopDataBaseImplements\ShopDataBaseImplements.csproj" />
|
||||
<ProjectReference Include="..\UserComponentsOption19\UserComponentsOption19.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -30,11 +30,7 @@
|
||||
{
|
||||
textComponentOrderSum = new WinFormsLibrary1.TextComponent();
|
||||
textBoxName = new TextBox();
|
||||
textBoxLastName = new TextBox();
|
||||
textBoxPatronymic = new TextBox();
|
||||
labelName = new Label();
|
||||
labelLastName = new Label();
|
||||
labelPatronymic = new Label();
|
||||
labelFIO = new Label();
|
||||
labelGoodDescription = new Label();
|
||||
textBoxGoodDescription = new TextBox();
|
||||
labelOrderSum = new Label();
|
||||
@ -44,7 +40,7 @@
|
||||
//
|
||||
// textComponentOrderSum
|
||||
//
|
||||
textComponentOrderSum.Location = new Point(653, 144);
|
||||
textComponentOrderSum.Location = new Point(213, -34);
|
||||
textComponentOrderSum.Margin = new Padding(3, 4, 3, 4);
|
||||
textComponentOrderSum.Name = "textComponentOrderSum";
|
||||
textComponentOrderSum.Size = new Size(351, 199);
|
||||
@ -53,57 +49,25 @@
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(176, 19);
|
||||
textBoxName.Location = new Point(60, 9);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(272, 27);
|
||||
textBoxName.Size = new Size(346, 27);
|
||||
textBoxName.TabIndex = 1;
|
||||
//
|
||||
// textBoxLastName
|
||||
// labelFIO
|
||||
//
|
||||
textBoxLastName.Location = new Point(176, 62);
|
||||
textBoxLastName.Name = "textBoxLastName";
|
||||
textBoxLastName.Size = new Size(272, 27);
|
||||
textBoxLastName.TabIndex = 2;
|
||||
//
|
||||
// textBoxPatronymic
|
||||
//
|
||||
textBoxPatronymic.Location = new Point(176, 109);
|
||||
textBoxPatronymic.Name = "textBoxPatronymic";
|
||||
textBoxPatronymic.Size = new Size(272, 27);
|
||||
textBoxPatronymic.TabIndex = 3;
|
||||
//
|
||||
// labelName
|
||||
//
|
||||
labelName.AutoSize = true;
|
||||
labelName.Location = new Point(30, 26);
|
||||
labelName.Name = "labelName";
|
||||
labelName.Size = new Size(39, 20);
|
||||
labelName.TabIndex = 4;
|
||||
labelName.Text = "Имя";
|
||||
//
|
||||
// labelLastName
|
||||
//
|
||||
labelLastName.AutoSize = true;
|
||||
labelLastName.Location = new Point(30, 69);
|
||||
labelLastName.Name = "labelLastName";
|
||||
labelLastName.Size = new Size(73, 20);
|
||||
labelLastName.TabIndex = 5;
|
||||
labelLastName.Text = "Фамилия";
|
||||
//
|
||||
// labelPatronymic
|
||||
//
|
||||
labelPatronymic.AutoSize = true;
|
||||
labelPatronymic.Location = new Point(30, 116);
|
||||
labelPatronymic.Name = "labelPatronymic";
|
||||
labelPatronymic.Size = new Size(72, 20);
|
||||
labelPatronymic.TabIndex = 6;
|
||||
labelPatronymic.Text = "Отчество";
|
||||
labelFIO.AutoSize = true;
|
||||
labelFIO.Location = new Point(12, 9);
|
||||
labelFIO.Name = "labelFIO";
|
||||
labelFIO.Size = new Size(42, 20);
|
||||
labelFIO.TabIndex = 4;
|
||||
labelFIO.Text = "ФИО";
|
||||
//
|
||||
// labelGoodDescription
|
||||
//
|
||||
labelGoodDescription.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
labelGoodDescription.AutoSize = true;
|
||||
labelGoodDescription.Location = new Point(626, 26);
|
||||
labelGoodDescription.Location = new Point(433, 16);
|
||||
labelGoodDescription.Name = "labelGoodDescription";
|
||||
labelGoodDescription.Size = new Size(131, 20);
|
||||
labelGoodDescription.TabIndex = 7;
|
||||
@ -112,7 +76,7 @@
|
||||
// textBoxGoodDescription
|
||||
//
|
||||
textBoxGoodDescription.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
textBoxGoodDescription.Location = new Point(626, 62);
|
||||
textBoxGoodDescription.Location = new Point(585, 9);
|
||||
textBoxGoodDescription.Name = "textBoxGoodDescription";
|
||||
textBoxGoodDescription.Size = new Size(378, 27);
|
||||
textBoxGoodDescription.TabIndex = 8;
|
||||
@ -121,7 +85,7 @@
|
||||
//
|
||||
labelOrderSum.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
labelOrderSum.AutoSize = true;
|
||||
labelOrderSum.Location = new Point(653, 264);
|
||||
labelOrderSum.Location = new Point(248, 60);
|
||||
labelOrderSum.Name = "labelOrderSum";
|
||||
labelOrderSum.Size = new Size(104, 20);
|
||||
labelOrderSum.TabIndex = 9;
|
||||
@ -131,7 +95,7 @@
|
||||
//
|
||||
labelOrderStatus.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
labelOrderStatus.AutoSize = true;
|
||||
labelOrderStatus.Location = new Point(30, 215);
|
||||
labelOrderStatus.Location = new Point(12, 60);
|
||||
labelOrderStatus.Name = "labelOrderStatus";
|
||||
labelOrderStatus.Size = new Size(101, 20);
|
||||
labelOrderStatus.TabIndex = 10;
|
||||
@ -139,7 +103,7 @@
|
||||
//
|
||||
// selectComponentOrderStatus
|
||||
//
|
||||
selectComponentOrderStatus.Location = new Point(30, 256);
|
||||
selectComponentOrderStatus.Location = new Point(12, 92);
|
||||
selectComponentOrderStatus.Name = "selectComponentOrderStatus";
|
||||
selectComponentOrderStatus.SelectedValue = "";
|
||||
selectComponentOrderStatus.Size = new Size(189, 36);
|
||||
@ -155,11 +119,7 @@
|
||||
Controls.Add(labelOrderSum);
|
||||
Controls.Add(textBoxGoodDescription);
|
||||
Controls.Add(labelGoodDescription);
|
||||
Controls.Add(labelPatronymic);
|
||||
Controls.Add(labelLastName);
|
||||
Controls.Add(labelName);
|
||||
Controls.Add(textBoxPatronymic);
|
||||
Controls.Add(textBoxLastName);
|
||||
Controls.Add(labelFIO);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(textComponentOrderSum);
|
||||
Name = "FormEdit_Add";
|
||||
@ -174,7 +134,7 @@
|
||||
private TextBox textBoxName;
|
||||
private TextBox textBoxLastName;
|
||||
private TextBox textBoxPatronymic;
|
||||
private Label labelName;
|
||||
private Label labelFIO;
|
||||
private Label labelLastName;
|
||||
private Label labelPatronymic;
|
||||
private Label labelGoodDescription;
|
||||
|
@ -49,6 +49,7 @@
|
||||
userControlTreeView.SelectedIndex = -1;
|
||||
userControlTreeView.Size = new Size(1278, 428);
|
||||
userControlTreeView.TabIndex = 0;
|
||||
userControlTreeView.Load += FormMain_Load;
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
@ -65,6 +66,7 @@
|
||||
добавитьToolStripMenuItem.Name = "добавитьToolStripMenuItem";
|
||||
добавитьToolStripMenuItem.Size = new Size(90, 24);
|
||||
добавитьToolStripMenuItem.Text = "Добавить";
|
||||
добавитьToolStripMenuItem.Click += добавитьToolStripMenuItem_Click;
|
||||
//
|
||||
// редактироватьToolStripMenuItem
|
||||
//
|
||||
@ -106,6 +108,7 @@
|
||||
MainMenuStrip = menuStrip1;
|
||||
Name = "FormMain";
|
||||
Text = "Главная форма";
|
||||
Load += FormMain_Load;
|
||||
menuStrip1.ResumeLayout(false);
|
||||
menuStrip1.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
|
@ -1,10 +1,79 @@
|
||||
using ShopContracts.BindingModels;
|
||||
using ShopContracts.BusinessLogicContracts;
|
||||
using ShopDataBaseImplements.Models;
|
||||
|
||||
namespace AppShopInternetOption19
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
public FormMain()
|
||||
|
||||
private readonly IOrderLogic _orderLogic;
|
||||
private readonly IOrderStatusLogic _orderStatusLogic;
|
||||
|
||||
public FormMain(IOrderLogic orderLogic, IOrderStatusLogic orderStatusLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_orderLogic = orderLogic;
|
||||
_orderStatusLogic = orderStatusLogic;
|
||||
|
||||
OrderBindingModel order = new OrderBindingModel
|
||||
{
|
||||
FIO = "Ïóïêèí âàñèëèé çàëóïêèí",
|
||||
OrderDescription = "Description",
|
||||
OrderStatus = "íå ãîòîâ",
|
||||
OrderSumm = "20 ðóáë¸â",
|
||||
};
|
||||
_orderLogic.Create(order);
|
||||
}
|
||||
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void äîáàâèòüToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormEdit_Add));
|
||||
if (!(service is FormEdit_Add form))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var orders = _orderLogic.ReadList(null);
|
||||
if (orders == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
List<(string PropertyName, bool AlwaysCreateBranch)> hierarchy =
|
||||
[
|
||||
("OrderStatus", false),
|
||||
("OrderSumm", false),
|
||||
("Id", false),
|
||||
("FIO", false),
|
||||
];
|
||||
|
||||
userControlTreeView.SetHierarchy(hierarchy);
|
||||
userControlTreeView.SetTreeObjects(orders);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"{ex.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,35 @@
|
||||
using ShopContracts.StorageContracts;
|
||||
using ShopDataBaseImplements.Implements;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AppShopInternetOption19.Forms
|
||||
{
|
||||
public static class SingletonClass
|
||||
{
|
||||
private static IOrderStorage? _orderStorage = null;
|
||||
public static IOrderStorage OrderStorage
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_orderStorage == null)
|
||||
_orderStorage = new OrderStorage();
|
||||
return _orderStorage;
|
||||
}
|
||||
}
|
||||
|
||||
private static IOrderStatusStorage? _orderStatusStorage = null;
|
||||
public static IOrderStatusStorage OrderStatusStorage
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_orderStatusStorage == null)
|
||||
_orderStatusStorage = new OrderStatusStorage();
|
||||
return _orderStatusStorage;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,20 @@
|
||||
using AppShopInternetOption19.Forms;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ShopBusinessLogic;
|
||||
using ShopContracts.BusinessLogicContracts;
|
||||
using ShopContracts.StorageContracts;
|
||||
using ShopDataBaseImplements.Implements;
|
||||
|
||||
namespace AppShopInternetOption19
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
private static ServiceProvider? _serviceProvider;
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
@ -11,7 +24,29 @@ namespace AppShopInternetOption19
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new FormMain());
|
||||
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<IOrderStorage, OrderStorage>();
|
||||
services.AddTransient<IOrderStatusStorage, OrderStatusStorage>();
|
||||
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
services.AddTransient<IOrderStatusLogic, OrderStatusLogic>();
|
||||
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormEdit_Add>();
|
||||
services.AddTransient<FormGuide>();
|
||||
}
|
||||
}
|
||||
}
|
@ -78,14 +78,10 @@ namespace ShopBusinessLogic
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (model.Name == null || string.IsNullOrEmpty(model.Name))
|
||||
if (model.FIO == null || string.IsNullOrEmpty(model.FIO))
|
||||
{
|
||||
throw new ArgumentNullException("Что-то с именем клиента - его нет почему-то");
|
||||
}
|
||||
if (model.LastName == null || string.IsNullOrEmpty(model.LastName))
|
||||
{
|
||||
throw new ArgumentNullException("что-то с фамилией клиента - ее нет почему-то");
|
||||
}
|
||||
if (model.OrderStatus == null || string.IsNullOrEmpty(model.OrderStatus))
|
||||
{
|
||||
throw new ArgumentNullException("что-то со статусом заказа - его нет почему-то");
|
||||
|
@ -5,9 +5,7 @@ namespace ShopContracts.BindingModels
|
||||
public class OrderBindingModel : IOrderModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
public string Patronymic { get; set; } = string.Empty;
|
||||
public string FIO { get; set; } = string.Empty;
|
||||
public string OrderDescription { get; set; } = string.Empty;
|
||||
public string OrderStatus { get; set; } = string.Empty;
|
||||
public string? OrderSumm { get; set; } = "Оплачено скидками";
|
||||
|
@ -5,9 +5,7 @@ namespace ShopContracts.ViewModels
|
||||
public class OrderViewModel : IOrderModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
public string Patronymic { get; set; } = string.Empty;
|
||||
public string FIO { get; set; } = string.Empty;
|
||||
public string? OrderDescription { get; set; } = "Оплачено скидками";
|
||||
public string OrderStatus { get; set; } = string.Empty;
|
||||
public string? OrderSumm { get; set; } = string.Empty;
|
||||
|
74
UserComponentsOption19/ShopDataBaseImplements/Migrations/20241119173303_MigrationInit.Designer.cs
generated
Normal file
74
UserComponentsOption19/ShopDataBaseImplements/Migrations/20241119173303_MigrationInit.Designer.cs
generated
Normal file
@ -0,0 +1,74 @@
|
||||
// <auto-generated />
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using ShopDataBaseImplements;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ShopDataBaseImplements.Migrations
|
||||
{
|
||||
[DbContext(typeof(DataBase))]
|
||||
[Migration("20241119173303_MigrationInit")]
|
||||
partial class MigrationInit
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "9.0.0")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("ShopDataBaseImplements.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("FIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("OrderDescription")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("OrderStatus")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("OrderSumm")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ShopDataBaseImplements.Models.OrderStatus", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("OrderStatuses");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ShopDataBaseImplements.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class MigrationInit : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Orders",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
FIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
OrderDescription = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
OrderStatus = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
OrderSumm = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "OrderStatuses",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_OrderStatuses", x => x.Id);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Orders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "OrderStatuses");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
// <auto-generated />
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using ShopDataBaseImplements;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ShopDataBaseImplements.Migrations
|
||||
{
|
||||
[DbContext(typeof(DataBase))]
|
||||
partial class DataBaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "9.0.0")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("ShopDataBaseImplements.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("FIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("OrderDescription")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("OrderStatus")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("OrderSumm")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ShopDataBaseImplements.Models.OrderStatus", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("OrderStatuses");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -10,13 +10,7 @@ namespace ShopDataBaseImplements.Models
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string Patronymic { get; set; } = string.Empty;
|
||||
public string FIO { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string OrderDescription { get; set; } = string.Empty;
|
||||
@ -24,41 +18,35 @@ namespace ShopDataBaseImplements.Models
|
||||
[Required]
|
||||
public string OrderStatus { get; set; } = string.Empty;
|
||||
|
||||
public string? OrderSumm { get; set; } = "оплачено скидками";
|
||||
public string? OrderSumm { get; set; }
|
||||
|
||||
public static Order? Create(OrderBindingModel model)
|
||||
{
|
||||
return new Order
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
LastName = model.LastName,
|
||||
FIO = model.FIO,
|
||||
OrderDescription = model.OrderDescription,
|
||||
OrderStatus = model.OrderStatus,
|
||||
Patronymic = model.Patronymic,
|
||||
OrderSumm = model.OrderSumm,
|
||||
OrderSumm = model.OrderSumm ?? "Оплачено скидками",
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(OrderBindingModel model)
|
||||
{
|
||||
Name = model.Name;
|
||||
LastName = model.LastName;
|
||||
Patronymic = model.Patronymic;
|
||||
FIO = model.FIO;
|
||||
OrderDescription = model.OrderDescription;
|
||||
OrderStatus = model.OrderStatus;
|
||||
OrderSumm = model.OrderSumm;
|
||||
OrderSumm = model.OrderSumm ?? "Оплачено скидками";
|
||||
}
|
||||
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
LastName = LastName,
|
||||
Patronymic = Patronymic,
|
||||
FIO = FIO,
|
||||
OrderDescription = OrderDescription,
|
||||
OrderStatus = OrderStatus,
|
||||
OrderSumm = OrderSumm,
|
||||
OrderSumm = OrderSumm ?? "Оплачено скидками",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,7 @@
|
||||
public interface IOrderModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string LastName { get; set; }
|
||||
public string Patronymic { get; set; }
|
||||
public string FIO { get; set; }
|
||||
public string OrderDescription { get; set; }
|
||||
public string OrderStatus { get; set; }
|
||||
public string OrderSumm { get; set; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user