small fix with relation between entities

This commit is contained in:
Никита Волков 2024-04-30 04:25:43 +04:00
parent b06e5065f6
commit e7d0077ce4
6 changed files with 13 additions and 7 deletions

View File

@ -82,7 +82,7 @@ namespace ComputersShopBusinessLogic.BusinessLogics
});
if (element == null)
{
_logger.LogWarning("Не удалоссь найти клиента, отправившего письмо с адреса Email:{Email}", model.SenderName);
_logger.LogWarning("Не удалось найти клиента, отправившего письмо с адреса Email:{Email}", model.SenderName);
}
else
{

View File

@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace ComputersShopDataBaseImplement.Migrations
{
[DbContext(typeof(ComputersShopDataBase))]
[Migration("20240418105123_Init-Create")]
partial class InitCreate
[Migration("20240430002234_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -237,9 +237,11 @@ namespace ComputersShopDataBaseImplement.Migrations
modelBuilder.Entity("ComputersShopDataBaseImplement.Models.Message", b =>
{
b.HasOne("ComputersShopDataBaseImplement.Models.Client", null)
b.HasOne("ComputersShopDataBaseImplement.Models.Client", "Client")
.WithMany("Messages")
.HasForeignKey("ClientId");
b.Navigation("Client");
});
modelBuilder.Entity("ComputersShopDataBaseImplement.Models.Order", b =>

View File

@ -7,7 +7,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace ComputersShopDataBaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitCreate : Migration
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)

View File

@ -234,9 +234,11 @@ namespace ComputersShopDataBaseImplement.Migrations
modelBuilder.Entity("ComputersShopDataBaseImplement.Models.Message", b =>
{
b.HasOne("ComputersShopDataBaseImplement.Models.Client", null)
b.HasOne("ComputersShopDataBaseImplement.Models.Client", "Client")
.WithMany("Messages")
.HasForeignKey("ClientId");
b.Navigation("Client");
});
modelBuilder.Entity("ComputersShopDataBaseImplement.Models.Order", b =>

View File

@ -17,6 +17,8 @@ namespace ComputersShopDataBaseImplement.Models
public int? ClientId { get; private set; }
public virtual Client? Client { get; set; }
public string SenderName { get; private set; } = string.Empty;
public DateTime DateDelivery { get; private set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);

View File

@ -47,7 +47,7 @@ namespace ComputersShopFileImplement
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
Implementers = LoadData(ImplementerFileName, "Implementer", x => Implementer.Create(x)!)!;
Messages = LoadData(MessageFileName, "Message", x => Message.Create(x));
Messages = LoadData(MessageFileName, "Message", x => Message.Create(x)!)!;
}
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
{