Исправлена структура сущностей

This commit is contained in:
Pyro 2024-11-29 07:09:24 +04:00
parent da841c1083
commit e70c5bfc06
4 changed files with 15 additions and 11 deletions

View File

@ -6,15 +6,17 @@ public class Order
public int ClientId { get; private set; }
public bool Completed { get; private set; }
public DateTime Date { get; private set; }
public IEnumerable<OrderProduct> OrderProducts { get; private set; } = [];
public static Order CreateEntity(int id, int clientid, bool completed)
public static Order CreateOperation(int id, int clientid, bool completed, IEnumerable<OrderProduct> orderProducts)
{
return new Order
{
Id = id,
ClientId = clientid,
Completed = completed,
Date = DateTime.Now
Date = DateTime.Now,
OrderProducts = orderProducts
};
}
}

View File

@ -8,15 +8,17 @@ public class Product
public ConfectionaryType ConfectionaryType { get; private set; }
public string Name { get; private set; } = string.Empty;
public double Price { get; private set; }
public IEnumerable<ProductComponent> ProductComponents { get; private set; } = [];
public static Product CreateEntity(int id, ConfectionaryType сonfectionaryType, string name, double price)
public static Product CreateEntity(int id, ConfectionaryType сonfectionaryType, string name, double price, IEnumerable<ProductComponent> productComponents)
{
return new Product
{
Id = id,
ConfectionaryType = сonfectionaryType,
Name = name ?? string.Empty,
Price = price
Price = price,
ProductComponents = productComponents
};
}
}

View File

@ -1,17 +1,17 @@
namespace ProjectConfectionaryFactory.Entities;
public class ComponentProduct
public class ProductComponent
{
public int ComponentId { get; private set; }
public int ProductId { get; private set; }
public int ComponentId { get; private set; }
public double Weight { get; private set; }
public static ComponentProduct CreateEntity(int componentid, int productid, double weight)
public static ProductComponent CreateEntity(int productid, int componentid, double weight)
{
return new ComponentProduct
return new ProductComponent
{
ComponentId = componentid,
ProductId = productid,
ComponentId = componentid,
Weight = weight
};
}

View File

@ -9,7 +9,7 @@ public class Supply
public bool Completed { get; private set; }
public DateTime Date { get; private set; }
public static Supply CreateEntity(int id, int supplierid, int componentid, double weight, bool completed)
public static Supply CreateOperation(int id, int supplierid, int componentid, double weight, bool completed)
{
return new Supply
{