правки но какой-то косяк
This commit is contained in:
parent
8a085d3f33
commit
01d41f519d
@ -33,97 +33,113 @@
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
textBoxCount = new TextBox();
|
||||
labelProduct = new Label();
|
||||
labelWood = new Label();
|
||||
labelSum = new Label();
|
||||
textBoxSum = new TextBox();
|
||||
labelClient = new Label();
|
||||
comboBoxClient = new ComboBox();
|
||||
labelClient = new Label();
|
||||
comboBoxClient = new ComboBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
labelCount.AutoSize = true;
|
||||
labelCount.Location = new Point(14, 42);
|
||||
labelCount.Margin = new Padding(4, 0, 4, 0);
|
||||
labelCount.Location = new Point(20, 102);
|
||||
labelCount.Name = "labelCount";
|
||||
labelCount.Size = new Size(75, 15);
|
||||
labelCount.TabIndex = 2;
|
||||
labelCount.Text = "Количество:";
|
||||
labelCount.Size = new Size(97, 20);
|
||||
labelCount.TabIndex = 1;
|
||||
labelCount.Text = "Количество :";
|
||||
//
|
||||
// comboBoxWood
|
||||
//
|
||||
comboBoxWood.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxWood.FormattingEnabled = true;
|
||||
comboBoxWood.Location = new Point(102, 7);
|
||||
comboBoxWood.Margin = new Padding(4, 3, 4, 3);
|
||||
comboBoxWood.Location = new Point(124, 12);
|
||||
comboBoxWood.Name = "comboBoxWood";
|
||||
comboBoxWood.Size = new Size(252, 23);
|
||||
comboBoxWood.TabIndex = 1;
|
||||
comboBoxWood.Size = new Size(300, 28);
|
||||
comboBoxWood.TabIndex = 4;
|
||||
comboBoxWood.SelectedIndexChanged += comboBoxWood_SelectedIndexChanged;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(255, 98);
|
||||
buttonCancel.Margin = new Padding(4, 3, 4, 3);
|
||||
buttonCancel.Location = new Point(312, 194);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(88, 27);
|
||||
buttonCancel.TabIndex = 7;
|
||||
buttonCancel.Size = new Size(94, 36);
|
||||
buttonCancel.TabIndex = 8;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(161, 98);
|
||||
buttonSave.Margin = new Padding(4, 3, 4, 3);
|
||||
buttonSave.Location = new Point(195, 194);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(88, 27);
|
||||
buttonSave.TabIndex = 6;
|
||||
buttonSave.Size = new Size(94, 36);
|
||||
buttonSave.TabIndex = 7;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += ButtonSave_Click;
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
textBoxCount.Location = new Point(102, 38);
|
||||
textBoxCount.Margin = new Padding(4, 3, 4, 3);
|
||||
textBoxCount.Location = new Point(124, 99);
|
||||
textBoxCount.Name = "textBoxCount";
|
||||
textBoxCount.Size = new Size(252, 23);
|
||||
textBoxCount.TabIndex = 3;
|
||||
textBoxCount.Size = new Size(300, 27);
|
||||
textBoxCount.TabIndex = 5;
|
||||
textBoxCount.TextChanged += textBoxCount_TextChanged;
|
||||
//
|
||||
// labelProduct
|
||||
// labelWood
|
||||
//
|
||||
labelProduct.AutoSize = true;
|
||||
labelProduct.Location = new Point(14, 10);
|
||||
labelProduct.Margin = new Padding(4, 0, 4, 0);
|
||||
labelProduct.Name = "labelProduct";
|
||||
labelProduct.Size = new Size(56, 15);
|
||||
labelProduct.TabIndex = 0;
|
||||
labelProduct.Text = "Изделие:";
|
||||
labelWood.AutoSize = true;
|
||||
labelWood.Location = new Point(20, 15);
|
||||
labelWood.Name = "labelWood";
|
||||
labelWood.Size = new Size(71, 20);
|
||||
labelWood.TabIndex = 3;
|
||||
labelWood.Text = "Изделие:";
|
||||
//
|
||||
// labelSum
|
||||
//
|
||||
labelSum.AutoSize = true;
|
||||
labelSum.Location = new Point(14, 72);
|
||||
labelSum.Margin = new Padding(4, 0, 4, 0);
|
||||
labelSum.Location = new Point(20, 145);
|
||||
labelSum.Name = "labelSum";
|
||||
labelSum.Size = new Size(48, 15);
|
||||
labelSum.TabIndex = 4;
|
||||
labelSum.Text = "Сумма:";
|
||||
labelSum.Size = new Size(62, 20);
|
||||
labelSum.TabIndex = 2;
|
||||
labelSum.Text = "Сумма :";
|
||||
//
|
||||
// textBoxSum
|
||||
//
|
||||
textBoxSum.Location = new Point(102, 68);
|
||||
textBoxSum.Margin = new Padding(4, 3, 4, 3);
|
||||
textBoxSum.Location = new Point(124, 145);
|
||||
textBoxSum.Name = "textBoxSum";
|
||||
textBoxSum.ReadOnly = true;
|
||||
textBoxSum.Size = new Size(252, 23);
|
||||
textBoxSum.TabIndex = 5;
|
||||
textBoxSum.Size = new Size(300, 27);
|
||||
textBoxSum.TabIndex = 6;
|
||||
//
|
||||
// labelClient
|
||||
//
|
||||
labelClient.AutoSize = true;
|
||||
labelClient.Location = new Point(20, 59);
|
||||
labelClient.Name = "labelClient";
|
||||
labelClient.Size = new Size(61, 20);
|
||||
labelClient.TabIndex = 9;
|
||||
labelClient.Text = "Клиент:";
|
||||
//
|
||||
// comboBoxClient
|
||||
//
|
||||
comboBoxClient.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxClient.FormattingEnabled = true;
|
||||
comboBoxClient.Location = new Point(124, 56);
|
||||
comboBoxClient.Name = "comboBoxClient";
|
||||
comboBoxClient.Size = new Size(300, 28);
|
||||
comboBoxClient.TabIndex = 10;
|
||||
//
|
||||
// FormCreateOrder
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(371, 136);
|
||||
ClientSize = new Size(452, 281);
|
||||
Controls.Add(comboBoxClient);
|
||||
Controls.Add(labelClient);
|
||||
Controls.Add(labelSum);
|
||||
Controls.Add(textBoxSum);
|
||||
Controls.Add(labelCount);
|
||||
@ -131,7 +147,7 @@
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(textBoxCount);
|
||||
Controls.Add(labelProduct);
|
||||
Controls.Add(labelWood);
|
||||
Margin = new Padding(4, 3, 4, 3);
|
||||
Name = "FormCreateOrder";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
@ -147,8 +163,10 @@
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
private TextBox textBoxCount;
|
||||
private Label labelProduct;
|
||||
private Label labelWood;
|
||||
private Label labelSum;
|
||||
private TextBox textBoxSum;
|
||||
private Label labelClient;
|
||||
private ComboBox comboBoxClient;
|
||||
}
|
||||
}
|
@ -11,12 +11,15 @@ namespace CarpentryWorkshopView
|
||||
private readonly ILogger _logger;
|
||||
private readonly IWoodLogic _logicW;
|
||||
private readonly IOrderLogic _logicO;
|
||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, IWoodLogic logicP, IOrderLogic logicO)
|
||||
private readonly IClientLogic _logicC;
|
||||
public FormCreateOrder(ILogger<FormCreateOrder> logger,
|
||||
IWoodLogic logicP, IOrderLogic logicO, IClientLogic logicC)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logicW = logicP;
|
||||
_logicO = logicO;
|
||||
_logicC = logicC;
|
||||
}
|
||||
private void FormCreateOrder_Load(object sender, EventArgs e)
|
||||
{
|
||||
@ -39,6 +42,23 @@ namespace CarpentryWorkshopView
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
_logger.LogInformation("Loading clients for order");
|
||||
try
|
||||
{
|
||||
var clientList = _logicC.ReadList(null);
|
||||
if (clientList != null)
|
||||
{
|
||||
comboBoxClient.DisplayMember = "ClientFIO";
|
||||
comboBoxClient.ValueMember = "Id";
|
||||
comboBoxClient.DataSource = clientList;
|
||||
comboBoxClient.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error during loading clients for order");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void CalcSum()
|
||||
{
|
||||
@ -79,12 +99,18 @@ namespace CarpentryWorkshopView
|
||||
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (comboBoxClient.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите клиента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Создание заказа");
|
||||
try
|
||||
{
|
||||
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
||||
{
|
||||
WoodId = Convert.ToInt32(comboBoxWood.SelectedValue),
|
||||
ClientId = Convert.ToInt32(comboBoxClient.SelectedValue),
|
||||
Count = Convert.ToInt32(textBoxCount.Text),
|
||||
Sum = Convert.ToDouble(textBoxSum.Text)
|
||||
});
|
||||
|
@ -98,6 +98,10 @@ namespace CarpentryWorkshopBusinessLogic.BusinessLogics
|
||||
{
|
||||
throw new ArgumentNullException("Нет логина(почты) клиента", nameof(model.Email));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
throw new ArgumentNullException("Нет пароля клиента", nameof(model.Password));
|
||||
}
|
||||
_logger.LogInformation("Client. Id: {Id}, FIO: {fio}, email: {email}", model.Id, model.ClientFIO, model.Email);
|
||||
var element = _clientStorage.GetElement(new ClientSearchModel
|
||||
{
|
||||
|
@ -81,8 +81,7 @@ namespace CarpentryWorkshopBusinessLogic.BusinessLogics
|
||||
return ChangeStatus(model, OrderStatus.Выдан);
|
||||
}
|
||||
|
||||
private void CheckModel(OrderBindingModel model, bool withParams =
|
||||
true)
|
||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -96,6 +95,14 @@ true)
|
||||
{
|
||||
throw new ArgumentNullException("Цена заказа должна быть больше 0", nameof(model.Sum));
|
||||
}
|
||||
if (model.WoodId <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Некорректный идентификатор изделия", nameof(model.WoodId));
|
||||
}
|
||||
if (model.ClientId <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Некорректный идентификатор клиента", nameof(model.ClientId));
|
||||
}
|
||||
if (model.Count <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Количество элементов в заказе должно быть больше 0", nameof(model.Count));
|
||||
|
@ -1,3 +1,5 @@
|
||||
using CarpentryWorkshopClientApp;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
@ -5,6 +7,8 @@ builder.Services.AddControllersWithViews();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
APIClient.Connect(builder.Configuration);
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
|
@ -6,6 +6,8 @@ namespace CarpentryWorkshopDataModels.Models
|
||||
{
|
||||
int WoodId { get; }
|
||||
|
||||
int ClientId { get; }
|
||||
|
||||
int Count { get; }
|
||||
|
||||
double Sum { get; }
|
||||
|
@ -35,6 +35,7 @@ namespace CarpentryWorkshopDatabaseImplement.Models
|
||||
return new Order
|
||||
{
|
||||
WoodId = model.WoodId,
|
||||
ClientId = model.ClientId,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
@ -57,6 +58,7 @@ namespace CarpentryWorkshopDatabaseImplement.Models
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
WoodId = WoodId,
|
||||
ClientId = ClientId,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
DateCreate = DateCreate,
|
||||
|
@ -15,20 +15,18 @@ namespace CarpentryWorkshopFileImplement.Implements
|
||||
}
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
return source.Orders
|
||||
.Select(x => AccessWoodStorage(x.GetViewModel))
|
||||
.ToList();
|
||||
return source.Orders.Select(x => GetViewModel(x)).ToList();
|
||||
}
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue)
|
||||
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return source.Orders
|
||||
.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo)
|
||||
.Select(x => AccessWoodStorage(x.GetViewModel))
|
||||
.ToList();
|
||||
.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo || x.ClientId == model.ClientId)
|
||||
.Select(x => GetViewModel(x))
|
||||
.ToList();
|
||||
}
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
@ -36,8 +34,8 @@ namespace CarpentryWorkshopFileImplement.Implements
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return AccessWoodStorage(source.Orders
|
||||
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel);
|
||||
return GetViewModel(source.Orders
|
||||
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id)));
|
||||
}
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
{
|
||||
@ -49,7 +47,7 @@ namespace CarpentryWorkshopFileImplement.Implements
|
||||
}
|
||||
source.Orders.Add(newOrder);
|
||||
source.SaveOrders();
|
||||
return AccessWoodStorage(newOrder.GetViewModel);
|
||||
return GetViewModel(newOrder);
|
||||
}
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
{
|
||||
@ -60,33 +58,33 @@ namespace CarpentryWorkshopFileImplement.Implements
|
||||
}
|
||||
order.Update(model);
|
||||
source.SaveOrders();
|
||||
return AccessWoodStorage(order.GetViewModel);
|
||||
return GetViewModel(order);
|
||||
}
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
var element = source.Orders.FirstOrDefault(x => x.Id ==
|
||||
model.Id);
|
||||
if (element != null)
|
||||
var order = source.Orders.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (order == null)
|
||||
{
|
||||
source.Orders.Remove(element);
|
||||
source.SaveOrders();
|
||||
return AccessWoodStorage(element.GetViewModel);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public OrderViewModel AccessWoodStorage(OrderViewModel model)
|
||||
{
|
||||
if (model == null)
|
||||
return null;
|
||||
foreach (var wood in source.Woods)
|
||||
{
|
||||
if (wood.Id == model.WoodId)
|
||||
{
|
||||
model.WoodName = wood.WoodName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return model;
|
||||
source.Orders.Remove(order);
|
||||
source.SaveOrders();
|
||||
return GetViewModel(order);
|
||||
}
|
||||
private OrderViewModel GetViewModel(Order order)
|
||||
{
|
||||
var viewModel = order.GetViewModel;
|
||||
var wood = source.Woods.FirstOrDefault(x => x.Id == order.WoodId);
|
||||
if (wood != null)
|
||||
{
|
||||
viewModel.WoodName = wood.WoodName;
|
||||
}
|
||||
var client = source.Clients.FirstOrDefault(x => x.Id == order.ClientId);
|
||||
if (client != null)
|
||||
{
|
||||
viewModel.ClientFIO = client.ClientFIO;
|
||||
}
|
||||
return viewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
using CarpentryWorkshopContracts.ViewModels;
|
||||
using CarpentryWorkshopDataModels.Enums;
|
||||
using CarpentryWorkshopDataModels.Models;
|
||||
using System.Reflection;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace CarpentryWorkshopFileImplement.Models
|
||||
@ -10,6 +11,7 @@ namespace CarpentryWorkshopFileImplement.Models
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public int WoodId { get; private set; }
|
||||
public int ClientId { get; private set; }
|
||||
public int Count { get; private set; }
|
||||
public double Sum { get; private set; }
|
||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
||||
@ -25,6 +27,7 @@ namespace CarpentryWorkshopFileImplement.Models
|
||||
{
|
||||
Id = model.Id,
|
||||
WoodId = model.WoodId,
|
||||
ClientId = model.ClientId,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
@ -42,6 +45,7 @@ namespace CarpentryWorkshopFileImplement.Models
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
WoodId = Convert.ToInt32(element.Element("WoodId")!.Value),
|
||||
ClientId = Convert.ToInt32(element.Element("ClientId")!.Value),
|
||||
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
||||
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
||||
Status = (OrderStatus)Convert.ToInt32(element.Element("Status").Value),
|
||||
@ -57,6 +61,7 @@ namespace CarpentryWorkshopFileImplement.Models
|
||||
}
|
||||
Id = model.Id;
|
||||
WoodId = model.WoodId;
|
||||
ClientId = model.ClientId;
|
||||
Count = model.Count;
|
||||
Sum = model.Sum;
|
||||
Status = model.Status;
|
||||
@ -67,6 +72,7 @@ namespace CarpentryWorkshopFileImplement.Models
|
||||
{
|
||||
Id = Id,
|
||||
WoodId = WoodId,
|
||||
ClientId = ClientId,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
@ -76,6 +82,7 @@ namespace CarpentryWorkshopFileImplement.Models
|
||||
public XElement GetXElement => new("Order",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("WoodId", WoodId),
|
||||
new XElement("ClientId", ClientId),
|
||||
new XElement("Count", Count),
|
||||
new XElement("Sum", Sum.ToString()),
|
||||
new XElement("Status", (int)Status),
|
||||
|
@ -18,36 +18,50 @@ namespace CarpentryWorkshopListImplement.Implements
|
||||
var result = new List<OrderViewModel>();
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
result.Add(AccessWoodStorage(order.GetViewModel));
|
||||
result.Add(GetViewModel(order));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
var result = new List<OrderViewModel>();
|
||||
if (model.Id == null)
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
foreach (var order in _source.Orders)
|
||||
if (model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||
{
|
||||
if (order.Id.Equals(model.Id) || model.DateFrom <= order.DateCreate && order.DateCreate <= model.DateTo)
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
result.Add(AccessWoodStorage(order.GetViewModel));
|
||||
if (order.Id == model.Id || model.DateFrom <= order.DateCreate && order.DateCreate <= model.DateTo)
|
||||
{
|
||||
result.Add(GetViewModel(order));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (model.ClientId.HasValue)
|
||||
{
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if (order.ClientId == model.ClientId)
|
||||
{
|
||||
result.Add(GetViewModel(order));
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
if (model.Id == null && !model.Id.HasValue)
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if ((model.Id != null && order.Id == model.Id) ||
|
||||
(model.Id.HasValue && order.Id == model.Id))
|
||||
if (
|
||||
(model.Id.HasValue && order.Id == model.Id)
|
||||
)
|
||||
{
|
||||
return order.GetViewModel;
|
||||
}
|
||||
@ -98,17 +112,26 @@ namespace CarpentryWorkshopListImplement.Implements
|
||||
return null;
|
||||
}
|
||||
|
||||
public OrderViewModel AccessWoodStorage(OrderViewModel model)
|
||||
private OrderViewModel GetViewModel(Order order)
|
||||
{
|
||||
var viewModel = order.GetViewModel;
|
||||
foreach (var wood in _source.Woods)
|
||||
{
|
||||
if (wood.Id == model.WoodId)
|
||||
if (wood.Id == order.WoodId)
|
||||
{
|
||||
model.WoodName = wood.WoodName;
|
||||
viewModel.WoodName = wood.WoodName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return model;
|
||||
foreach (var client in _source.Clients)
|
||||
{
|
||||
if (client.Id == order.ClientId)
|
||||
{
|
||||
viewModel.ClientFIO = client.ClientFIO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return viewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
using CarpentryWorkshopContracts.ViewModels;
|
||||
using CarpentryWorkshopDataModels.Enums;
|
||||
using CarpentryWorkshopDataModels.Models;
|
||||
using System.Reflection;
|
||||
|
||||
namespace CarpentryWorkshopListImplement.Models
|
||||
{
|
||||
@ -9,6 +10,7 @@ namespace CarpentryWorkshopListImplement.Models
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int WoodId { get; set; }
|
||||
public int ClientId { get; set; }
|
||||
public int Count { get; set; }
|
||||
public double Sum { get; set; }
|
||||
public OrderStatus Status { get; set; }
|
||||
@ -24,6 +26,7 @@ namespace CarpentryWorkshopListImplement.Models
|
||||
{
|
||||
Id = model.Id,
|
||||
WoodId = model.WoodId,
|
||||
ClientId = model.ClientId,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
@ -38,6 +41,7 @@ namespace CarpentryWorkshopListImplement.Models
|
||||
return;
|
||||
}
|
||||
WoodId = model.WoodId;
|
||||
ClientId = model.ClientId;
|
||||
Count = model.Count;
|
||||
Sum = model.Sum;
|
||||
Status = model.Status;
|
||||
@ -48,6 +52,7 @@ namespace CarpentryWorkshopListImplement.Models
|
||||
{
|
||||
Id = Id,
|
||||
WoodId = WoodId,
|
||||
ClientId = ClientId,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
|
Loading…
Reference in New Issue
Block a user