фикс лабы + сразу фикс конфликтов
This commit is contained in:
parent
2946b11ea8
commit
3b724de00d
@ -24,11 +24,17 @@ namespace ComputersShopFileImplements.Implements
|
||||
}
|
||||
public List<OrderViewModel> GetFiltredList(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue && model.Status == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return source.Orders.Where(x => x.Id == model.Id).Select(x => GetViewModel(x)).ToList();
|
||||
return source.Orders
|
||||
.Where(x => x.Id == model.Id ||
|
||||
model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo ||
|
||||
x.ClientId == model.ClientId ||
|
||||
model.Status.Equals(x.Status))
|
||||
.Select(x => GetViewModel(x))
|
||||
.ToList();
|
||||
}
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
@ -36,6 +42,10 @@ namespace ComputersShopFileImplements.Implements
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (model.ImplementerId.HasValue && model.Status != null)
|
||||
{
|
||||
return source.Orders.FirstOrDefault(x => x.ImplementerId == model.ImplementerId && model.Status.Equals(x.Status))?.GetViewModel;
|
||||
}
|
||||
return GetViewModel(source.Orders.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id));
|
||||
}
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
@ -77,6 +87,8 @@ namespace ComputersShopFileImplements.Implements
|
||||
var viewModel = order.GetViewModel;
|
||||
var computer = source.Computers.FirstOrDefault(x => x.Id == order.ComputerId);
|
||||
viewModel.ComputerName = computer?.ComputerName;
|
||||
var client = source.Clients.FirstOrDefault(x => x.Id == order.ClientId);
|
||||
viewModel.ClientFIO = client.ClientFIO;
|
||||
return viewModel;
|
||||
}
|
||||
}
|
||||
|
@ -62,13 +62,6 @@ namespace ComputersShop
|
||||
option.SetMinimumLevel(LogLevel.Information);
|
||||
option.AddNLog("nlog.config");
|
||||
});
|
||||
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
|
||||
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||
DependencyManager.Instance.RegisterType<IComputerStorage, ComputerStorage>();
|
||||
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||
|
||||
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
|
||||
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
|
||||
DependencyManager.Instance.RegisterType<IComputerLogic, ComputerLogic>();
|
||||
|
@ -15,9 +15,11 @@ namespace ComputersShopDatabaseImplements
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=ComputersShopDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
optionsBuilder.UseNpgsql(@"Host=localhost;Database=ComputersShop_db;Username=postgres;Password=postgres");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
|
||||
}
|
||||
public virtual DbSet<Component> Components { set; get; }
|
||||
public virtual DbSet<Computer> Computers { set; get; }
|
||||
|
@ -18,6 +18,7 @@
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.11" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
|
@ -21,7 +21,15 @@ namespace ComputersShopDatabaseImplements.Implements
|
||||
return null;
|
||||
}
|
||||
using var context = new ComputersShopDatabase();
|
||||
return context.Orders.Include(x => x.Computer).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
return context.Orders
|
||||
.Include(x => x.Computer)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.FirstOrDefault(x =>
|
||||
(model.Status == null || model.Status != null && model.Status.Equals(x.Status)) &&
|
||||
(model.ImplementerId.HasValue && x.ImplementerId == model.ImplementerId) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))?
|
||||
.GetViewModel;
|
||||
}
|
||||
public List<OrderViewModel> GetFiltredList(OrderSearchModel model)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user