order + client (file)

This commit is contained in:
VictoriaPresnyakova 2023-04-01 21:00:22 +04:00
parent dc2492a0e1
commit 6dc87a5d88
2 changed files with 22 additions and 5 deletions

View File

@ -47,12 +47,23 @@ namespace JewelryStoreFileImplement.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model) public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{ {
if (!model.DateFrom.HasValue || !model.DateTo.HasValue) if (model.DateFrom.HasValue)
{ return source.Orders
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
.Select(x => x.GetViewModel)
.ToList();
if (model.ClientId.HasValue && !model.Id.HasValue)
return source.Orders
.Where(x => x.ClientId == model.ClientId)
.Select(x => x.GetViewModel)
.ToList();
if (model.Id.HasValue)
return source.Orders
.Where(x => x.Id.Equals(model.Id))
.Select(x => x.GetViewModel)
.ToList();
return new(); return new();
} }
return source.Orders.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo).Select(x => x.GetViewModel).ToList();
}
public List<OrderViewModel> GetFullList() public List<OrderViewModel> GetFullList()
{ {

View File

@ -5,6 +5,7 @@ using JewelryStoreDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Xml.Linq; using System.Xml.Linq;
@ -14,6 +15,7 @@ namespace JewelryStoreFileImplement.Models
public class Order : IOrderModel public class Order : IOrderModel
{ {
public int JewelId { get; private set; } public int JewelId { get; private set; }
public int ClientId { get; private set; }
public string JewelName { get; private set; } = string.Empty; public string JewelName { get; private set; } = string.Empty;
@ -40,6 +42,7 @@ namespace JewelryStoreFileImplement.Models
Id = model.Id, Id = model.Id,
JewelId = model.JewelId, JewelId = model.JewelId,
JewelName = model.JewelName, JewelName = model.JewelName,
ClientId = model.ClientId,
Count = model.Count, Count = model.Count,
Sum = model.Sum, Sum = model.Sum,
Status = model.Status, Status = model.Status,
@ -59,6 +62,7 @@ namespace JewelryStoreFileImplement.Models
{ {
Id = Convert.ToInt32(element.Attribute("Id")!.Value), Id = Convert.ToInt32(element.Attribute("Id")!.Value),
JewelId = Convert.ToInt32(element.Element("JewelId")!.Value), JewelId = Convert.ToInt32(element.Element("JewelId")!.Value),
ClientId = Convert.ToInt32(element.Element("ClientId")!.Value),
JewelName = element.Element("JewelName")!.Value, JewelName = element.Element("JewelName")!.Value,
Count = Convert.ToInt32(element.Element("Count")!.Value), Count = Convert.ToInt32(element.Element("Count")!.Value),
Sum = Convert.ToDouble(element.Element("Sum")!.Value), Sum = Convert.ToDouble(element.Element("Sum")!.Value),
@ -91,6 +95,7 @@ namespace JewelryStoreFileImplement.Models
{ {
Id = Id, Id = Id,
JewelId = JewelId, JewelId = JewelId,
ClientId = ClientId,
JewelName = JewelName, JewelName = JewelName,
Count = Count, Count = Count,
Sum = Sum, Sum = Sum,
@ -103,6 +108,7 @@ namespace JewelryStoreFileImplement.Models
new XAttribute("Id", Id), new XAttribute("Id", Id),
new XElement("JewelName", JewelName), new XElement("JewelName", JewelName),
new XElement("JewelId", JewelId.ToString()), new XElement("JewelId", JewelId.ToString()),
new XElement("ClientId", ClientId.ToString()),
new XElement("Count", Count.ToString()), new XElement("Count", Count.ToString()),
new XElement("Sum", Sum.ToString()), new XElement("Sum", Sum.ToString()),
new XElement("Status", Status.ToString()), new XElement("Status", Status.ToString()),