fix ReportLogic
This commit is contained in:
parent
36883c907c
commit
a6e97267aa
@ -14,19 +14,20 @@ namespace FurnitureContracts.BusinessLogicsContracts
|
|||||||
|
|
||||||
|
|
||||||
List<ReportSalesSalonViewModel> GetSalesSalons(ReportBindingModel model);
|
List<ReportSalesSalonViewModel> GetSalesSalons(ReportBindingModel model);
|
||||||
|
|
||||||
List<ReportHeadsetMaterialViewModel> GetHeadsetMaterial(ReportBindingModel model);
|
List<ReportHeadsetMaterialViewModel> GetHeadsetMaterial(ReportBindingModel model);
|
||||||
|
|
||||||
|
|
||||||
List<ReportFurnitureHeadsetModuleViewModel> GetLessonTask(ReportBindingModel model);
|
List<ReportFurnitureHeadsetModuleViewModel> GetHeadsetModuleTask(ReportBindingModel model);
|
||||||
|
|
||||||
|
|
||||||
void SaveInterestLessonToWordFile(ReportBindingModel model);
|
void SaveSalesSalonHeadsetModuleToWordFile(ReportBindingModel model);
|
||||||
|
|
||||||
|
|
||||||
void SaveInterestLessonToExcelFile(ReportBindingModel model);
|
void SaveSalesSalonHeadsetModuleToExcelFile(ReportBindingModel model);
|
||||||
|
|
||||||
|
|
||||||
void SaveInterestsToPdfFile(ReportBindingModel model);
|
void SaveSalesSalonsToPdfFile(ReportBindingModel model);
|
||||||
|
|
||||||
void SaveHeadsetMaterialToWordFile(ReportBindingModel model);
|
void SaveHeadsetMaterialToWordFile(ReportBindingModel model);
|
||||||
|
|
||||||
@ -35,5 +36,7 @@ namespace FurnitureContracts.BusinessLogicsContracts
|
|||||||
|
|
||||||
|
|
||||||
void SaveFurnitureHeadsetModuleToPdfFile(ReportBindingModel model);
|
void SaveFurnitureHeadsetModuleToPdfFile(ReportBindingModel model);
|
||||||
}
|
|
||||||
|
void SaveOrdersHeadsetToPdfFile(ReportBindingModel model);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,5 +12,8 @@ namespace FurnitureContracts.SearchModels
|
|||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
public int? ManagerId { get; set; }
|
public int? ManagerId { get; set; }
|
||||||
public string? Size { get; set; }
|
public string? Size { get; set; }
|
||||||
}
|
public DateTime? DateFrom { get; set; }
|
||||||
|
|
||||||
|
public DateTime? DateTo { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,10 @@ namespace FurnitureContracts.ViewModel
|
|||||||
public string? Title { get; set; } = string.Empty;
|
public string? Title { get; set; } = string.Empty;
|
||||||
[DisplayName("Цена")]
|
[DisplayName("Цена")]
|
||||||
public int Cost { get; set; }
|
public int Cost { get; set; }
|
||||||
|
[DisplayName("Дата создания")]
|
||||||
|
public DateTime DateCreate { get; set; }
|
||||||
|
|
||||||
[DisplayName("Размер")]
|
[DisplayName("Размер")]
|
||||||
public string Size { get; set; } = string.Empty;
|
public string Size { get; set; } = string.Empty;
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int HeadsetModuleId { get; set; }
|
public int HeadsetModuleId { get; set; }
|
||||||
|
@ -14,6 +14,7 @@ namespace FurnitureContracts.ViewModel
|
|||||||
[DisplayName("Название")]
|
[DisplayName("Название")]
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
|
||||||
[DisplayName("Дата заказа")]
|
[DisplayName("Дата заказа")]
|
||||||
public DateTime Date { get; set; }
|
public DateTime Date { get; set; }
|
||||||
|
|
||||||
|
@ -12,5 +12,6 @@ namespace FurnitureContracts.ViewModel
|
|||||||
public string OrderTitle { get; set; } = string.Empty;
|
public string OrderTitle { get; set; } = string.Empty;
|
||||||
public DateTime DateCreateOrder { get; set; }
|
public DateTime DateCreateOrder { get; set; }
|
||||||
public string HeadsetTitle { get; set; } = string.Empty;
|
public string HeadsetTitle { get; set; } = string.Empty;
|
||||||
}
|
public DateTime DateCreateHeadset { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ namespace FurnitureFactoryBusinessLogic.BusinessLogic
|
|||||||
{
|
{
|
||||||
public class ReportLogic : IReportLogic
|
public class ReportLogic : IReportLogic
|
||||||
{
|
{
|
||||||
private readonly ISalesSalonsStorage _interestStorage;
|
private readonly ISalesSalonsStorage _salesSalonStorage;
|
||||||
private readonly IMaterialStorage _materialStorage;
|
private readonly IMaterialStorage _materialStorage;
|
||||||
private readonly IOrdersStorage _orderStorage;
|
private readonly IOrdersStorage _orderStorage;
|
||||||
private readonly IHeadsetStorage _headsetStorage;
|
private readonly IHeadsetStorage _headsetStorage;
|
||||||
@ -37,7 +37,7 @@ namespace FurnitureFactoryBusinessLogic.BusinessLogic
|
|||||||
|
|
||||||
public ReportLogic(ISalesSalonsStorage salessalonStorage, IMaterialStorage materialStorage, IOrdersStorage orderStorage, IHeadsetStorage headsetStorage, IHeadsetModuleStorage headsetmoduleStorage, IFurnitureStorage furnitureStorage, AbstractSaveToExcelMaster saveToExcelMaster, AbstractSaveToWordMaster saveToWordMaster, AbstractSaveToPdfMaster saveToPdfMaster, AbstractSaveToExcelManager saveToExcelManager, AbstractSaveToWordManager saveToWordManager, AbstractSaveToPdfManager saveToPdfManager)
|
public ReportLogic(ISalesSalonsStorage salessalonStorage, IMaterialStorage materialStorage, IOrdersStorage orderStorage, IHeadsetStorage headsetStorage, IHeadsetModuleStorage headsetmoduleStorage, IFurnitureStorage furnitureStorage, AbstractSaveToExcelMaster saveToExcelMaster, AbstractSaveToWordMaster saveToWordMaster, AbstractSaveToPdfMaster saveToPdfMaster, AbstractSaveToExcelManager saveToExcelManager, AbstractSaveToWordManager saveToWordManager, AbstractSaveToPdfManager saveToPdfManager)
|
||||||
{
|
{
|
||||||
_interestStorage = salessalonStorage;
|
_salesSalonStorage = salessalonStorage;
|
||||||
_materialStorage = materialStorage;
|
_materialStorage = materialStorage;
|
||||||
_orderStorage = orderStorage;
|
_orderStorage = orderStorage;
|
||||||
_headsetStorage = headsetStorage;
|
_headsetStorage = headsetStorage;
|
||||||
@ -121,7 +121,7 @@ namespace FurnitureFactoryBusinessLogic.BusinessLogic
|
|||||||
|
|
||||||
public List<ReportSalesSalonViewModel> GetSalesSalons(ReportBindingModel model)
|
public List<ReportSalesSalonViewModel> GetSalesSalons(ReportBindingModel model)
|
||||||
{
|
{
|
||||||
var salessalons = _interestStorage.GetFilteredList(new SalesSalonsSearchModel
|
var salessalons = _salesSalonStorage.GetFilteredList(new SalesSalonsSearchModel
|
||||||
{
|
{
|
||||||
ManagerId = model.ManagerId
|
ManagerId = model.ManagerId
|
||||||
});
|
});
|
||||||
@ -163,7 +163,55 @@ namespace FurnitureFactoryBusinessLogic.BusinessLogic
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ReportFurnitureHeadsetModuleViewModel> GetLessonTask(ReportBindingModel model)
|
public List<ReportSalesSalonViewModel> GetSalesSalonsTask(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
var interests = _salesSalonStorage.GetFilteredList(new SalesSalonsSearchModel
|
||||||
|
{
|
||||||
|
ManagerId = model.ManagerId
|
||||||
|
});
|
||||||
|
var orders = _orderStorage.GetFilteredList(new OrderSearchModel
|
||||||
|
{
|
||||||
|
ManagerId = model.ManagerId,
|
||||||
|
DateFrom = model.DateFrom,
|
||||||
|
DateTo = model.DateTo
|
||||||
|
});
|
||||||
|
var headsets = _headsetStorage.GetFilteredList(new HeadsetSearchModel
|
||||||
|
{
|
||||||
|
ManagerId = model.ManagerId,
|
||||||
|
DateFrom = model.DateFrom,
|
||||||
|
DateTo = model.DateTo
|
||||||
|
});
|
||||||
|
var list = new List<ReportSalesSalonViewModel>();
|
||||||
|
foreach (OrdersViewModel order in orders)
|
||||||
|
{
|
||||||
|
|
||||||
|
foreach (HeadsetViewModel headset in headsets)
|
||||||
|
{
|
||||||
|
|
||||||
|
foreach (int interestOrder in order.OrdersSalesSalons.Keys)
|
||||||
|
{
|
||||||
|
if (headset.HeadsetSalesSalons.ContainsKey(interestOrder))
|
||||||
|
{
|
||||||
|
list.Add(new ReportSalesSalonViewModel
|
||||||
|
{
|
||||||
|
SalesSalonTitle = interests.FirstOrDefault(x => x.Id == interestOrder).ToString(),
|
||||||
|
OrderTitle = order.Title,
|
||||||
|
DateCreateOrder = order.Date,
|
||||||
|
HeadsetTitle = headset.Title,
|
||||||
|
DateCreateHeadset = headset.DateCreate
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ReportFurnitureHeadsetModuleViewModel> GetHeadsetModuleTask(ReportBindingModel model)
|
||||||
{
|
{
|
||||||
|
|
||||||
var headsetmodules = _headsetmoduleStorage.GetFilteredList(new HeadsetModuleSearchModel
|
var headsetmodules = _headsetmoduleStorage.GetFilteredList(new HeadsetModuleSearchModel
|
||||||
@ -206,6 +254,7 @@ namespace FurnitureFactoryBusinessLogic.BusinessLogic
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void SaveHeadsetMaterialToExcelFile(ReportBindingModel model)
|
public void SaveHeadsetMaterialToExcelFile(ReportBindingModel model)
|
||||||
{
|
{
|
||||||
_saveToExcelMaster.CreateReport(new ExcelInfoMaster
|
_saveToExcelMaster.CreateReport(new ExcelInfoMaster
|
||||||
@ -226,7 +275,7 @@ namespace FurnitureFactoryBusinessLogic.BusinessLogic
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveInterestLessonToExcelFile(ReportBindingModel model)
|
public void SaveSalesSalonHeadsetModuleToExcelFile(ReportBindingModel model)
|
||||||
{
|
{
|
||||||
_saveToExcelManager.CreateReport(new ExcelInfoManager
|
_saveToExcelManager.CreateReport(new ExcelInfoManager
|
||||||
{
|
{
|
||||||
@ -236,7 +285,7 @@ namespace FurnitureFactoryBusinessLogic.BusinessLogic
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveInterestLessonToWordFile(ReportBindingModel model)
|
public void SaveSalesSalonHeadsetModuleToWordFile(ReportBindingModel model)
|
||||||
{
|
{
|
||||||
_saveToWordManager.CreateDoc(new WordInfoManager
|
_saveToWordManager.CreateDoc(new WordInfoManager
|
||||||
{
|
{
|
||||||
@ -246,7 +295,7 @@ namespace FurnitureFactoryBusinessLogic.BusinessLogic
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveInterestsToPdfFile(ReportBindingModel model)
|
public void SaveSalesSalonsToPdfFile(ReportBindingModel model)
|
||||||
{
|
{
|
||||||
_saveToPdfManager.CreateDoc(new PdfInfoManager
|
_saveToPdfManager.CreateDoc(new PdfInfoManager
|
||||||
{
|
{
|
||||||
@ -264,8 +313,21 @@ namespace FurnitureFactoryBusinessLogic.BusinessLogic
|
|||||||
Title = "Список модулей гарнитур и мебели со сохожими материалами",
|
Title = "Список модулей гарнитур и мебели со сохожими материалами",
|
||||||
DateFrom = DateTime.SpecifyKind(model.DateFrom!.Value, DateTimeKind.Utc),
|
DateFrom = DateTime.SpecifyKind(model.DateFrom!.Value, DateTimeKind.Utc),
|
||||||
DateTo = DateTime.SpecifyKind(model.DateTo!.Value, DateTimeKind.Utc),
|
DateTo = DateTime.SpecifyKind(model.DateTo!.Value, DateTimeKind.Utc),
|
||||||
FurnitureHeadsetModule = GetLessonTask(model)
|
FurnitureHeadsetModule = GetHeadsetModuleTask(model)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public void SaveOrdersHeadsetToPdfFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
_saveToPdfManager.CreateDoc(new PdfInfoManager
|
||||||
|
{
|
||||||
|
FileName = model.FileName,
|
||||||
|
Title = "Список заказов и гарнитур со схожими материалами",
|
||||||
|
DateFrom = DateTime.SpecifyKind(model.DateFrom!.Value, DateTimeKind.Utc),
|
||||||
|
DateTo = DateTime.SpecifyKind(model.DateTo!.Value, DateTimeKind.Utc),
|
||||||
|
SalesSalons = GetSalesSalonsTask(model)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ namespace FurnitureFactoryBusinessLogic.BusinessLogic
|
|||||||
{
|
{
|
||||||
throw new ArgumentNullException("Неверно задан идентификатор менеджера", nameof(model.ManagerId));
|
throw new ArgumentNullException("Неверно задан идентификатор менеджера", nameof(model.ManagerId));
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Interest. Name:{Name}.Address{Address}.ManagerId:{ManagerId}. Id: {Id}", model.Name, model.Address, model.ManagerId, model.Id);
|
_logger.LogInformation("SalesSalon. Name:{Name}.Address{Address}.ManagerId:{ManagerId}. Id: {Id}", model.Name, model.Address, model.ManagerId, model.Id);
|
||||||
var element = _salesSalonStorage.GetElement(new SalesSalonsSearchModel
|
var element = _salesSalonStorage.GetElement(new SalesSalonsSearchModel
|
||||||
{
|
{
|
||||||
Name = model.Name,
|
Name = model.Name,
|
||||||
|
@ -13,9 +13,10 @@ namespace FurnitureFactoryBusinessLogic.OfficePackage.Implements
|
|||||||
public void CreateDoc(PdfInfoManager info)
|
public void CreateDoc(PdfInfoManager info)
|
||||||
{
|
{
|
||||||
CreatePdf(info);
|
CreatePdf(info);
|
||||||
CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
||||||
|
CreateParagraph(new PdfParagraph { Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
||||||
|
|
||||||
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "3cm", "6cm", "6cm" });
|
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "3cm", "6cm", "6cm" });
|
||||||
|
|
||||||
CreateRow(new PdfRowParameters
|
CreateRow(new PdfRowParameters
|
||||||
{
|
{
|
||||||
|
@ -13,6 +13,6 @@ namespace FurnitureFactoryBusinessLogic.OfficePackage.HelperModels
|
|||||||
|
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
|
|
||||||
public List<ReportHeadsetMaterialViewModel> HeadsetMaterials { get; set; }
|
public List<ReportHeadsetMaterialViewModel> HeadsetMaterials { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,9 +13,11 @@ namespace FurnitureFactoryBusinessLogic.OfficePackage.HelperModels
|
|||||||
|
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
|
|
||||||
public DateTime Date { get; set; }
|
public DateTime DateFrom { get; set; }
|
||||||
|
|
||||||
public List<ReportSalesSalonViewModel> SalesSalons { get; set; } = new();
|
public DateTime DateTo { get; set; }
|
||||||
|
|
||||||
|
public List<ReportSalesSalonViewModel> SalesSalons { get; set; } = new();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ namespace FurnitureFactoryDataBaseImplements.Implements
|
|||||||
}
|
}
|
||||||
order.Update(model);
|
order.Update(model);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
order.UpdateInterests(context, model);
|
order.UpdateSalesSalons(context, model);
|
||||||
transaction.Commit();
|
transaction.Commit();
|
||||||
return order.GetViewModel;
|
return order.GetViewModel;
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ namespace FurnitureFactoryDataBaseImplement.Models
|
|||||||
OrdersSalesSalons = OrdersSalesSalons
|
OrdersSalesSalons = OrdersSalesSalons
|
||||||
};
|
};
|
||||||
|
|
||||||
public void UpdateInterests(FurnitureDataBase context, OrdersBindingModel model)
|
public void UpdateSalesSalons(FurnitureDataBase context, OrdersBindingModel model)
|
||||||
{
|
{
|
||||||
var ordersSalesSalons = context.OrdersSalesSalons.Where(rec => rec.OrdersId == model.Id).ToList();
|
var ordersSalesSalons = context.OrdersSalesSalons.Where(rec => rec.OrdersId == model.Id).ToList();
|
||||||
if (ordersSalesSalons != null && OrdersSalesSalons.Count > 0)
|
if (ordersSalesSalons != null && OrdersSalesSalons.Count > 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user