исправление для отчётов
This commit is contained in:
parent
db7f79ed81
commit
0b0e6abcde
@ -47,22 +47,9 @@ namespace HardwareShopContracts.BusinessLogicsContracts
|
|||||||
{
|
{
|
||||||
Id = purchase.Id,
|
Id = purchase.Id,
|
||||||
Builds = new List<(string Build, int count, List<(string Component, int count)>)>(),
|
Builds = new List<(string Build, int count, List<(string Component, int count)>)>(),
|
||||||
Goods = new List<(string Good, int count, List<(string Component, int count)>)>(),
|
|
||||||
TotalCount = 0,
|
TotalCount = 0,
|
||||||
TotalCost = 0
|
TotalCost = 0
|
||||||
};
|
};
|
||||||
foreach (var good in purchase.PurchaseGoods)
|
|
||||||
{
|
|
||||||
List<(string Component, int count)> componentList = new List<(string Component, int count)>();
|
|
||||||
int goodTotalCount = 0;
|
|
||||||
foreach (var component in good.Value.Item1.GoodComponents)
|
|
||||||
{
|
|
||||||
componentList.Add(new(component.Value.Item1.ComponentName, component.Value.Item2));
|
|
||||||
goodTotalCount += component.Value.Item2;
|
|
||||||
}
|
|
||||||
record.Goods.Add(new(good.Value.Item1.GoodName, good.Value.Item2, componentList));
|
|
||||||
record.TotalCount += goodTotalCount * good.Value.Item2;
|
|
||||||
}
|
|
||||||
foreach (var build in purchase.PurchaseBuilds)
|
foreach (var build in purchase.PurchaseBuilds)
|
||||||
{
|
{
|
||||||
List<(string Component, int count)> componentList = new List<(string Component, int count)>();
|
List<(string Component, int count)> componentList = new List<(string Component, int count)>();
|
||||||
|
@ -12,8 +12,6 @@ namespace HardwareShopContracts.ViewModels
|
|||||||
|
|
||||||
public List<(string Build, int count, List<(string Component, int count)>)> Builds { get; set; } = new();
|
public List<(string Build, int count, List<(string Component, int count)>)> Builds { get; set; } = new();
|
||||||
|
|
||||||
public List<(string Good, int count, List<(string Component, int count)>)> Goods { get; set; } = new();
|
|
||||||
|
|
||||||
public int TotalCount { get; set; }
|
public int TotalCount { get; set; }
|
||||||
|
|
||||||
public int TotalCost { get; set; }
|
public int TotalCost { get; set; }
|
||||||
|
@ -27,8 +27,13 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
|
|||||||
if (!model.UserId.HasValue && !model.PurchaseStatus.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
|
if (!model.UserId.HasValue && !model.PurchaseStatus.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||||
{
|
{
|
||||||
return context.Purchases
|
return context.Purchases
|
||||||
.Include(x => x.Goods)
|
.Include(x => x.Builds)
|
||||||
.ThenInclude(x => x.Good)
|
.ThenInclude(x => x.Build)
|
||||||
|
.ThenInclude(x => x.Components)
|
||||||
|
.ThenInclude(x => x.Component)
|
||||||
|
.Include(x => x.Builds)
|
||||||
|
.ThenInclude(x => x.Build)
|
||||||
|
.ThenInclude(x => x.Comments)
|
||||||
.Where(x => x.DatePurchase >= model.DateFrom && x.DatePurchase <= model.DateTo)
|
.Where(x => x.DatePurchase >= model.DateFrom && x.DatePurchase <= model.DateTo)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
@ -50,6 +55,23 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
|
|||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<PurchaseViewModel> GetReportFilteredList(PurchaseSearchModel model)
|
||||||
|
{
|
||||||
|
using var context = new HardwareShopDatabase();
|
||||||
|
if (!model.UserId.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return context.Purchases
|
||||||
|
.Include(x => x.Builds)
|
||||||
|
.ThenInclude(x => x.Build)
|
||||||
|
.ThenInclude(x => x.Components)
|
||||||
|
.ThenInclude(x => x.Component)
|
||||||
|
.Where(x => x.UserId == model.UserId)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
public PurchaseViewModel? GetElement(PurchaseSearchModel model)
|
public PurchaseViewModel? GetElement(PurchaseSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.Id.HasValue)
|
if (!model.Id.HasValue)
|
||||||
|
@ -27,7 +27,7 @@ namespace HardwareShopDatabaseImplement.Models.Worker
|
|||||||
public virtual List<Comment> Comments { get; set; } = new();
|
public virtual List<Comment> Comments { get; set; } = new();
|
||||||
|
|
||||||
[ForeignKey("BuildId")]
|
[ForeignKey("BuildId")]
|
||||||
public virtual List<ComponentBuild>? Components { get; set; }
|
public virtual List<ComponentBuild> Components { get; set; } = new();
|
||||||
|
|
||||||
|
|
||||||
[ForeignKey("BuildId")]
|
[ForeignKey("BuildId")]
|
||||||
|
@ -27,7 +27,7 @@ namespace HardwareShopDatabaseImplement.Models.Worker
|
|||||||
public virtual User User { get; set; }
|
public virtual User User { get; set; }
|
||||||
|
|
||||||
[ForeignKey("PurchaseId")]
|
[ForeignKey("PurchaseId")]
|
||||||
public virtual List<PurchaseBuild>? Builds { get; set; }
|
public virtual List<PurchaseBuild> Builds { get; set; } = new();
|
||||||
|
|
||||||
[ForeignKey("PurchaseId")]
|
[ForeignKey("PurchaseId")]
|
||||||
public virtual List<PurchaseGood> Goods { get; set; } = new();
|
public virtual List<PurchaseGood> Goods { get; set; } = new();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user