diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/ReportLogic.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/ReportLogic.cs index 16e5315..bffebd2 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/ReportLogic.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/ReportLogic.cs @@ -82,7 +82,8 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic Id = x.Id, DateCreate = x.DateCreate, ManufactureName = x.ManufactureName, - Sum = x.Sum + Sum = x.Sum, + OrderStatus = x.Status.ToString() }) .ToList(); } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToPdf.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToPdf.cs index 0da5b88..2bdb97d 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToPdf.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToPdf.cs @@ -29,11 +29,11 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage ParagraphAlignment = PdfParagraphAlignmentType.Center }); - CreateTable(new List { "2cm", "3cm", "6cm", "3cm" }); + CreateTable(new List { "2cm", "3cm", "6cm", "3cm", "3cm" }); CreateRow(new PdfRowParameters { - Texts = new List { "Номер", "Дата заказа", "Изделие", "Сумма" }, + Texts = new List { "Номер", "Дата заказа", "Изделие", "Сумма", "Статус заказа" }, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); @@ -42,7 +42,7 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage { CreateRow(new PdfRowParameters { - Texts = new List { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.ManufactureName, order.Sum.ToString() }, + Texts = new List { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.ManufactureName, order.Sum.ToString(), order.OrderStatus }, Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Left }); diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToWord.cs index 5d0f643..cd69068 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -31,7 +31,8 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage { CreateParagraph(new WordParagraph { - Texts = new List<(string, WordTextProperties)> { (workPiece.WorkPieceName, new WordTextProperties { Size = "24", }) }, + Texts = new List<(string, WordTextProperties)> { (workPiece.WorkPieceName + " ", new WordTextProperties { Bold = true, Size = "24", }), + (workPiece.Cost.ToString(), new WordTextProperties { Size = "24" }) }, TextProperties = new WordTextProperties { Size = "24", diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ReportOrdersViewModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ReportOrdersViewModel.cs index d0e327d..b8b6e0d 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ReportOrdersViewModel.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ReportOrdersViewModel.cs @@ -15,5 +15,7 @@ namespace BlacksmithWorkshopContracts.ViewModels public string ManufactureName { get; set; } = string.Empty; public double Sum { get; set; } + + public string OrderStatus { get; set; } } } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Implements/OrderStorage.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Implements/OrderStorage.cs index 8dfa776..8d9b9ee 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Implements/OrderStorage.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Implements/OrderStorage.cs @@ -17,6 +17,7 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements public OrderViewModel? Delete(OrderBindingModel model) { using var context = new BlacksmithWorkshopDatabase(); + var element = context.Orders .FirstOrDefault(rec => rec.Id == model.Id); @@ -41,31 +42,45 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements using var context = new BlacksmithWorkshopDatabase(); return context.Orders + .Include(x => x.Manufacture) .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id) ?.GetViewModel; } public List GetFilteredList(OrderSearchModel model) { - if (!model.Id.HasValue) + if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue) { return new(); } using var context = new BlacksmithWorkshopDatabase(); - return context.Orders - .Where(x => x.Id == model.Id) + if(!model.Id.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue) + { + return context.Orders + .Include(x => x.Manufacture) + .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo) .Select(x => x.GetViewModel) .ToList(); + } + + return context.Orders + .Include(x => x.Manufacture) + .Where(x => x.Id == model.Id) + .Select(x => x.GetViewModel) + .ToList(); } private static OrderViewModel GetViewModel(Order order) { var viewModel = order.GetViewModel; + using var context = new BlacksmithWorkshopDatabase(); + var element = context.Manufactures .FirstOrDefault(x => x.Id == order.ManufactureId); + viewModel.ManufactureName = element.ManufactureName; return viewModel; @@ -76,18 +91,18 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements using var context = new BlacksmithWorkshopDatabase(); return context.Orders - .Select(x => new OrderViewModel - { - Id = x.Id, - ManufactureId = x.ManufactureId, - Count = x.Count, - Sum = x.Sum, - Status = x.Status, - DateCreate = x.DateCreate, - DateImplement = x.DateImplement, - ManufactureName = x.Manufacture.ManufactureName - }) - .ToList(); + .Select(x => new OrderViewModel + { + Id = x.Id, + ManufactureId = x.ManufactureId, + Count = x.Count, + Sum = x.Sum, + Status = x.Status, + DateCreate = x.DateCreate, + DateImplement = x.DateImplement, + ManufactureName = x.Manufacture.ManufactureName + }) + .ToList(); } public OrderViewModel? Insert(OrderBindingModel model) @@ -100,6 +115,7 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements } using var context = new BlacksmithWorkshopDatabase(); + context.Orders.Add(newOrder); context.SaveChanges(); diff --git a/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Implements/OrderStorage.cs b/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Implements/OrderStorage.cs index 250a67e..867356e 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Implements/OrderStorage.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Implements/OrderStorage.cs @@ -28,9 +28,11 @@ namespace BlacksmithWorkshopFileImplement.Implements public List GetFilteredList(OrderSearchModel model) { - if (!model.Id.HasValue) + if (!model.Id.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue) { - return new(); + return source.Orders.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo) + .Select(x => GetViewModel(x)) + .ToList(); } return source.Orders.Where(x => x.Id == model.Id).Select(x => GetViewModel(x)).ToList();