report grabbing logic
This commit is contained in:
parent
9d584e2f20
commit
d51a55180c
@ -38,14 +38,43 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
||||
{
|
||||
var result = new List<ReportComponentReceivingViewModel>();
|
||||
|
||||
List<ComponentViewModel> components = new List<ComponentViewModel>();
|
||||
foreach (int id in ids)
|
||||
{
|
||||
var component = _componentStorage.GetElement(new ComponentSearchModel()
|
||||
{
|
||||
Id = id,
|
||||
});
|
||||
if (component != null) components.Add(component);
|
||||
var supplies = _supplyStorage.GetFilteredList(new()
|
||||
{
|
||||
ComponentId = id
|
||||
});
|
||||
|
||||
var receivings = new List<EquipmentReceivingViewModel>();
|
||||
|
||||
foreach(var supply in supplies)
|
||||
{
|
||||
if (supply.ReceivingId.HasValue)
|
||||
{
|
||||
var receiving = _receivingStorage.GetElement(new() { Id = supply.ReceivingId.Value });
|
||||
if (receiving != null && receivings.Contains(receiving))
|
||||
{
|
||||
receivings.Add(receiving);
|
||||
}
|
||||
}
|
||||
}
|
||||
var receivingnames = new List<string>();
|
||||
foreach (var receiving in receivings)
|
||||
{
|
||||
receivingnames.Add($"Id: {receiving.Id}. Date: {receiving.Status}.");
|
||||
}
|
||||
if(receivingnames.Count > 0 && component != null)
|
||||
{
|
||||
result.Add(new()
|
||||
{
|
||||
ComponentName = component.ComponentName,
|
||||
Receivings = receivingnames
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -54,12 +83,12 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
||||
|
||||
public void SaveReceivingComponentsToWordFile(ReportBindingModel model)
|
||||
{
|
||||
//_saveToWord.CreateDoc(new WordInfoProvider
|
||||
//{
|
||||
// FileName = model.FileName,
|
||||
// Title = "Список получений по компонентам",
|
||||
// ComponentReceivings = GetComponentReceivings(model.Ids)
|
||||
//});
|
||||
_saveToWord.CreateDoc(new WordInfoProvider
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список получений по компонентам",
|
||||
ComponentReceivings = GetComponentReceivings(model.Ids)
|
||||
});
|
||||
}
|
||||
|
||||
public void SaveReceivingComponentsToXmlFile(ReportBindingModel mode)
|
||||
|
@ -12,51 +12,51 @@ namespace ComputerShopBusinessLogic.OfficePackage
|
||||
{
|
||||
public void CreateDoc(WordInfoProvider info)
|
||||
{
|
||||
//CreateWord(info);
|
||||
CreateWord(info);
|
||||
|
||||
//CreateParagraph(new WordParagraph
|
||||
//{
|
||||
// Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
|
||||
// TextProperties = new WordTextProperties
|
||||
// {
|
||||
// Size = "24",
|
||||
// JustificationType = WordJustificationType.Center
|
||||
// }
|
||||
//});
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Center
|
||||
}
|
||||
});
|
||||
|
||||
//foreach (var mc in info.MemberConferences)
|
||||
//{
|
||||
// CreateParagraph(new WordParagraph
|
||||
// {
|
||||
// Texts = new List<(string, WordTextProperties)>
|
||||
// { (mc.MemberFIO, new WordTextProperties { Size = "20", Bold=true})},
|
||||
// TextProperties = new WordTextProperties
|
||||
// {
|
||||
// Size = "24",
|
||||
// JustificationType = WordJustificationType.Both
|
||||
// }
|
||||
// });
|
||||
foreach (var mc in info.MemberConferences)
|
||||
{
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)>
|
||||
{ (mc.MemberFIO, new WordTextProperties { Size = "20", Bold=true})},
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Both
|
||||
}
|
||||
});
|
||||
|
||||
// foreach (var conference in mc.Conferences)
|
||||
// {
|
||||
// CreateParagraph(new WordParagraph
|
||||
// {
|
||||
// Texts = new List<(string, WordTextProperties)>
|
||||
// { (conference.Item1 + " - ", new WordTextProperties { Size = "16", Bold=false}),
|
||||
// (conference.Item2.ToShortDateString(), new WordTextProperties { Size = "16", Bold=false})},
|
||||
// TextProperties = new WordTextProperties
|
||||
// {
|
||||
// Size = "24",
|
||||
// JustificationType = WordJustificationType.Both
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//}
|
||||
//SaveWord(info);
|
||||
foreach (var conference in mc.Conferences)
|
||||
{
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)>
|
||||
{ (conference.Item1 + " - ", new WordTextProperties { Size = "16", Bold=false}),
|
||||
(conference.Item2.ToShortDateString(), new WordTextProperties { Size = "16", Bold=false})},
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Both
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
SaveWord(info);
|
||||
}
|
||||
|
||||
//protected abstract void CreateWord(WordInfoOrganiser info);
|
||||
//protected abstract void CreateParagraph(WordParagraph paragraph);
|
||||
//protected abstract void SaveWord(WordInfoOrganiser info);
|
||||
protected abstract void CreateWord(WordInfoOrganiser info);
|
||||
protected abstract void CreateParagraph(WordParagraph paragraph);
|
||||
protected abstract void SaveWord(WordInfoOrganiser info);
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,6 @@ namespace ComputerShopBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public Dictionary<ComponentViewModel, List<EquipmentReceivingViewModel>> ComponentReceivings { get; set; } = new();
|
||||
public List<ReportComponentReceivingViewModel> ComponentReceivings { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,8 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerShopBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
public class SaveToWord
|
||||
public class SaveToWord : AbstractSaveToWord
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -12,5 +12,6 @@ namespace ComputerShopContracts.SearchModels
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
public ComponentSearchModel? Component { get; set; }
|
||||
public int? ComponentId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,8 @@ namespace ComputerShopContracts.ViewModels
|
||||
set;
|
||||
} = new();
|
||||
|
||||
public int? ReceivingId { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -47,11 +47,12 @@ namespace ComputerShopDatabaseImplement.Implements
|
||||
|
||||
public List<SupplyViewModel> GetFilteredList(SupplySearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
if (!model.Id.HasValue && !model.ComponentId.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new ComputerShopDatabase();
|
||||
if(model.ComponentId.HasValue)
|
||||
return context.Supplies
|
||||
.Include(x => x.Orders)
|
||||
.ThenInclude(x => x.Order)
|
||||
@ -59,6 +60,16 @@ namespace ComputerShopDatabaseImplement.Implements
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
else
|
||||
return context.Supplies
|
||||
.Include(x => x.Orders)
|
||||
.ThenInclude(x => x.Order)
|
||||
.Include(x => x.ComponentSupplies)
|
||||
.ThenInclude(x => x.Component)
|
||||
.Where(x => x.ComponentSupplies.Any(x => x.ComponentId == model.ComponentId))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<SupplyViewModel> GetFullList()
|
||||
|
Loading…
Reference in New Issue
Block a user