Мелкие правки.
This commit is contained in:
parent
c213555ba1
commit
1676bfd40a
@ -23,13 +23,16 @@ namespace BlacksmithWorkshop
|
||||
|
||||
private readonly IOrderLogic _logicO;
|
||||
|
||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, IManufactureLogic logicM, IOrderLogic logicO)
|
||||
private readonly IClientLogic _logicCl;
|
||||
|
||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, IManufactureLogic logicM, IOrderLogic logicO, IClientLogic logicCl)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logger = logger;
|
||||
_logicM = logicM;
|
||||
_logicO = logicO;
|
||||
_logicCl = logicCl;
|
||||
}
|
||||
|
||||
private void FormCreateOrder_Load(object sender, EventArgs e)
|
||||
@ -39,6 +42,7 @@ namespace BlacksmithWorkshop
|
||||
try
|
||||
{
|
||||
var list = _logicM.ReadList(null);
|
||||
var listClients = _logicCl.ReadList(null);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
@ -48,10 +52,17 @@ namespace BlacksmithWorkshop
|
||||
comboBoxManufacture.SelectedItem = null;
|
||||
}
|
||||
|
||||
if(listClients != null)
|
||||
{
|
||||
comboBoxClient.DisplayMember = "ClientFIO";
|
||||
comboBoxClient.ValueMember = "Id";
|
||||
comboBoxClient.DataSource = listClients;
|
||||
comboBoxClient.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки изделий для заказа");
|
||||
_logger.LogError(ex, "Ошибка загрузки изделий для заказа или списка клиентов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
@ -122,7 +122,12 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
throw new InvalidOperationException("Дата создания должна быть более ранней, нежели дата завершения");
|
||||
}
|
||||
|
||||
_logger.LogInformation("Order. OrderId:{Id}. Sun:{Sum}. ManufactureId:{Id}", model.Id, model.Sum, model.ManufactureId);
|
||||
if (model.ClientId < 0)
|
||||
{
|
||||
throw new ArgumentNullException("Некорректный идентификатор у клиента", nameof(model.ClientId));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Order. OrderId:{Id}. Sun:{Sum}. ClientId:{ClientId}. ManufactureId:{Id}", model.Id, model.Sum, model.ClientId, model.ManufactureId);
|
||||
}
|
||||
|
||||
//обновление статуса заказа
|
||||
|
@ -73,14 +73,27 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.Id.HasValue)
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Manufacture)
|
||||
.Include(x => x.Client)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.ClientId.HasValue)
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Manufacture)
|
||||
.Include(x => x.Client)
|
||||
.Where(x => x.ClientId == model.ClientId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
return context.Orders
|
||||
.Include(x => x.Manufacture)
|
||||
.Include(x => x.Client)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return new();
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user