Compare commits
No commits in common. "7fde2e5622118f78df358f613da52b7f00d047c3" and "92d6b4ed4ddcfdc9b952ecef0f87f6c9964d51af" have entirely different histories.
7fde2e5622
...
92d6b4ed4d
@ -13,7 +13,8 @@ namespace ComputerShopContracts.BindingModels
|
||||
|
||||
public int UserId { get; set; }
|
||||
|
||||
public int AssemblyId { get; set; }
|
||||
//!!!ДОБАВИТЬ ССЫЛКУ НА СБОРКУ
|
||||
|
||||
|
||||
public DateTime DateMake { get; set; } = DateTime.Now;
|
||||
|
||||
|
@ -11,8 +11,7 @@ namespace ComputerShopContracts.SearchModels
|
||||
public int? Id { get; set; }
|
||||
public int? UserId { get; set; }
|
||||
|
||||
//поиск по сборкам
|
||||
public int? AssemblyId { get; set; }
|
||||
//!!!ДОБАВИТЬ ПОИСК ПО СБОРКЕ (СУЩНОСТИ ОЛЕГА)
|
||||
|
||||
//!!!мб надо добавить поиск по заказам
|
||||
|
||||
|
@ -7,12 +7,12 @@ namespace ComputerShopContracts.ViewModels
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int UserId { get; set; }
|
||||
public int UserId { get; }
|
||||
|
||||
[DisplayName("Название комплектующей")]
|
||||
public string ComponentName { get; set; } = string.Empty;
|
||||
public string ComponentName { get; } = string.Empty;
|
||||
|
||||
[DisplayName("Стоимость")]
|
||||
public double Cost { get; set; }
|
||||
public double Cost { get; }
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ namespace ComputerShopContracts.ViewModels
|
||||
|
||||
//!!!МБ ДОБАВИТЬ НИК ПОЛЬЗОВАТЕЛЯ, СОЗДАВШЕГО ЗАЯВКУ
|
||||
|
||||
public int AssemblyId { get; set; }
|
||||
//!!!МБ ДОБАВИТЬ ID СБОРКИ
|
||||
|
||||
public Dictionary<int, IOrderModel> RequestOrders { get; set; } = new();
|
||||
|
||||
|
@ -14,10 +14,12 @@ namespace ComputerShopDataModels.Models
|
||||
//ID пользователя, создавшего заявку
|
||||
int UserId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// ID сборки
|
||||
/// </summary>
|
||||
int AssemblyId { get; }
|
||||
|
||||
|
||||
|
||||
|
||||
//!!!ДОБАВИТЬ ССЫЛКУ НА СБОРКУ ИЗ ЧАСТИ ОЛЕГА
|
||||
|
||||
|
||||
Dictionary<int, IOrderModel> RequestOrders { get; }
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
using ComputerShopDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace ComputerShopDatabaseImplement
|
||||
{
|
||||
@ -17,17 +16,5 @@ namespace ComputerShopDatabaseImplement
|
||||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
|
||||
}
|
||||
|
||||
public virtual DbSet<User> Users { get; set; }
|
||||
|
||||
public virtual DbSet<Component> Components { get; set; }
|
||||
|
||||
public virtual DbSet<Assembly> Assemblies { get; set; }
|
||||
|
||||
public virtual DbSet<AssemblyComponent> AssemblyComponents { get; set; }
|
||||
|
||||
public virtual DbSet<Product> Products { get; set; }
|
||||
|
||||
public virtual DbSet<ProductComponent> ProductComponents { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -6,12 +6,6 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Implements\**" />
|
||||
<EmbeddedResource Remove="Implements\**" />
|
||||
<None Remove="Implements\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.18" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.18">
|
||||
@ -26,4 +20,8 @@
|
||||
<ProjectReference Include="..\ComputerShopDataModels\ComputerShopDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Implements\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -1,65 +0,0 @@
|
||||
using ComputerShopContracts.BindingModels;
|
||||
using ComputerShopDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ComputerShopDatabaseImplement.Models
|
||||
{
|
||||
public class Assembly : IAssemblyModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
[Required]
|
||||
public int UserId { get; private set; }
|
||||
|
||||
[Required]
|
||||
public string AssemblyName { get; private set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public double Cost { get; private set; }
|
||||
|
||||
[Required]
|
||||
public string Category { get; private set; } = string.Empty;
|
||||
|
||||
[ForeignKey("ComponentId")]
|
||||
public virtual List<AssemblyComponent> Components { get; set; } = new();
|
||||
|
||||
private Dictionary<int, (IComponentModel, int)>? _assemblyComponents;
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IComponentModel, int)> AssemblyComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_assemblyComponents == null)
|
||||
{
|
||||
_assemblyComponents = Components.ToDictionary(
|
||||
AsmComp => AsmComp.ComponentId,
|
||||
AsmComp => (AsmComp.Component as IComponentModel, AsmComp.Count)
|
||||
);
|
||||
}
|
||||
|
||||
return _assemblyComponents;
|
||||
}
|
||||
}
|
||||
|
||||
public static Assembly Create(ComputerShopDatabase Context, AssemblyBindingModel Model)
|
||||
{
|
||||
return new()
|
||||
{
|
||||
Id = Model.Id,
|
||||
UserId = Model.UserId,
|
||||
AssemblyName = Model.AssemblyName,
|
||||
Cost = Model.Cost,
|
||||
Category = Model.Category,
|
||||
Components = Model.AssemblyComponents.Select(x => new AssemblyComponent
|
||||
{
|
||||
Component = Context.Components.First(y => y.Id == x.Key),
|
||||
Count = x.Value.Item2
|
||||
}).ToList(),
|
||||
};
|
||||
}
|
||||
|
||||
// TODO: Update(), ViewModel, UpdateComponents()
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ComputerShopDatabaseImplement.Models
|
||||
{
|
||||
public class AssemblyComponent
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public int AssemblyId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ComponentId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
|
||||
public virtual Assembly Assembly { get; set; } = new();
|
||||
|
||||
public virtual Component Component { get; set; } = new();
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
using ComputerShopContracts.BindingModels;
|
||||
using ComputerShopContracts.ViewModels;
|
||||
using ComputerShopDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ComputerShopDatabaseImplement.Models
|
||||
{
|
||||
public class Component : IComponentModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
[Required]
|
||||
public int UserId { get; private set; }
|
||||
|
||||
[Required]
|
||||
public string ComponentName { get; private set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public double Cost { get; private set; }
|
||||
|
||||
[ForeignKey("ComponentId")]
|
||||
public virtual List<AssemblyComponent> AssemblyComponents { get; set; } = new();
|
||||
|
||||
public static Component Create(ComponentBindingModel Model)
|
||||
{
|
||||
return new()
|
||||
{
|
||||
Id = Model.Id,
|
||||
UserId = Model.UserId,
|
||||
ComponentName = Model.ComponentName,
|
||||
Cost = Model.Cost,
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ComponentBindingModel Model)
|
||||
{
|
||||
ComponentName = Model.ComponentName;
|
||||
Cost = Model.Cost;
|
||||
}
|
||||
|
||||
public ComponentViewModel ViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
UserId = UserId,
|
||||
ComponentName = ComponentName,
|
||||
Cost = Cost,
|
||||
};
|
||||
}
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
using ComputerShopContracts.BindingModels;
|
||||
using ComputerShopDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ComputerShopDatabaseImplement.Models
|
||||
{
|
||||
public class Product : IProductModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public int UserId { get; set; }
|
||||
|
||||
[Required]
|
||||
public string ProductName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public double Cost { get; set; }
|
||||
|
||||
[Required]
|
||||
public int Warranty { get; set; }
|
||||
|
||||
public int? ShipmentId { get; set; }
|
||||
|
||||
[ForeignKey("ComponentId")]
|
||||
public virtual List<ProductComponent> Components { get; set; } = new();
|
||||
|
||||
private Dictionary<int, (IComponentModel, int)>? _productComponents;
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IComponentModel, int)> ProductComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_productComponents == null)
|
||||
{
|
||||
_productComponents = Components.ToDictionary(
|
||||
ProdComp => ProdComp.ComponentId,
|
||||
ProdComp => (ProdComp.Component as IComponentModel, ProdComp.Count)
|
||||
);
|
||||
}
|
||||
|
||||
return _productComponents;
|
||||
}
|
||||
}
|
||||
|
||||
public static Product Create(ComputerShopDatabase Context, ProductBindingModel Model)
|
||||
{
|
||||
return new()
|
||||
{
|
||||
Id = Model.Id,
|
||||
UserId = Model.UserId,
|
||||
ProductName = Model.ProductName,
|
||||
Cost = Model.Cost,
|
||||
Warranty = Model.Warranty,
|
||||
Components = Model.ProductComponents.Select(x => new ProductComponent
|
||||
{
|
||||
Component = Context.Components.First(y => y.Id == x.Key),
|
||||
Count = x.Value.Item2
|
||||
}).ToList(),
|
||||
ShipmentId = Model.ShipmentId,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ComputerShopDatabaseImplement.Models
|
||||
{
|
||||
public class ProductComponent
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ProductId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ComponentId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
|
||||
public virtual Product Product { get; set; } = new();
|
||||
|
||||
public virtual Component Component { get; set; } = new();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user