Compare commits
No commits in common. "7aa92dbb74177993780144be503b562cbdb1a484" and "bb74221578f917d9ed37b97071012ee3c4bd1393" have entirely different histories.
7aa92dbb74
...
bb74221578
@ -103,6 +103,7 @@ namespace LawFirmView
|
||||
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
||||
{
|
||||
DocumentId = Convert.ToInt32(comboBoxDocument.SelectedValue),
|
||||
DocumentName = comboBoxDocument.Text,
|
||||
Count = Convert.ToInt32(textBoxCount.Text),
|
||||
Sum = Convert.ToDouble(textBoxSum.Text)
|
||||
});
|
||||
|
@ -64,6 +64,7 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
{
|
||||
Id = viewModel.Id,
|
||||
DocumentId = viewModel.DocumentId,
|
||||
DocumentName = viewModel.DocumentName,
|
||||
Status = viewModel.Status,
|
||||
DateCreate = viewModel.DateCreate,
|
||||
DateImplement = viewModel.DateImplement,
|
||||
@ -71,7 +72,7 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
Sum = viewModel.Sum
|
||||
};
|
||||
|
||||
CheckModel(model, false);
|
||||
CheckModel(model);
|
||||
if (model.Status + 1 != newStatus)
|
||||
{
|
||||
_logger.LogWarning("Status update to " + newStatus.ToString() +" operation failed. Order status incorrect.");
|
||||
|
@ -12,6 +12,8 @@ namespace LawFirmContracts.BindingModels
|
||||
{
|
||||
public int DocumentId { get; set; }
|
||||
|
||||
public string DocumentName { get; set; } = string.Empty;
|
||||
|
||||
public int Count { get; set; }
|
||||
|
||||
public double Sum { get; set; }
|
||||
|
@ -10,6 +10,7 @@ namespace LawFirmDataModels.Models
|
||||
public interface IOrderModel : IId
|
||||
{
|
||||
int DocumentId { get; }
|
||||
string DocumentName { get; }
|
||||
int Count { get; }
|
||||
double Sum { get; }
|
||||
OrderStatus Status { get; }
|
||||
|
@ -26,8 +26,8 @@ namespace LawFirmFileImplement.Implements
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return GetViewModel(source.Orders
|
||||
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id)));
|
||||
return source.Orders
|
||||
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
@ -38,13 +38,13 @@ namespace LawFirmFileImplement.Implements
|
||||
}
|
||||
return source.Orders
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => GetViewModel(x))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
return source.Orders.Select(x => GetViewModel(x)).ToList();
|
||||
return source.Orders.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
@ -57,7 +57,7 @@ namespace LawFirmFileImplement.Implements
|
||||
}
|
||||
source.Orders.Add(newOrder);
|
||||
source.SaveOrders();
|
||||
return GetViewModel(newOrder);
|
||||
return newOrder.GetViewModel;
|
||||
}
|
||||
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
@ -69,7 +69,7 @@ namespace LawFirmFileImplement.Implements
|
||||
}
|
||||
order.Update(model);
|
||||
source.SaveOrders();
|
||||
return GetViewModel(order);
|
||||
return order.GetViewModel;
|
||||
}
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
@ -80,21 +80,7 @@ namespace LawFirmFileImplement.Implements
|
||||
}
|
||||
source.Orders.Remove(order);
|
||||
source.SaveOrders();
|
||||
return GetViewModel(order);
|
||||
}
|
||||
|
||||
private OrderViewModel GetViewModel(Order order)
|
||||
{
|
||||
var viewModel = order.GetViewModel;
|
||||
foreach (var document in source.Documents)
|
||||
{
|
||||
if (document.Id == order.DocumentId)
|
||||
{
|
||||
viewModel.DocumentName = document.DocumentName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return viewModel;
|
||||
return order.GetViewModel;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ namespace LawFirmFileImplement.Models
|
||||
{
|
||||
public int DocumentId { get; private set; }
|
||||
|
||||
public string DocumentName { get; private set; } = string.Empty;
|
||||
|
||||
public int Count { get; private set; }
|
||||
|
||||
public double Sum { get; private set; }
|
||||
@ -36,6 +38,7 @@ namespace LawFirmFileImplement.Models
|
||||
return new Order
|
||||
{
|
||||
DocumentId = model.DocumentId,
|
||||
DocumentName = model.DocumentName,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
@ -54,6 +57,7 @@ namespace LawFirmFileImplement.Models
|
||||
return new Order()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
DocumentName = element.Element("DocumentName")!.Value,
|
||||
DocumentId = Convert.ToInt32(element.Element("DocumentId")!.Value),
|
||||
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
||||
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
||||
@ -69,13 +73,20 @@ namespace LawFirmFileImplement.Models
|
||||
{
|
||||
return;
|
||||
}
|
||||
DocumentId = model.DocumentId;
|
||||
DocumentName = model.DocumentName;
|
||||
Count = model.Count;
|
||||
Sum = model.Sum;
|
||||
Status = model.Status;
|
||||
DateCreate = model.DateCreate;
|
||||
DateImplement = model.DateImplement;
|
||||
Id = model.Id;
|
||||
}
|
||||
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
DocumentId = DocumentId,
|
||||
DocumentName = DocumentName,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
DateCreate = DateCreate,
|
||||
@ -87,6 +98,7 @@ namespace LawFirmFileImplement.Models
|
||||
public XElement GetXElement => new(
|
||||
"Order",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("DocumentName", DocumentName),
|
||||
new XElement("DocumentId", DocumentId.ToString()),
|
||||
new XElement("Count", Count.ToString()),
|
||||
new XElement("Sum", Sum.ToString()),
|
||||
|
@ -30,7 +30,7 @@ namespace LawFirmListImplements.Implements
|
||||
{
|
||||
if (model.Id.HasValue && order.Id == model.Id)
|
||||
{
|
||||
return GetViewModel(order);
|
||||
return order.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -47,7 +47,7 @@ namespace LawFirmListImplements.Implements
|
||||
{
|
||||
if (order.Id == model.Id)
|
||||
{
|
||||
result.Add(GetViewModel(order));
|
||||
result.Add(order.GetViewModel);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@ -58,7 +58,7 @@ namespace LawFirmListImplements.Implements
|
||||
var result = new List<OrderViewModel>();
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
result.Add(GetViewModel(order));
|
||||
result.Add(order.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -79,7 +79,7 @@ namespace LawFirmListImplements.Implements
|
||||
return null;
|
||||
}
|
||||
_source.Orders.Add(newOrder);
|
||||
return GetViewModel(newOrder);
|
||||
return newOrder.GetViewModel;
|
||||
}
|
||||
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
@ -89,7 +89,7 @@ namespace LawFirmListImplements.Implements
|
||||
if (order.Id == model.Id)
|
||||
{
|
||||
order.Update(model);
|
||||
return GetViewModel(order);
|
||||
return order.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -102,25 +102,11 @@ namespace LawFirmListImplements.Implements
|
||||
{
|
||||
var element = _source.Orders[i];
|
||||
_source.Orders.RemoveAt(i);
|
||||
return GetViewModel(element);
|
||||
return element.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private OrderViewModel GetViewModel(Order order)
|
||||
{
|
||||
var viewModel = order.GetViewModel;
|
||||
foreach (var document in _source.Documents)
|
||||
{
|
||||
if (document.Id == order.DocumentId)
|
||||
{
|
||||
viewModel.DocumentName = document.DocumentName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return viewModel;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ namespace LawFirmListImplements.Models
|
||||
{
|
||||
public int DocumentId { get; private set; }
|
||||
|
||||
public string DocumentName { get; private set; } = string.Empty;
|
||||
|
||||
public int Count { get; private set; }
|
||||
|
||||
public double Sum { get; private set; }
|
||||
@ -35,6 +37,7 @@ namespace LawFirmListImplements.Models
|
||||
return new Order
|
||||
{
|
||||
DocumentId = model.DocumentId,
|
||||
DocumentName = model.DocumentName,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
@ -50,13 +53,20 @@ namespace LawFirmListImplements.Models
|
||||
{
|
||||
return;
|
||||
}
|
||||
DocumentId = model.DocumentId;
|
||||
DocumentName = model.DocumentName;
|
||||
Count = model.Count;
|
||||
Sum = model.Sum;
|
||||
Status = model.Status;
|
||||
DateCreate = model.DateCreate;
|
||||
DateImplement = model.DateImplement;
|
||||
Id = model.Id;
|
||||
}
|
||||
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
DocumentId = DocumentId,
|
||||
DocumentName = DocumentName,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
DateCreate = DateCreate,
|
||||
|
Loading…
Reference in New Issue
Block a user