КРУДЫЫ РАБОТАЮТ
This commit is contained in:
parent
2dfdf5d21d
commit
231063ed16
@ -7,11 +7,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeautySaloonView", "BeautyS
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeautySaloonDataModels", "BeautySaloonDataModels\BeautySaloonDataModels.csproj", "{A83AC6FD-F6BD-4BD2-AC69-3BB5BA30FF7D}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeautySaloonDataModels", "BeautySaloonDataModels\BeautySaloonDataModels.csproj", "{A83AC6FD-F6BD-4BD2-AC69-3BB5BA30FF7D}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeautySaloonContracts", "BeautySaloonContracts\BeautySaloonContracts.csproj", "{7494D3AF-2581-4128-9183-BB87A9DC4B10}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeautySaloonContracts", "BeautySaloonContracts\BeautySaloonContracts.csproj", "{7494D3AF-2581-4128-9183-BB87A9DC4B10}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeautySaloonBusinessLogic", "BeautySaloonBusinessLogic\BeautySaloonBusinessLogic.csproj", "{E43A1394-BC9A-430B-B984-BCCD828FFF45}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeautySaloonBusinessLogic", "BeautySaloonBusinessLogic\BeautySaloonBusinessLogic.csproj", "{E43A1394-BC9A-430B-B984-BCCD828FFF45}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeautySaloonDatabaseImplement", "BeautySaloonDatabaseImplement\BeautySaloonDatabaseImplement.csproj", "{BB7AD640-FF4A-415B-A09B-BB802D64CE27}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeautySaloonDatabaseImplement", "BeautySaloonDatabaseImplement\BeautySaloonDatabaseImplement.csproj", "{BB7AD640-FF4A-415B-A09B-BB802D64CE27}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
@ -6,6 +6,14 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.4">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\BeautySaloonContracts\BeautySaloonContracts.csproj" />
|
<ProjectReference Include="..\BeautySaloonContracts\BeautySaloonContracts.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -6,6 +6,14 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.4">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\BeautySaloonDataModels\BeautySaloonDataModels.csproj" />
|
<ProjectReference Include="..\BeautySaloonDataModels\BeautySaloonDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -6,4 +6,12 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.4">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using BeautySaloonContracts.SearchModels;
|
using BeautySaloonContracts.SearchModels;
|
||||||
using BeautySaloonContracts.StoragesContracts;
|
using BeautySaloonContracts.StoragesContracts;
|
||||||
using BeautySaloonContracts.ViewModels;
|
using BeautySaloonContracts.ViewModels;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace BeautySaloonDatabaseImplement.Implements
|
namespace BeautySaloonDatabaseImplement.Implements
|
||||||
{
|
{
|
||||||
@ -11,6 +12,8 @@ namespace BeautySaloonDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
using var context = new NewdbContext();
|
using var context = new NewdbContext();
|
||||||
var element = context.Orders
|
var element = context.Orders
|
||||||
|
.Include(x => x.Employee)
|
||||||
|
.Include(x => x.Client)
|
||||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
if (element != null)
|
if (element != null)
|
||||||
{
|
{
|
||||||
@ -26,6 +29,8 @@ namespace BeautySaloonDatabaseImplement.Implements
|
|||||||
using var context = new NewdbContext();
|
using var context = new NewdbContext();
|
||||||
if (model.Id.HasValue)
|
if (model.Id.HasValue)
|
||||||
return context.Orders
|
return context.Orders
|
||||||
|
.Include(x => x.Employee)
|
||||||
|
.Include(x => x.Client)
|
||||||
.FirstOrDefault(x => x.Id == model.Id)?
|
.FirstOrDefault(x => x.Id == model.Id)?
|
||||||
.GetViewModel;
|
.GetViewModel;
|
||||||
return null;
|
return null;
|
||||||
@ -36,16 +41,22 @@ namespace BeautySaloonDatabaseImplement.Implements
|
|||||||
using var context = new NewdbContext();
|
using var context = new NewdbContext();
|
||||||
if (model.ClientId.HasValue)
|
if (model.ClientId.HasValue)
|
||||||
return context.Orders
|
return context.Orders
|
||||||
|
.Include(x => x.Employee)
|
||||||
|
.Include(x => x.Client)
|
||||||
.Where(x => x.ClientId == model.ClientId)
|
.Where(x => x.ClientId == model.ClientId)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
if (model.EmployeeId.HasValue)
|
if (model.EmployeeId.HasValue)
|
||||||
return context.Orders
|
return context.Orders
|
||||||
|
.Include(x => x.Employee)
|
||||||
|
.Include(x => x.Client)
|
||||||
.Where(x => x.EmployeeId == model.EmployeeId)
|
.Where(x => x.EmployeeId == model.EmployeeId)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
if (model.Date.HasValue)
|
if (model.Date.HasValue)
|
||||||
return context.Orders
|
return context.Orders
|
||||||
|
.Include(x => x.Employee)
|
||||||
|
.Include(x => x.Client)
|
||||||
.Where(x => x.Date == model.Date)
|
.Where(x => x.Date == model.Date)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
@ -56,14 +67,18 @@ namespace BeautySaloonDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
using var context = new NewdbContext();
|
using var context = new NewdbContext();
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Select(x => x.GetViewModel)
|
.Include(x => x.Employee)
|
||||||
.ToList();
|
.Include(x => x.Client)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
public OrderViewModel? Insert(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new NewdbContext();
|
using var context = new NewdbContext();
|
||||||
model.Id = context.Orders
|
model.Id = context.Orders
|
||||||
|
.Include(x => x.Employee)
|
||||||
|
.Include(x => x.Client)
|
||||||
.Count() > 0 ? context.Orders.Max(x => x.Id) + 1 : 1;
|
.Count() > 0 ? context.Orders.Max(x => x.Id) + 1 : 1;
|
||||||
var newOrder = Order.Create(context, model);
|
var newOrder = Order.Create(context, model);
|
||||||
if (newOrder == null)
|
if (newOrder == null)
|
||||||
@ -72,7 +87,10 @@ namespace BeautySaloonDatabaseImplement.Implements
|
|||||||
}
|
}
|
||||||
context.Orders.Add(newOrder);
|
context.Orders.Add(newOrder);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return newOrder.GetViewModel;
|
return context.Orders
|
||||||
|
.Include(x => x.Employee)
|
||||||
|
.Include(x => x.Client).FirstOrDefault(x => x.Id == newOrder.Id)
|
||||||
|
?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? Update(OrderBindingModel model)
|
public OrderViewModel? Update(OrderBindingModel model)
|
||||||
@ -81,7 +99,8 @@ namespace BeautySaloonDatabaseImplement.Implements
|
|||||||
using var transaction = context.Database.BeginTransaction();
|
using var transaction = context.Database.BeginTransaction();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var order = context.Orders.FirstOrDefault(rec => rec.Id == model.Id);
|
var order = context.Orders.Include(x => x.Employee)
|
||||||
|
.Include(x => x.Client).FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
if (order == null)
|
if (order == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
@ -174,10 +174,6 @@ public partial class NewdbContext : DbContext
|
|||||||
|
|
||||||
entity.ToTable("service_order", tb => tb.HasComment("Сущность-связь услуги с заказом"));
|
entity.ToTable("service_order", tb => tb.HasComment("Сущность-связь услуги с заказом"));
|
||||||
|
|
||||||
entity.HasIndex(e => e.OrderId, "service_order_orderid_key").IsUnique();
|
|
||||||
|
|
||||||
entity.HasIndex(e => e.ServiceId, "service_order_serviceid_key").IsUnique();
|
|
||||||
|
|
||||||
entity.Property(e => e.ServiceId)
|
entity.Property(e => e.ServiceId)
|
||||||
.HasComment("Составной первичный ключ: идентификатор услуги")
|
.HasComment("Составной первичный ключ: идентификатор услуги")
|
||||||
.HasColumnName("service_id");
|
.HasColumnName("service_id");
|
||||||
@ -194,22 +190,22 @@ public partial class NewdbContext : DbContext
|
|||||||
|
|
||||||
entity.HasOne(d => d.Employee).WithMany(p => p.ServiceOrders)
|
entity.HasOne(d => d.Employee).WithMany(p => p.ServiceOrders)
|
||||||
.HasForeignKey(d => d.EmployeeId)
|
.HasForeignKey(d => d.EmployeeId)
|
||||||
.OnDelete(DeleteBehavior.ClientSetNull)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.HasConstraintName("employee_fk");
|
.HasConstraintName("service_order_employee_id_fkey");
|
||||||
|
|
||||||
entity.HasOne(d => d.Order).WithOne(p => p.ServiceOrder)
|
entity.HasOne(d => d.Order).WithMany(p => p.ServiceOrders)
|
||||||
.HasForeignKey<ServiceOrder>(d => d.OrderId)
|
.HasForeignKey(d => d.OrderId)
|
||||||
.OnDelete(DeleteBehavior.ClientSetNull)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.HasConstraintName("order_fk");
|
.HasConstraintName("service_order_order_id_fkey");
|
||||||
|
|
||||||
entity.HasOne(d => d.Service).WithOne(p => p.ServiceOrder)
|
entity.HasOne(d => d.Service).WithMany(p => p.ServiceOrders)
|
||||||
.HasForeignKey<ServiceOrder>(d => d.ServiceId)
|
.HasForeignKey(d => d.ServiceId)
|
||||||
.OnDelete(DeleteBehavior.ClientSetNull)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.HasConstraintName("service_fk");
|
.HasConstraintName("service_order_service_id_fkey");
|
||||||
});
|
});
|
||||||
|
|
||||||
OnModelCreatingPartial(modelBuilder);
|
OnModelCreatingPartial(modelBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
using BeautySaloonContracts.BindingModels;
|
using BeautySaloonContracts.BindingModels;
|
||||||
using BeautySaloonContracts.ViewModels;
|
using BeautySaloonContracts.ViewModels;
|
||||||
using BeautySaloonDataModels;
|
using BeautySaloonDataModels;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace BeautySaloonDatabaseImplement;
|
namespace BeautySaloonDatabaseImplement;
|
||||||
|
|
||||||
@ -38,23 +39,19 @@ public partial class Order : IOrderModel
|
|||||||
|
|
||||||
public virtual Employee Employee { get; set; } = null!;
|
public virtual Employee Employee { get; set; } = null!;
|
||||||
|
|
||||||
public virtual ServiceOrder? ServiceOrder { get; set; }
|
public virtual List<ServiceOrder> ServiceOrders { get; set; } = new List<ServiceOrder>();
|
||||||
|
|
||||||
|
|
||||||
public Dictionary<int, (TimeOnly, IServiceModel, int)> _orderServices = null;
|
public Dictionary<int, (TimeOnly, IServiceModel, int)> _orderServices = null;
|
||||||
|
|
||||||
public virtual List<ServiceOrder> Services { get; set; } = new();
|
|
||||||
|
|
||||||
public Dictionary<int, (TimeOnly, IServiceModel, int)> OrderServices
|
public Dictionary<int, (TimeOnly, IServiceModel, int)> OrderServices
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_orderServices == null)
|
if (_orderServices == null)
|
||||||
{
|
{
|
||||||
_orderServices = Services
|
_orderServices = ServiceOrders
|
||||||
.ToDictionary(serviceOrd => serviceOrd.ServiceId,
|
.ToDictionary(recPC => recPC.ServiceId,
|
||||||
serviceOrd => (serviceOrd.Date, serviceOrd.Service as IServiceModel,
|
recPC => (recPC.Date, recPC.Service as IServiceModel, recPC.EmployeeId));
|
||||||
serviceOrd.EmployeeId));
|
|
||||||
}
|
}
|
||||||
return _orderServices;
|
return _orderServices;
|
||||||
}
|
}
|
||||||
@ -73,7 +70,7 @@ public partial class Order : IOrderModel
|
|||||||
Sum = model.Sum,
|
Sum = model.Sum,
|
||||||
ClientId = model.ClientId,
|
ClientId = model.ClientId,
|
||||||
EmployeeId = model.EmployeeId,
|
EmployeeId = model.EmployeeId,
|
||||||
Services = model.OrderServices.Select(x => new ServiceOrder
|
ServiceOrders = model.OrderServices.Select(x => new ServiceOrder
|
||||||
{
|
{
|
||||||
Service = context.Services.First(y => y.Id == x.Key),
|
Service = context.Services.First(y => y.Id == x.Key),
|
||||||
Date = x.Value.Item1,
|
Date = x.Value.Item1,
|
||||||
|
@ -25,8 +25,7 @@ public partial class Service : IServiceModel
|
|||||||
/// Цена
|
/// Цена
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public decimal Price { get; set; }
|
public decimal Price { get; set; }
|
||||||
|
public virtual ICollection<ServiceOrder> ServiceOrders { get; } = new List<ServiceOrder>();
|
||||||
public virtual ServiceOrder? ServiceOrder { get; set; }
|
|
||||||
|
|
||||||
public static Service Create(ServiceBindingModel model)
|
public static Service Create(ServiceBindingModel model)
|
||||||
{
|
{
|
||||||
|
@ -13,7 +13,12 @@
|
|||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.4">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||||
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using BeautySaloonContracts.BindingModels;
|
using BeautySaloonContracts.BindingModels;
|
||||||
using BeautySaloonContracts.BusinessLogicsContracts;
|
using BeautySaloonContracts.BusinessLogicsContracts;
|
||||||
using BeautySaloonContracts.SearchModels;
|
using BeautySaloonContracts.SearchModels;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
|
||||||
|
|
||||||
namespace BeautySaloonView
|
namespace BeautySaloonView
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user