Eliseev E.E. LabWork04_Hard #9

Closed
ElEgEv wants to merge 43 commits from LabWork04_Hard into LabWork03_Hard
6 changed files with 44 additions and 22 deletions
Showing only changes of commit 6938c31141 - Show all commits

View File

@ -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();
}

View File

@ -29,11 +29,11 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm" });
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "3cm" });
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Номер", "Дата заказа", "Изделие", "Сумма" },
Texts = new List<string> { "Номер", "Дата заказа", "Изделие", "Сумма", "Статус заказа" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
@ -42,7 +42,7 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.ManufactureName, order.Sum.ToString() },
Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.ManufactureName, order.Sum.ToString(), order.OrderStatus },
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});

View File

@ -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",

View File

@ -15,5 +15,7 @@ namespace BlacksmithWorkshopContracts.ViewModels
public string ManufactureName { get; set; } = string.Empty;
public double Sum { get; set; }
public string OrderStatus { get; set; }
}
}

View File

@ -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<OrderViewModel> 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();

View File

@ -28,9 +28,11 @@ namespace BlacksmithWorkshopFileImplement.Implements
public List<OrderViewModel> 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();