fix
This commit is contained in:
commit
4083f3a939
@ -18,7 +18,7 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
|
||||
}
|
||||
public List<ComponentViewModel>? ReadList(ComponentSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. PastryName:{PastryName}.Id:{ Id} ",
|
||||
_logger.LogInformation("ReadList. ComponentName:{ComponentName}.Id:{ Id} ",
|
||||
model?.ComponentName, model?.Id);
|
||||
var list = (model == null) ? _componentStorage.GetFullList() :
|
||||
_componentStorage.GetFilteredList(model);
|
||||
@ -36,7 +36,7 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. PastryName:{PastryName}.Id:{ Id}",
|
||||
_logger.LogInformation("ReadElement. ComponentName:{ComponentName}.Id:{ Id}",
|
||||
model.ComponentName, model.Id);
|
||||
var element = _componentStorage.GetElement(model);
|
||||
if (element == null)
|
||||
@ -78,8 +78,7 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(ComponentBindingModel model, bool withParams =
|
||||
true)
|
||||
private void CheckModel(ComponentBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -98,7 +97,7 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
|
||||
{
|
||||
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);
|
||||
var element = _componentStorage.GetElement(new ComponentSearchModel
|
||||
{
|
||||
|
@ -33,7 +33,7 @@ namespace ConfectioneryFileImplement.Models
|
||||
return new Component()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
ComponentName = element.Element("PastryName")!.Value,
|
||||
ComponentName = element.Element("ComponentName")!.Value,
|
||||
Cost = Convert.ToDouble(element.Element("Cost")!.Value)
|
||||
};
|
||||
}
|
||||
@ -52,9 +52,9 @@ namespace ConfectioneryFileImplement.Models
|
||||
ComponentName = ComponentName,
|
||||
Cost = Cost
|
||||
};
|
||||
public XElement GetXElement => new("Components",
|
||||
public XElement GetXElement => new("Component",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("PastryName", ComponentName),
|
||||
new XElement("ComponentName", ComponentName),
|
||||
new XElement("Cost", Cost.ToString()));
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ namespace ConfectioneryFileImplement
|
||||
public class DataFileSingleton
|
||||
{
|
||||
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 PastryFileName = "Pastry.xml";
|
||||
private readonly string ShopFileName = "Shop.xml";
|
||||
@ -24,13 +24,13 @@ namespace ConfectioneryFileImplement
|
||||
return instance;
|
||||
}
|
||||
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 SaveShops() => SaveData(Shops, ShopFileName, "Shops", x => x.GetXElement);
|
||||
|
||||
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)!)!;
|
||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||
Shops = LoadData(ShopFileName, "Shop", x => Shop.Create(x)!)!;
|
||||
|
4
Confectionery/FormPastry.Designer.cs
generated
4
Confectionery/FormPastry.Designer.cs
generated
@ -144,12 +144,12 @@
|
||||
this.id.Name = "id";
|
||||
this.id.Visible = false;
|
||||
//
|
||||
// Components
|
||||
// Component
|
||||
//
|
||||
this.Component.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.Component.FillWeight = 1000F;
|
||||
this.Component.HeaderText = "Компонент";
|
||||
this.Component.Name = "Components";
|
||||
this.Component.Name = "Component";
|
||||
//
|
||||
// Count
|
||||
//
|
||||
|
@ -82,7 +82,7 @@ namespace ConfectioneryView
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Добавление нового компонента: { PastryName}- { Count}",
|
||||
_logger.LogInformation("Добавление нового компонента: { ComponentName}- { Count}",
|
||||
form.ComponentModel.ComponentName, form.Count);
|
||||
if (_pastryComponents.ContainsKey(form.Id))
|
||||
{
|
||||
@ -114,7 +114,7 @@ namespace ConfectioneryView
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Изменение компонента: { PastryName} - { Count} ",
|
||||
_logger.LogInformation("Изменение компонента: { ComponentName} - { Count} ",
|
||||
form.ComponentModel.ComponentName, form.Count);
|
||||
_pastryComponents[id] = (form.ComponentModel, form.Count);
|
||||
LoadData();
|
||||
@ -131,7 +131,7 @@ namespace ConfectioneryView
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Удаление компонента: { PastryName}- { Count}",
|
||||
_logger.LogInformation("Удаление компонента: { ComponentName}- { Count}",
|
||||
dataGridView.SelectedRows[0].Cells[1].Value);
|
||||
_pastryComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ namespace ConfectioneryView
|
||||
_list = logic.ReadList(null);
|
||||
if (_list != null)
|
||||
{
|
||||
comboBoxComponent.DisplayMember = "PastryName";
|
||||
comboBoxComponent.DisplayMember = "ComponentName";
|
||||
comboBoxComponent.ValueMember = "Id";
|
||||
comboBoxComponent.DataSource = _list;
|
||||
comboBoxComponent.SelectedItem = null;
|
||||
|
@ -25,7 +25,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Components", b =>
|
||||
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@ -33,7 +33,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("PastryName")
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
@ -95,7 +95,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Components");
|
||||
b.ToTable("Pastries");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.PastryComponent", b =>
|
||||
@ -137,7 +137,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
|
||||
|
||||
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.PastryComponent", b =>
|
||||
{
|
||||
b.HasOne("ConfectioneryDatabaseImplement.Models.Components", "Components")
|
||||
b.HasOne("ConfectioneryDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("PastryComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
@ -149,12 +149,12 @@ namespace ConfectioneryDatabaseImplement.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Components");
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Pastry");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Components", b =>
|
||||
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("PastryComponents");
|
||||
});
|
||||
|
@ -26,7 +26,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Components",
|
||||
name: "Pastries",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
@ -58,7 +58,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Pastries_PastryId",
|
||||
column: x => x.PastryId,
|
||||
principalTable: "Components",
|
||||
principalTable: "Pastries",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
@ -85,7 +85,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
|
||||
table.ForeignKey(
|
||||
name: "FK_PastryComponents_Pastries_PastryId",
|
||||
column: x => x.PastryId,
|
||||
principalTable: "Components",
|
||||
principalTable: "Pastries",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
@ -119,7 +119,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
|
||||
name: "Components");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Components");
|
||||
name: "Pastries");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Components", b =>
|
||||
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@ -30,7 +30,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("PastryName")
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
@ -92,7 +92,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Components");
|
||||
b.ToTable("Pastries");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.PastryComponent", b =>
|
||||
@ -192,7 +192,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
|
||||
|
||||
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.PastryComponent", b =>
|
||||
{
|
||||
b.HasOne("ConfectioneryDatabaseImplement.Models.Components", "Components")
|
||||
b.HasOne("ConfectioneryDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("PastryComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
@ -204,7 +204,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Components");
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Pastry");
|
||||
});
|
||||
@ -235,7 +235,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
|
||||
b.Navigation("Shop");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Components", b =>
|
||||
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("PastryComponents");
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user