Я вроде +- починила всё
This commit is contained in:
parent
9e943ce4d4
commit
d3d8d0e340
@ -41,8 +41,9 @@ namespace ConfectioneryBusinessLogic
|
|||||||
}
|
}
|
||||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("ReadList. OrderId:{Id}", model?.Id);
|
_logger.LogInformation("ReadList. ClientId:{ClientId}.Status:{Status}.ImplementerId:{ImplementerId}.DateFrom:{DateFrom}.DateTo:{DateTo}OrderId:{Id}",
|
||||||
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
model?.ClientId, model?.Status, model?.ImplementerId, model?.DateFrom, model?.DateTo, model?.Id);
|
||||||
|
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
||||||
if (list == null)
|
if (list == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadList return null list");
|
_logger.LogWarning("ReadList return null list");
|
||||||
@ -120,23 +121,30 @@ namespace ConfectioneryBusinessLogic
|
|||||||
model.DateCreate = element.DateCreate;
|
model.DateCreate = element.DateCreate;
|
||||||
model.PastryId = element.PastryId;
|
model.PastryId = element.PastryId;
|
||||||
model.DateImplement = element.DateImplement;
|
model.DateImplement = element.DateImplement;
|
||||||
model.Status = element.Status;
|
model.ClientId = element.ClientId;
|
||||||
|
if (!model.ImplementerId.HasValue)
|
||||||
|
{
|
||||||
|
model.ImplementerId = element.ImplementerId;
|
||||||
|
}
|
||||||
|
model.Status = element.Status;
|
||||||
model.Count = element.Count;
|
model.Count = element.Count;
|
||||||
model.Sum = element.Sum;
|
model.Sum = element.Sum;
|
||||||
if (requiredStatus - model.Status == 1)
|
if (requiredStatus - model.Status == 1)
|
||||||
{
|
{
|
||||||
model.Status = requiredStatus;
|
model.Status = requiredStatus;
|
||||||
if (model.Status == OrderStatus.Выдан)
|
if (model.Status == OrderStatus.Готов)
|
||||||
model.DateImplement = DateTime.Now;
|
{
|
||||||
if (_orderStorage.Update(model) == null)
|
model.DateImplement = DateTime.Now;
|
||||||
{
|
}
|
||||||
_logger.LogWarning("Update operation failed");
|
if (_orderStorage.Update(model) == null)
|
||||||
return false;
|
{
|
||||||
}
|
_logger.LogWarning("Update operation failed");
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
_logger.LogWarning("Changing status operation faled: Current-{Status}:required-{requiredStatus}.", model.Status, requiredStatus);
|
return true;
|
||||||
throw new ArgumentException($"Невозможно присвоить статус {requiredStatus} заказу с текущим статусом {model.Status}");
|
}
|
||||||
|
_logger.LogWarning("Changing status operation faled: Current-{Status}:required-{requiredStatus}.", model.Status, requiredStatus);
|
||||||
|
throw new ArgumentException($"Невозможно присвоить статус {requiredStatus} заказу с текущим статусом {model.Status}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,10 @@ namespace ConfectioneryContracts.ViewModels
|
|||||||
|
|
||||||
[DisplayName("ФИО клиента")]
|
[DisplayName("ФИО клиента")]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
public int PastryId { get; set; }
|
public int? ImplementerId { get; set; }
|
||||||
|
[DisplayName("Исполнитель")]
|
||||||
|
public string? ImplementerFIO { get; set; } = null;
|
||||||
|
public int PastryId { get; set; }
|
||||||
[DisplayName("Изделие")]
|
[DisplayName("Изделие")]
|
||||||
public string PastryName { get; set; } = string.Empty;
|
public string PastryName { get; set; } = string.Empty;
|
||||||
[DisplayName("Количество")]
|
[DisplayName("Количество")]
|
||||||
|
@ -11,7 +11,8 @@ namespace ConfectioneryDataModels.Models
|
|||||||
{
|
{
|
||||||
int PastryId { get; }
|
int PastryId { get; }
|
||||||
int ClientId { get; }
|
int ClientId { get; }
|
||||||
int Count { get; }
|
int? ImplementerId { get; }
|
||||||
|
int Count { get; }
|
||||||
double Sum { get; }
|
double Sum { get; }
|
||||||
OrderStatus Status { get; }
|
OrderStatus Status { get; }
|
||||||
DateTime DateCreate { get; }
|
DateTime DateCreate { get; }
|
||||||
|
@ -191,7 +191,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
|
|||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("ConfectioneryDatabaseImplement.Models.Implementer", null)
|
b.HasOne("ConfectioneryDatabaseImplement.Models.Implementer", "Implementer")
|
||||||
.WithMany("Order")
|
.WithMany("Order")
|
||||||
.HasForeignKey("ImplementerId");
|
.HasForeignKey("ImplementerId");
|
||||||
|
|
||||||
@ -203,7 +203,9 @@ namespace ConfectioneryDatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.Navigation("Client");
|
b.Navigation("Client");
|
||||||
|
|
||||||
b.Navigation("Pastry");
|
b.Navigation("Implementer");
|
||||||
|
|
||||||
|
b.Navigation("Pastry");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.PastryComponent", b =>
|
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.PastryComponent", b =>
|
||||||
|
@ -23,8 +23,10 @@ namespace ConfectioneryDatabaseImplement.Models
|
|||||||
public int PastryId { get; private set; }
|
public int PastryId { get; private set; }
|
||||||
|
|
||||||
public virtual Pastry Pastry { get; set; } = new();
|
public virtual Pastry Pastry { get; set; } = new();
|
||||||
|
public int? ImplementerId { get; private set; }
|
||||||
|
public virtual Implementer? Implementer { get; set; } = new();
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
@ -47,7 +49,9 @@ namespace ConfectioneryDatabaseImplement.Models
|
|||||||
Client = context.Clients.First(x => x.Id == model.ClientId),
|
Client = context.Clients.First(x => x.Id == model.ClientId),
|
||||||
PastryId = model.PastryId,
|
PastryId = model.PastryId,
|
||||||
Pastry = context.Pastrys.First(x => x.Id == model.PastryId),
|
Pastry = context.Pastrys.First(x => x.Id == model.PastryId),
|
||||||
Count = model.Count,
|
ImplementerId = model.ImplementerId,
|
||||||
|
Implementer = model.ImplementerId.HasValue ? context.Implementers.First(x => x.Id == model.ImplementerId) : null,
|
||||||
|
Count = model.Count,
|
||||||
Sum = model.Sum,
|
Sum = model.Sum,
|
||||||
Status = model.Status,
|
Status = model.Status,
|
||||||
DateCreate = model.DateCreate,
|
DateCreate = model.DateCreate,
|
||||||
@ -55,7 +59,7 @@ namespace ConfectioneryDatabaseImplement.Models
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(OrderBindingModel? model)
|
public void Update(ConfectioneryDatabase context, OrderBindingModel? model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
@ -63,7 +67,9 @@ namespace ConfectioneryDatabaseImplement.Models
|
|||||||
}
|
}
|
||||||
Status = model.Status;
|
Status = model.Status;
|
||||||
DateImplement = model.DateImplement;
|
DateImplement = model.DateImplement;
|
||||||
}
|
ImplementerId = model.ImplementerId;
|
||||||
|
Implementer = model.ImplementerId.HasValue ? context.Implementers.First(x => x.Id == model.ImplementerId) : null;
|
||||||
|
}
|
||||||
|
|
||||||
public OrderViewModel GetViewModel => new()
|
public OrderViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
@ -72,7 +78,9 @@ namespace ConfectioneryDatabaseImplement.Models
|
|||||||
ClientFIO = Client.ClientFIO,
|
ClientFIO = Client.ClientFIO,
|
||||||
PastryId = PastryId,
|
PastryId = PastryId,
|
||||||
PastryName = Pastry.PastryName,
|
PastryName = Pastry.PastryName,
|
||||||
Count = Count,
|
ImplementerId = ImplementerId,
|
||||||
|
ImplementerFIO = Implementer != null ? Implementer.ImplementerFIO : null,
|
||||||
|
Count = Count,
|
||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
DateCreate = DateCreate,
|
DateCreate = DateCreate,
|
||||||
|
@ -17,32 +17,35 @@ namespace ConfectioneryDatabaseImplement.Implements
|
|||||||
public List<OrderViewModel> GetFullList()
|
public List<OrderViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
using var context = new ConfectioneryDatabase();
|
using var context = new ConfectioneryDatabase();
|
||||||
return context.Orders.Include(x => x.Pastry).Include(x => x.Client).Select(x => x.GetViewModel).ToList();
|
return context.Orders.Include(x => x.Pastry).Include(x => x.Client).Include(y => y.Implementer).Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
using var context = new ConfectioneryDatabase();
|
using var context = new ConfectioneryDatabase();
|
||||||
if (model.DateFrom.HasValue)
|
if ((!model.DateFrom.HasValue || !model.DateTo.HasValue) && !model.ClientId.HasValue && !model.Status.HasValue)
|
||||||
{
|
{
|
||||||
return context.Orders.Include(x => x.Pastry).Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo).Select(x => x.GetViewModel).ToList();
|
return new();
|
||||||
}
|
}
|
||||||
if (model.ClientId.HasValue)
|
return context.Orders.Include(x => x.Pastry).Include(x => x.Client).Include(x => x.Implementer).Where(x =>
|
||||||
{
|
(model.DateFrom.HasValue && model.DateTo.HasValue && x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo) ||
|
||||||
return context.Orders.Include(x => x.Pastry).Where(x => x.ClientId == model.ClientId).Select(x => x.GetViewModel).ToList();
|
(model.ClientId.HasValue && x.ClientId == model.ClientId) ||
|
||||||
}
|
(model.Status.HasValue && x.Status == model.Status))
|
||||||
return context.Orders.Include(x => x.Pastry).Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
|
.Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.Id.HasValue)
|
if (!model.Id.HasValue && (!model.ImplementerId.HasValue || !model.Status.HasValue))
|
||||||
{
|
{
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
using var context = new ConfectioneryDatabase();
|
using var context = new ConfectioneryDatabase();
|
||||||
return context.Orders.Include(x => x.Pastry).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
return context.Orders.Include(x => x.Pastry).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(x =>
|
||||||
}
|
(model.Id.HasValue && x.Id == model.Id) ||
|
||||||
|
(model.ImplementerId.HasValue && x.ImplementerId == model.ImplementerId && x.Status == model.Status))
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
public OrderViewModel? Insert(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
@ -67,7 +70,7 @@ namespace ConfectioneryDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
order.Update(model);
|
order.Update(context, model);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return order.GetViewModel;
|
return order.GetViewModel;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,8 @@ namespace ConfectioneryFileImplement.Models
|
|||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
public int ClientId { get; private set; }
|
public int ClientId { get; private set; }
|
||||||
public int PastryId { get; private set; }
|
public int? ImplementerId { get; set; }
|
||||||
|
public int PastryId { get; private set; }
|
||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
public double Sum { get; private set; }
|
public double Sum { get; private set; }
|
||||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
||||||
@ -27,12 +28,14 @@ namespace ConfectioneryFileImplement.Models
|
|||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
PastryId = model.PastryId,
|
PastryId = model.PastryId,
|
||||||
Count = model.Count,
|
ClientId = model.ClientId,
|
||||||
Sum = model.Sum,
|
ImplementerId = model.ImplementerId,
|
||||||
Status = model.Status,
|
Count = model.Count,
|
||||||
DateCreate = model.DateCreate,
|
Sum = model.Sum,
|
||||||
DateImplement = model.DateImplement,
|
Status = model.Status,
|
||||||
};
|
DateCreate = model.DateCreate,
|
||||||
|
DateImplement = model.DateImplement,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Order? Create(XElement element)
|
public static Order? Create(XElement element)
|
||||||
@ -46,12 +49,14 @@ namespace ConfectioneryFileImplement.Models
|
|||||||
{
|
{
|
||||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
PastryId = Convert.ToInt32(element.Element("PastryId")!.Value),
|
PastryId = Convert.ToInt32(element.Element("PastryId")!.Value),
|
||||||
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
ClientId = Convert.ToInt32(element.Element("ClientId")!.Value),
|
||||||
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
ImplementerId = Convert.ToInt32(element.Element("ImplementerId")!.Value),
|
||||||
Status = (OrderStatus)(Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value)),
|
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
||||||
DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value),
|
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
||||||
DateImplement = (dateImplement == "" || dateImplement is null) ? Convert.ToDateTime(null) : Convert.ToDateTime(dateImplement)
|
Status = (OrderStatus)(Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value)),
|
||||||
};
|
DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value),
|
||||||
|
DateImplement = (dateImplement == "" || dateImplement is null) ? Convert.ToDateTime(null) : Convert.ToDateTime(dateImplement)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(OrderBindingModel? model)
|
public void Update(OrderBindingModel? model)
|
||||||
@ -68,20 +73,24 @@ namespace ConfectioneryFileImplement.Models
|
|||||||
{
|
{
|
||||||
Id = Id,
|
Id = Id,
|
||||||
PastryId = PastryId,
|
PastryId = PastryId,
|
||||||
Count = Count,
|
ClientId = ClientId,
|
||||||
Sum = Sum,
|
ImplementerId = ImplementerId,
|
||||||
Status = Status,
|
Count = Count,
|
||||||
DateCreate = DateCreate,
|
Sum = Sum,
|
||||||
DateImplement = DateImplement,
|
Status = Status,
|
||||||
};
|
DateCreate = DateCreate,
|
||||||
|
DateImplement = DateImplement,
|
||||||
|
};
|
||||||
|
|
||||||
public XElement GetXElement => new("Order",
|
public XElement GetXElement => new("Order",
|
||||||
new XAttribute("Id", Id),
|
new XAttribute("Id", Id),
|
||||||
new XElement("PastryId", PastryId.ToString()),
|
new XElement("PastryId", PastryId.ToString()),
|
||||||
new XElement("Count", Count.ToString()),
|
new XElement("ClientId", ClientId.ToString()),
|
||||||
new XElement("Sum", Sum.ToString()),
|
new XElement("ImplementerId", ImplementerId),
|
||||||
new XElement("Status", Status.ToString()),
|
new XElement("Count", Count.ToString()),
|
||||||
new XElement("DateCreate", DateCreate.ToString()),
|
new XElement("Sum", Sum.ToString()),
|
||||||
new XElement("DateImplement", DateImplement.ToString()));
|
new XElement("Status", Status.ToString()),
|
||||||
}
|
new XElement("DateCreate", DateCreate.ToString()),
|
||||||
|
new XElement("DateImplement", DateImplement.ToString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,21 +24,59 @@ namespace ConfectioneryFileImplement.Implements
|
|||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.Id.HasValue)
|
if (model.DateFrom.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 => AttachPastryName(x.GetViewModel)).ToList();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
if (model.ClientId.HasValue && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return source.Orders.Where(x => x.ClientId == model.ClientId).Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!model.ImplementerId.HasValue && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return source.Orders.Where(x => x.ImplementerId == model.ImplementerId).Select(x => x.GetViewModel).ToList();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return source.Orders.Where(x => x.Id.Equals(model.Id)).Select(x => GetViewModel(x)).ToList();
|
||||||
|
}
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
private OrderViewModel GetViewModel(Order order)
|
||||||
|
{
|
||||||
|
var viewModel = order.GetViewModel;
|
||||||
|
|
||||||
|
var Pastry = source.Pastrys.FirstOrDefault(x => x.Id == order.PastryId);
|
||||||
|
var client = source.Clients.FirstOrDefault(x => x.Id == order.ClientId);
|
||||||
|
|
||||||
|
if (Pastry != null)
|
||||||
|
{
|
||||||
|
viewModel.PastryName = Pastry.PastryName;
|
||||||
|
}
|
||||||
|
if (client != null)
|
||||||
|
{
|
||||||
|
viewModel.ClientFIO = client.ClientFIO;
|
||||||
|
}
|
||||||
|
return viewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.Id.HasValue)
|
if (model.ImplementerId.HasValue)
|
||||||
{
|
{
|
||||||
return new();
|
return source.Orders.FirstOrDefault(x => x.ImplementerId == model.ImplementerId)?.GetViewModel;
|
||||||
}
|
}
|
||||||
return AttachPastryName(source.Orders.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel);
|
if (!model.Id.HasValue)
|
||||||
}
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
return AttachPastryName(source.Orders.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel);
|
||||||
|
}
|
||||||
|
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
public OrderViewModel? Insert(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,8 @@ namespace ConfectioneryListImplement.Models
|
|||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
public int PastryId { get; private set; }
|
public int PastryId { get; private set; }
|
||||||
public int ClientId { get; private set; }
|
public int ClientId { get; private set; }
|
||||||
public int Count { get; private set; }
|
public int? ImplementerId { get; private set; }
|
||||||
|
public int Count { get; private set; }
|
||||||
public double Sum { get; private set; }
|
public double Sum { get; private set; }
|
||||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
||||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||||
@ -31,12 +32,14 @@ namespace ConfectioneryListImplement.Models
|
|||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
PastryId = model.PastryId,
|
PastryId = model.PastryId,
|
||||||
Count = model.Count,
|
ClientId = model.ClientId,
|
||||||
Sum = model.Sum,
|
ImplementerId = model.ImplementerId,
|
||||||
Status = model.Status,
|
Count = model.Count,
|
||||||
DateCreate = model.DateCreate,
|
Sum = model.Sum,
|
||||||
DateImplement = model.DateImplement,
|
Status = model.Status,
|
||||||
};
|
DateCreate = model.DateCreate,
|
||||||
|
DateImplement = model.DateImplement,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(OrderBindingModel? model)
|
public void Update(OrderBindingModel? model)
|
||||||
@ -53,11 +56,13 @@ namespace ConfectioneryListImplement.Models
|
|||||||
{
|
{
|
||||||
Id = Id,
|
Id = Id,
|
||||||
PastryId = PastryId,
|
PastryId = PastryId,
|
||||||
Count = Count,
|
ClientId = ClientId,
|
||||||
Sum = Sum,
|
ImplementerId = ImplementerId,
|
||||||
Status = Status,
|
Count = Count,
|
||||||
DateCreate = DateCreate,
|
Sum = Sum,
|
||||||
DateImplement = DateImplement,
|
Status = Status,
|
||||||
};
|
DateCreate = DateCreate,
|
||||||
|
DateImplement = DateImplement,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,36 +32,90 @@ namespace ConfectioneryListImplement
|
|||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
var result = new List<OrderViewModel>();
|
var result = new List<OrderViewModel>();
|
||||||
if (model == null || !model.Id.HasValue)
|
if (model.DateFrom.HasValue)
|
||||||
{
|
{
|
||||||
return result;
|
foreach (var order in _source.Orders)
|
||||||
}
|
{
|
||||||
foreach (var order in _source.Orders)
|
if (order.DateCreate >= model.DateFrom && order.DateCreate <= model.DateTo)
|
||||||
{
|
{
|
||||||
if (order.Id == model.Id)
|
result.Add(GetViewModel(order));
|
||||||
{
|
}
|
||||||
result.Add(AttachPastryName(order.GetViewModel));
|
}
|
||||||
}
|
}
|
||||||
}
|
else if (model.ClientId.HasValue && !model.Id.HasValue)
|
||||||
return result;
|
{
|
||||||
}
|
foreach (var order in _source.Orders)
|
||||||
|
{
|
||||||
|
if (order.ClientId == model.ClientId)
|
||||||
|
{
|
||||||
|
result.Add(GetViewModel(order));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (model.ImplementerId.HasValue && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
foreach (var order in _source.Orders)
|
||||||
|
{
|
||||||
|
if (order.ImplementerId == model.ImplementerId)
|
||||||
|
{
|
||||||
|
result.Add(GetViewModel(order));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
foreach (var order in _source.Orders)
|
||||||
|
{
|
||||||
|
if (order.Id == model.Id)
|
||||||
|
{
|
||||||
|
result.Add(GetViewModel(order));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
private OrderViewModel GetViewModel(Order order)
|
||||||
|
{
|
||||||
|
var viewModel = order.GetViewModel;
|
||||||
|
foreach (var package in _source.Pastrys)
|
||||||
|
{
|
||||||
|
if (package.Id == order.PastryId)
|
||||||
|
{
|
||||||
|
viewModel.PastryName = package.PastryName;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (var client in _source.Clients)
|
||||||
|
{
|
||||||
|
if (client.Id == order.ClientId)
|
||||||
|
{
|
||||||
|
viewModel.ClientFIO = client.ClientFIO;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return viewModel;
|
||||||
|
}
|
||||||
|
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.Id.HasValue)
|
if (!model.Id.HasValue)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
foreach (var order in _source.Orders)
|
foreach (var order in _source.Orders)
|
||||||
{
|
{
|
||||||
if (model.Id.HasValue && order.Id == model.Id)
|
if (model.Id.HasValue && order.Id == model.Id)
|
||||||
{
|
{
|
||||||
return AttachPastryName(order.GetViewModel);
|
return AttachPastryName(order.GetViewModel);
|
||||||
}
|
}
|
||||||
}
|
else if (model.ImplementerId.HasValue && model.ImplementerId == order.ImplementerId)
|
||||||
return null;
|
{
|
||||||
}
|
return GetViewModel(order);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
public OrderViewModel? Insert(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
|
16
Confectionery/ConfectioneryView/FormMain.Designer.cs
generated
16
Confectionery/ConfectioneryView/FormMain.Designer.cs
generated
@ -56,7 +56,7 @@
|
|||||||
dataGridView.Location = new Point(12, 60);
|
dataGridView.Location = new Point(12, 60);
|
||||||
dataGridView.Name = "dataGridView";
|
dataGridView.Name = "dataGridView";
|
||||||
dataGridView.RowHeadersWidth = 62;
|
dataGridView.RowHeadersWidth = 62;
|
||||||
dataGridView.Size = new Size(1374, 549);
|
dataGridView.Size = new Size(1614, 549);
|
||||||
dataGridView.TabIndex = 0;
|
dataGridView.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// menuStrip
|
// menuStrip
|
||||||
@ -65,7 +65,7 @@
|
|||||||
menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem, отчетыToolStripMenuItem, startWorkToolStripMenuItem });
|
menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem, отчетыToolStripMenuItem, startWorkToolStripMenuItem });
|
||||||
menuStrip.Location = new Point(0, 0);
|
menuStrip.Location = new Point(0, 0);
|
||||||
menuStrip.Name = "menuStrip";
|
menuStrip.Name = "menuStrip";
|
||||||
menuStrip.Size = new Size(1666, 33);
|
menuStrip.Size = new Size(1921, 33);
|
||||||
menuStrip.TabIndex = 1;
|
menuStrip.TabIndex = 1;
|
||||||
menuStrip.Text = "menuStrip1";
|
menuStrip.Text = "menuStrip1";
|
||||||
//
|
//
|
||||||
@ -142,7 +142,7 @@
|
|||||||
// buttonCreateOrder
|
// buttonCreateOrder
|
||||||
//
|
//
|
||||||
buttonCreateOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
buttonCreateOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
buttonCreateOrder.Location = new Point(1402, 83);
|
buttonCreateOrder.Location = new Point(1657, 83);
|
||||||
buttonCreateOrder.Name = "buttonCreateOrder";
|
buttonCreateOrder.Name = "buttonCreateOrder";
|
||||||
buttonCreateOrder.Size = new Size(232, 34);
|
buttonCreateOrder.Size = new Size(232, 34);
|
||||||
buttonCreateOrder.TabIndex = 2;
|
buttonCreateOrder.TabIndex = 2;
|
||||||
@ -153,7 +153,7 @@
|
|||||||
// buttonTakeOrderInWork
|
// buttonTakeOrderInWork
|
||||||
//
|
//
|
||||||
buttonTakeOrderInWork.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
buttonTakeOrderInWork.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
buttonTakeOrderInWork.Location = new Point(1402, 143);
|
buttonTakeOrderInWork.Location = new Point(1657, 143);
|
||||||
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
|
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
|
||||||
buttonTakeOrderInWork.Size = new Size(232, 34);
|
buttonTakeOrderInWork.Size = new Size(232, 34);
|
||||||
buttonTakeOrderInWork.TabIndex = 3;
|
buttonTakeOrderInWork.TabIndex = 3;
|
||||||
@ -164,7 +164,7 @@
|
|||||||
// buttonOrderReady
|
// buttonOrderReady
|
||||||
//
|
//
|
||||||
buttonOrderReady.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
buttonOrderReady.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
buttonOrderReady.Location = new Point(1402, 203);
|
buttonOrderReady.Location = new Point(1657, 203);
|
||||||
buttonOrderReady.Name = "buttonOrderReady";
|
buttonOrderReady.Name = "buttonOrderReady";
|
||||||
buttonOrderReady.Size = new Size(232, 34);
|
buttonOrderReady.Size = new Size(232, 34);
|
||||||
buttonOrderReady.TabIndex = 4;
|
buttonOrderReady.TabIndex = 4;
|
||||||
@ -175,7 +175,7 @@
|
|||||||
// buttonIssuedOrder
|
// buttonIssuedOrder
|
||||||
//
|
//
|
||||||
buttonIssuedOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
buttonIssuedOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
buttonIssuedOrder.Location = new Point(1402, 266);
|
buttonIssuedOrder.Location = new Point(1657, 266);
|
||||||
buttonIssuedOrder.Name = "buttonIssuedOrder";
|
buttonIssuedOrder.Name = "buttonIssuedOrder";
|
||||||
buttonIssuedOrder.Size = new Size(232, 34);
|
buttonIssuedOrder.Size = new Size(232, 34);
|
||||||
buttonIssuedOrder.TabIndex = 5;
|
buttonIssuedOrder.TabIndex = 5;
|
||||||
@ -186,7 +186,7 @@
|
|||||||
// buttonRef
|
// buttonRef
|
||||||
//
|
//
|
||||||
buttonRef.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
buttonRef.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
buttonRef.Location = new Point(1402, 329);
|
buttonRef.Location = new Point(1657, 329);
|
||||||
buttonRef.Name = "buttonRef";
|
buttonRef.Name = "buttonRef";
|
||||||
buttonRef.Size = new Size(232, 34);
|
buttonRef.Size = new Size(232, 34);
|
||||||
buttonRef.TabIndex = 6;
|
buttonRef.TabIndex = 6;
|
||||||
@ -198,7 +198,7 @@
|
|||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(1666, 621);
|
ClientSize = new Size(1921, 621);
|
||||||
Controls.Add(buttonRef);
|
Controls.Add(buttonRef);
|
||||||
Controls.Add(buttonIssuedOrder);
|
Controls.Add(buttonIssuedOrder);
|
||||||
Controls.Add(buttonOrderReady);
|
Controls.Add(buttonOrderReady);
|
||||||
|
@ -43,6 +43,7 @@ namespace ConfectioneryView
|
|||||||
dataGridView.DataSource = list;
|
dataGridView.DataSource = list;
|
||||||
dataGridView.Columns["PastryId"].Visible = false;
|
dataGridView.Columns["PastryId"].Visible = false;
|
||||||
dataGridView.Columns["ClientId"].Visible = false;
|
dataGridView.Columns["ClientId"].Visible = false;
|
||||||
|
dataGridView.Columns["ImplementerId"].Visible = false;
|
||||||
dataGridView.Columns["PastryName"].AutoSizeMode =
|
dataGridView.Columns["PastryName"].AutoSizeMode =
|
||||||
DataGridViewAutoSizeColumnMode.Fill;
|
DataGridViewAutoSizeColumnMode.Fill;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user