Переименована обратно случайная переменная

This commit is contained in:
Данияр Аглиуллов 2023-03-04 22:53:49 +04:00
parent 04c455cd7e
commit 6b9f987f44
10 changed files with 1127 additions and 1128 deletions

View File

@ -18,7 +18,7 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
} }
public List<ComponentViewModel>? ReadList(ComponentSearchModel? model) public List<ComponentViewModel>? ReadList(ComponentSearchModel? model)
{ {
_logger.LogInformation("ReadList. PastryName:{PastryName}.Id:{ Id} ", _logger.LogInformation("ReadList. ComponentName:{ComponentName}.Id:{ Id} ",
model?.ComponentName, model?.Id); model?.ComponentName, model?.Id);
var list = (model == null) ? _componentStorage.GetFullList() : var list = (model == null) ? _componentStorage.GetFullList() :
_componentStorage.GetFilteredList(model); _componentStorage.GetFilteredList(model);
@ -36,7 +36,7 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
{ {
throw new ArgumentNullException(nameof(model)); throw new ArgumentNullException(nameof(model));
} }
_logger.LogInformation("ReadElement. PastryName:{PastryName}.Id:{ Id}", _logger.LogInformation("ReadElement. ComponentName:{ComponentName}.Id:{ Id}",
model.ComponentName, model.Id); model.ComponentName, model.Id);
var element = _componentStorage.GetElement(model); var element = _componentStorage.GetElement(model);
if (element == null) if (element == null)
@ -78,8 +78,7 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
} }
return true; return true;
} }
private void CheckModel(ComponentBindingModel model, bool withParams = private void CheckModel(ComponentBindingModel model, bool withParams = true)
true)
{ {
if (model == null) if (model == null)
{ {
@ -98,7 +97,7 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
{ {
throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost)); throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost));
} }
_logger.LogInformation("Components. PastryName:{PastryName}.Cost:{ Cost}. Id: { Id}", _logger.LogInformation("Component. ComponentName:{ComponentName}.Cost:{ Cost}. Id: { Id}",
model.ComponentName, model.Cost, model.Id); model.ComponentName, model.Cost, model.Id);
var element = _componentStorage.GetElement(new ComponentSearchModel var element = _componentStorage.GetElement(new ComponentSearchModel
{ {

View File

@ -33,7 +33,7 @@ namespace ConfectioneryFileImplement.Models
return new Component() return new Component()
{ {
Id = Convert.ToInt32(element.Attribute("Id")!.Value), Id = Convert.ToInt32(element.Attribute("Id")!.Value),
ComponentName = element.Element("PastryName")!.Value, ComponentName = element.Element("ComponentName")!.Value,
Cost = Convert.ToDouble(element.Element("Cost")!.Value) Cost = Convert.ToDouble(element.Element("Cost")!.Value)
}; };
} }
@ -52,9 +52,9 @@ namespace ConfectioneryFileImplement.Models
ComponentName = ComponentName, ComponentName = ComponentName,
Cost = Cost Cost = Cost
}; };
public XElement GetXElement => new("Components", public XElement GetXElement => new("Component",
new XAttribute("Id", Id), new XAttribute("Id", Id),
new XElement("PastryName", ComponentName), new XElement("ComponentName", ComponentName),
new XElement("Cost", Cost.ToString())); new XElement("Cost", Cost.ToString()));
} }
} }

View File

@ -6,7 +6,7 @@ namespace ConfectioneryFileImplement
public class DataFileSingleton public class DataFileSingleton
{ {
private static DataFileSingleton? instance; private static DataFileSingleton? instance;
private readonly string ComponentFileName = "Components.xml"; private readonly string ComponentFileName = "Component.xml";
private readonly string OrderFileName = "Order.xml"; private readonly string OrderFileName = "Order.xml";
private readonly string PastryFileName = "Pastry.xml"; private readonly string PastryFileName = "Pastry.xml";
public List<Component> Components { get; private set; } public List<Component> Components { get; private set; }
@ -22,12 +22,12 @@ namespace ConfectioneryFileImplement
return instance; return instance;
} }
public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement); public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement);
public void SavePastries() => SaveData(Pastries, PastryFileName, "Components", x => x.GetXElement); public void SavePastries() => SaveData(Pastries, PastryFileName, "Pastries", x => x.GetXElement);
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement); public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
private DataFileSingleton() private DataFileSingleton()
{ {
Components = LoadData(ComponentFileName, "Components", x => Component.Create(x)!)!; Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
Pastries = LoadData(PastryFileName, "Pastry", x => Pastry.Create(x)!)!; Pastries = LoadData(PastryFileName, "Pastry", x => Pastry.Create(x)!)!;
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!; Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
} }

View File

@ -144,12 +144,12 @@
this.id.Name = "id"; this.id.Name = "id";
this.id.Visible = false; this.id.Visible = false;
// //
// Components // Component
// //
this.Component.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.Component.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.Component.FillWeight = 1000F; this.Component.FillWeight = 1000F;
this.Component.HeaderText = "Компонент"; this.Component.HeaderText = "Компонент";
this.Component.Name = "Components"; this.Component.Name = "Component";
// //
// Count // Count
// //

