фиг знает
This commit is contained in:
parent
210d90bb69
commit
493886c45a
@ -3,6 +3,7 @@ using ComputerHardwareStoreContracts.BusinessLogicsContracts;
|
|||||||
using ComputerHardwareStoreContracts.SearchModels;
|
using ComputerHardwareStoreContracts.SearchModels;
|
||||||
using ComputerHardwareStoreContracts.StorageContracts;
|
using ComputerHardwareStoreContracts.StorageContracts;
|
||||||
using ComputerHardwareStoreContracts.ViewModels;
|
using ComputerHardwareStoreContracts.ViewModels;
|
||||||
|
using ComputerHardwareStoreDataModels.Enums;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace ComputerHardwareStoreBusinessLogic.BusinessLogic
|
namespace ComputerHardwareStoreBusinessLogic.BusinessLogic
|
||||||
@ -78,7 +79,6 @@ namespace ComputerHardwareStoreBusinessLogic.BusinessLogic
|
|||||||
model.OrderProduct = element.OrderProduct;
|
model.OrderProduct = element.OrderProduct;
|
||||||
model.DateCreate = element.DateCreate;
|
model.DateCreate = element.DateCreate;
|
||||||
model.Status = element.Status;
|
model.Status = element.Status;
|
||||||
model.Cost = element.Cost;
|
|
||||||
|
|
||||||
if (model.Status != orderStatus - 1)
|
if (model.Status != orderStatus - 1)
|
||||||
{
|
{
|
||||||
@ -106,9 +106,9 @@ namespace ComputerHardwareStoreBusinessLogic.BusinessLogic
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (model.Cost <= 0)
|
if (model.Sum <= 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Цена заказа должна быть больше 0", nameof(model.Cost));
|
throw new ArgumentNullException("Цена заказа должна быть больше 0", nameof(model.Sum));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ namespace ComputerHardwareStoreBusinessLogic.BusinessLogic
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(model.DateCreate))
|
if (model.DateCreate == null) // TODO чего блин, всмысле нет
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Нет даты создания покупки", nameof(model.Date));
|
throw new ArgumentNullException("Нет даты создания покупки", nameof(model.Date));
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,12 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Remove="BusinessLogic\**" />
|
||||||
|
<EmbeddedResource Remove="BusinessLogic\**" />
|
||||||
|
<None Remove="BusinessLogic\**" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -6,12 +6,10 @@ namespace ComputerHardwareStoreContracts.BindingModels
|
|||||||
public class OrderBindingModel : IOrderModel
|
public class OrderBindingModel : IOrderModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int CannedId { get; set; }
|
public double Sum { get; set; }
|
||||||
public int Count { get; set; }
|
|
||||||
public double Cost { get; set; }
|
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; } = null;
|
||||||
public Dictionary<int, (IProductModel, int)> OrderProduct { get; set; } = new();
|
public Dictionary<int, (IProductModel, int)> OrderProduct { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ using ComputerHardwareStoreContracts.ViewModels;
|
|||||||
|
|
||||||
namespace ComputerHardwareStoreContracts.StorageContracts
|
namespace ComputerHardwareStoreContracts.StorageContracts
|
||||||
{
|
{
|
||||||
public interface IBuidStorage
|
public interface IBuildStorage
|
||||||
{
|
{
|
||||||
List<BuildViewModel> GetFullList();
|
List<BuildViewModel> GetFullList();
|
||||||
List<BuildViewModel> GetFilteredList(BuildSearchModel model);
|
List<BuildViewModel> GetFilteredList(BuildSearchModel model);
|
@ -1,15 +1,21 @@
|
|||||||
using ComputerHardwareStoreDataModels.Models;
|
using ComputerHardwareStoreDataModels.Enums;
|
||||||
|
using ComputerHardwareStoreDataModels.Models;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace ComputerHardwareStoreContracts.ViewModels
|
namespace ComputerHardwareStoreContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class OrderViewModel : IOrderModel
|
public class OrderViewModel : IOrderModel
|
||||||
{
|
{
|
||||||
|
[DisplayName("Номер")]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Стоимость")]
|
[DisplayName("Сумма")]
|
||||||
public double Cost { get; set; }
|
public double Sum { get; set; }
|
||||||
|
[DisplayName("Статус")]
|
||||||
|
public OrderStatus Status { get; set; }
|
||||||
[DisplayName("Дата создания")]
|
[DisplayName("Дата создания")]
|
||||||
public DateTime DateCreate { get; set; }
|
public DateTime DateCreate { get; set; }
|
||||||
|
[DisplayName("Дата выполнения")]
|
||||||
|
public DateTime? DateImplement { get; set; }
|
||||||
public Dictionary<int, (IProductModel, int)> OrderProduct { get; set; } = new();
|
public Dictionary<int, (IProductModel, int)> OrderProduct { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
namespace ComputerHardwareStoreDataModels.Models
|
using ComputerHardwareStoreDataModels.Enums;
|
||||||
|
|
||||||
|
namespace ComputerHardwareStoreDataModels.Models
|
||||||
{
|
{
|
||||||
public interface IOrderModel : IId
|
public interface IOrderModel : IId
|
||||||
{
|
{
|
||||||
double Cost { get; }
|
double Sum { get; }
|
||||||
|
OrderStatus Status { get; }
|
||||||
DateTime DateCreate { get; }
|
DateTime DateCreate { get; }
|
||||||
|
DateTime? DateImplement { get; }
|
||||||
public Dictionary<int, (IProductModel, int)> OrderProduct { get; }
|
public Dictionary<int, (IProductModel, int)> OrderProduct { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
using ComputerHardwareStoreDatabaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace ComputerHardwareStoreDatabaseImplement
|
||||||
|
{
|
||||||
|
public class ComputerHardwareStoreDBContext : DbContext
|
||||||
|
{
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
|
{
|
||||||
|
if (optionsBuilder.IsConfigured == false)
|
||||||
|
{
|
||||||
|
//optionsBuilder.UseNpgsql(@"Host=localhost;Database=ProductBar_db;Username=postgres;Password=postgres"); // не надо >:
|
||||||
|
/*
|
||||||
|
* в program добавить:
|
||||||
|
* // получаем строку подключения из файла конфигурации
|
||||||
|
* string connection = builder.Configuration.GetConnectionString("DefaultConnection");
|
||||||
|
*
|
||||||
|
* // добавляем контекст ApplicationContext в качестве сервиса в приложение
|
||||||
|
* builder.Services.AddDbContext<ApplicationContext>(options => options.UseSqlServer(connection));
|
||||||
|
*
|
||||||
|
* в appsettings:
|
||||||
|
* "ConnectionStrings": {
|
||||||
|
* "DefaultConnection": "Host=localhost;Database=ProductBar_db;Username=compstore;Password=compstore"
|
||||||
|
* },
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
base.OnConfiguring(optionsBuilder);
|
||||||
|
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||||
|
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
|
||||||
|
}
|
||||||
|
public virtual DbSet<Component> Components { set; get; }
|
||||||
|
public virtual DbSet<Product> Products { set; get; }
|
||||||
|
public virtual DbSet<ProductComponent> ProductComponents { set; get; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
|
||||||
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.2" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\ComputerHardwareStoreContracts\ComputerHardwareStoreContracts.csproj" />
|
||||||
|
<ProjectReference Include="..\ComputerHardwareStoreDataModels\ComputerHardwareStoreDataModels.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
Loading…
Reference in New Issue
Block a user