View File

@ -82,7 +82,7 @@ namespace ConfectioneryView
{ {
return; return;
} }
_logger.LogInformation("Добавление нового компонента: { PastryName}- { Count}", _logger.LogInformation("Добавление нового компонента: { ComponentName}- { Count}",
form.ComponentModel.ComponentName, form.Count); form.ComponentModel.ComponentName, form.Count);
if (_pastryComponents.ContainsKey(form.Id)) if (_pastryComponents.ContainsKey(form.Id))
{ {
@ -114,7 +114,7 @@ namespace ConfectioneryView
{ {
return; return;
} }
_logger.LogInformation("Изменение компонента: { PastryName} - { Count} ", _logger.LogInformation("Изменение компонента: { ComponentName} - { Count} ",
form.ComponentModel.ComponentName, form.Count); form.ComponentModel.ComponentName, form.Count);
_pastryComponents[id] = (form.ComponentModel, form.Count); _pastryComponents[id] = (form.ComponentModel, form.Count);
LoadData(); LoadData();
@ -131,7 +131,7 @@ namespace ConfectioneryView
{ {
try try
{ {
_logger.LogInformation("Удаление компонента: { PastryName}- { Count}", _logger.LogInformation("Удаление компонента: { ComponentName}- { Count}",
dataGridView.SelectedRows[0].Cells[1].Value); dataGridView.SelectedRows[0].Cells[1].Value);
_pastryComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); _pastryComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
} }

View File

@ -47,7 +47,7 @@ namespace ConfectioneryView
_list = logic.ReadList(null); _list = logic.ReadList(null);
if (_list != null) if (_list != null)
{ {
comboBoxComponent.DisplayMember = "PastryName"; comboBoxComponent.DisplayMember = "ComponentName";
comboBoxComponent.ValueMember = "Id"; comboBoxComponent.ValueMember = "Id";
comboBoxComponent.DataSource = _list; comboBoxComponent.DataSource = _list;
comboBoxComponent.SelectedItem = null; comboBoxComponent.SelectedItem = null;

View File

@ -25,7 +25,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Components", b => modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Component", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@ -33,7 +33,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("PastryName") b.Property<string>("ComponentName")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
@ -95,7 +95,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.ToTable("Components"); b.ToTable("Pastries");
}); });
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.PastryComponent", b => modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.PastryComponent", b =>
@ -137,7 +137,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.PastryComponent", b => modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.PastryComponent", b =>
{ {
b.HasOne("ConfectioneryDatabaseImplement.Models.Components", "Components") b.HasOne("ConfectioneryDatabaseImplement.Models.Component", "Component")
.WithMany("PastryComponents") .WithMany("PastryComponents")
.HasForeignKey("ComponentId") .HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
@ -149,12 +149,12 @@ namespace ConfectioneryDatabaseImplement.Migrations
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("Components"); b.Navigation("Component");
b.Navigation("Pastry"); b.Navigation("Pastry");
}); });
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Components", b => modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Component", b =>
{ {
b.Navigation("PastryComponents"); b.Navigation("PastryComponents");
}); });

View File

@ -26,7 +26,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Components", name: "Pastries",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "int", nullable: false) Id = table.Column<int>(type: "int", nullable: false)
@ -58,7 +58,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
table.ForeignKey( table.ForeignKey(
name: "FK_Orders_Pastries_PastryId", name: "FK_Orders_Pastries_PastryId",
column: x => x.PastryId, column: x => x.PastryId,
principalTable: "Components", principalTable: "Pastries",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
}); });
@ -85,7 +85,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
table.ForeignKey( table.ForeignKey(
name: "FK_PastryComponents_Pastries_PastryId", name: "FK_PastryComponents_Pastries_PastryId",
column: x => x.PastryId, column: x => x.PastryId,
principalTable: "Components", principalTable: "Pastries",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
}); });
@ -119,7 +119,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
name: "Components"); name: "Components");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Components"); name: "Pastries");
} }
} }
} }

View File

@ -22,7 +22,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Components", b => modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Component", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@ -30,7 +30,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("PastryName") b.Property<string>("ComponentName")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
@ -92,7 +92,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.ToTable("Components"); b.ToTable("Pastries");
}); });
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.PastryComponent", b => modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.PastryComponent", b =>
@ -134,7 +134,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.PastryComponent", b => modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.PastryComponent", b =>
{ {
b.HasOne("ConfectioneryDatabaseImplement.Models.Components", "Components") b.HasOne("ConfectioneryDatabaseImplement.Models.Component", "Component")
.WithMany("PastryComponents") .WithMany("PastryComponents")
.HasForeignKey("ComponentId") .HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
@ -146,12 +146,12 @@ namespace ConfectioneryDatabaseImplement.Migrations
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("Components"); b.Navigation("Component");
b.Navigation("Pastry"); b.Navigation("Pastry");
}); });
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Components", b => modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Component", b =>
{ {
b.Navigation("PastryComponents"); b.Navigation("PastryComponents");
}); });