Compare commits
4 Commits
9a9ac1fb88
...
c67efaf03c
Author | SHA1 | Date | |
---|---|---|---|
c67efaf03c | |||
248ba0e38d | |||
b61a40fb5a | |||
2a701082f7 |
@ -15,10 +15,15 @@ namespace PizzeriaFileImplement
|
|||||||
private readonly string OrderFileName = "Order.xml";
|
private readonly string OrderFileName = "Order.xml";
|
||||||
private readonly string PizzaFileName = "Pizza.xml";
|
private readonly string PizzaFileName = "Pizza.xml";
|
||||||
private readonly string ClientFileName = "Client.xml";
|
private readonly string ClientFileName = "Client.xml";
|
||||||
|
private readonly string ImplementerFileName = "Implementer.xml";
|
||||||
|
private readonly string MessageInfoFileName = "MessageInfo.xml";
|
||||||
public List<Component> Components { get; private set; }
|
public List<Component> Components { get; private set; }
|
||||||
public List<Order> Orders { get; private set; }
|
public List<Order> Orders { get; private set; }
|
||||||
public List<Pizza> Pizzas { get; private set; }
|
public List<Pizza> Pizzas { get; private set; }
|
||||||
public List<Client> Clients { get; private set; }
|
public List<Client> Clients { get; private set; }
|
||||||
|
public List<Implementer> Implementers { get; private set; }
|
||||||
|
public List<MessageInfo> Messages { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
public static DataFileSingleton GetInstance()
|
public static DataFileSingleton GetInstance()
|
||||||
{
|
{
|
||||||
@ -33,6 +38,8 @@ namespace PizzeriaFileImplement
|
|||||||
public void SavePizzas() => SaveData(Pizzas, PizzaFileName, "Pizzas", x => x.GetXElement);
|
public void SavePizzas() => SaveData(Pizzas, PizzaFileName, "Pizzas", x => x.GetXElement);
|
||||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
||||||
public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement);
|
public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement);
|
||||||
|
public void SaveImplementers() => SaveData(Implementers, ImplementerFileName, "Implementers", x => x.GetXElement);
|
||||||
|
public void SaveMessages() => SaveData(Orders, ImplementerFileName, "Messages", x => x.GetXElement);
|
||||||
|
|
||||||
private DataFileSingleton()
|
private DataFileSingleton()
|
||||||
{
|
{
|
||||||
@ -40,6 +47,8 @@ namespace PizzeriaFileImplement
|
|||||||
Pizzas = LoadData(PizzaFileName, "Pizza", x => Pizza.Create(x)!)!;
|
Pizzas = LoadData(PizzaFileName, "Pizza", x => Pizza.Create(x)!)!;
|
||||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||||
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
|
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
|
||||||
|
Implementers = LoadData(ImplementerFileName, "Implementer", x => Implementer.Create(x)!)!;
|
||||||
|
Messages = LoadData(MessageInfoFileName, "MessageInfo", x => MessageInfo.Create(x)!)!;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
||||||
|
@ -2,39 +2,47 @@
|
|||||||
using PizzeriaContracts.SearchModels;
|
using PizzeriaContracts.SearchModels;
|
||||||
using PizzeriaContracts.StoragesContracts;
|
using PizzeriaContracts.StoragesContracts;
|
||||||
using PizzeriaContracts.ViewModels;
|
using PizzeriaContracts.ViewModels;
|
||||||
|
using PizzeriaFileImplement.Models;
|
||||||
|
|
||||||
namespace PizzeriaFileImplement.Implements
|
namespace PizzeriaFileImplement.Implements
|
||||||
{
|
{
|
||||||
public class ImplementerStorage : IImplementerStorage
|
public class MessageInfoStorage : IMessageInfoStorage
|
||||||
{
|
{
|
||||||
public ImplementerViewModel? Delete(ImplementerBindingModel model)
|
private readonly DataFileSingleton _source;
|
||||||
|
public MessageInfoStorage()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
_source = DataFileSingleton.GetInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
public List<MessageInfoViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return _source.Messages.Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
|
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return _source.Messages.Where(x => x.ClientId == model.ClientId).Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ImplementerViewModel> GetFullList()
|
public MessageInfoViewModel? GetElement(MessageInfoSearchModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
if (model.MessageId != null)
|
||||||
|
{
|
||||||
|
return _source.Messages.FirstOrDefault(x => x.MessageId == model.MessageId)?.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImplementerViewModel? Insert(ImplementerBindingModel model)
|
public MessageInfoViewModel? Insert(MessageInfoBindingModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var newMessage = MessageInfo.Create(model);
|
||||||
}
|
if (newMessage == null)
|
||||||
|
|
||||||
public ImplementerViewModel? Update(ImplementerBindingModel model)
|
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return null;
|
||||||
|
}
|
||||||
|
_source.Messages.Add(newMessage);
|
||||||
|
_source.SaveMessages();
|
||||||
|
return newMessage.GetViewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,12 @@ namespace PizzeriaFileImplement.Implements
|
|||||||
return source.Orders.Where(x => x.ClientId == model.ClientId).Select(x => x.GetViewModel).ToList();
|
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)
|
if (model.Id.HasValue)
|
||||||
{
|
{
|
||||||
return source.Orders.Where(x => x.Id.Equals(model.Id)).Select(x => GetViewModel(x)).ToList();
|
return source.Orders.Where(x => x.Id.Equals(model.Id)).Select(x => GetViewModel(x)).ToList();
|
||||||
@ -39,6 +45,10 @@ namespace PizzeriaFileImplement.Implements
|
|||||||
|
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
|
if (model.ImplementerId.HasValue)
|
||||||
|
{
|
||||||
|
return source.Orders.FirstOrDefault(x => x.ImplementerId == model.ImplementerId)?.GetViewModel;
|
||||||
|
}
|
||||||
if (!model.Id.HasValue)
|
if (!model.Id.HasValue)
|
||||||
{
|
{
|
||||||
return new();
|
return new();
|
||||||
|
87
Pizzeria/PizzeriaFileImplement/Models/Implementer.cs
Normal file
87
Pizzeria/PizzeriaFileImplement/Models/Implementer.cs
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
using PizzeriaContracts.BindingModels;
|
||||||
|
using PizzeriaContracts.ViewModels;
|
||||||
|
using PizzeriaDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace PizzeriaFileImplement.Models
|
||||||
|
{
|
||||||
|
public class Implementer : IImplementerModel
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Password { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public int WorkExperience { get; private set; }
|
||||||
|
|
||||||
|
public int Qualification { get; private set; }
|
||||||
|
|
||||||
|
public static Implementer? Create(XElement element)
|
||||||
|
{
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
ImplementerFIO = element.Element("FIO")!.Value,
|
||||||
|
Password = element.Element("Password")!.Value,
|
||||||
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
|
Qualification = Convert.ToInt32(element.Element("Qualification")!.Value),
|
||||||
|
WorkExperience = Convert.ToInt32(element.Element("WorkExperience")!.Value),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Implementer? Create(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Password = model.Password,
|
||||||
|
Qualification = model.Qualification,
|
||||||
|
ImplementerFIO = model.ImplementerFIO,
|
||||||
|
WorkExperience = model.WorkExperience,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void Update(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Password = model.Password;
|
||||||
|
Qualification = model.Qualification;
|
||||||
|
ImplementerFIO = model.ImplementerFIO;
|
||||||
|
WorkExperience = model.WorkExperience;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Password = Password,
|
||||||
|
Qualification = Qualification,
|
||||||
|
ImplementerFIO = ImplementerFIO,
|
||||||
|
};
|
||||||
|
|
||||||
|
public XElement GetXElement => new("Client",
|
||||||
|
new XAttribute("Id", Id),
|
||||||
|
new XElement("Password", Password),
|
||||||
|
new XElement("FIO", ImplementerFIO),
|
||||||
|
new XElement("Qualification", Qualification),
|
||||||
|
new XElement("WorkExperience", WorkExperience)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -10,7 +10,7 @@ using System.Xml.Linq;
|
|||||||
|
|
||||||
namespace PizzeriaFileImplement.Models
|
namespace PizzeriaFileImplement.Models
|
||||||
{
|
{
|
||||||
public class Message : IMessageInfoModel
|
public class MessageInfo : IMessageInfoModel
|
||||||
{
|
{
|
||||||
public string MessageId { get; private set; } = string.Empty;
|
public string MessageId { get; private set; } = string.Empty;
|
||||||
|
|
||||||
@ -24,11 +24,7 @@ namespace PizzeriaFileImplement.Models
|
|||||||
|
|
||||||
public string Body { get; private set; } = string.Empty;
|
public string Body { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public bool HasRead { get; private set; }
|
public static MessageInfo? Create(MessageInfoBindingModel model)
|
||||||
|
|
||||||
public string? Reply { get; private set; }
|
|
||||||
|
|
||||||
public static Message? Create(MessageInfoBindingModel model)
|
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
@ -38,14 +34,14 @@ namespace PizzeriaFileImplement.Models
|
|||||||
{
|
{
|
||||||
Body = model.Body,
|
Body = model.Body,
|
||||||
Subject = model.Subject,
|
Subject = model.Subject,
|
||||||
DateDelivery = model.DateDelivery,
|
|
||||||
SenderName = model.SenderName,
|
|
||||||
ClientId = model.ClientId,
|
ClientId = model.ClientId,
|
||||||
MessageId = model.MessageId
|
MessageId = model.MessageId,
|
||||||
|
SenderName = model.SenderName,
|
||||||
|
DateDelivery = model.DateDelivery,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Message? Create(XElement element)
|
public static MessageInfo? Create(XElement element)
|
||||||
{
|
{
|
||||||
if (element == null)
|
if (element == null)
|
||||||
{
|
{
|
||||||
@ -55,40 +51,26 @@ namespace PizzeriaFileImplement.Models
|
|||||||
{
|
{
|
||||||
Body = element.Attribute("Body")!.Value,
|
Body = element.Attribute("Body")!.Value,
|
||||||
Subject = element.Attribute("Subject")!.Value,
|
Subject = element.Attribute("Subject")!.Value,
|
||||||
DateDelivery = Convert.ToDateTime(element.Attribute("DateDelivery")!.Value),
|
|
||||||
SenderName = element.Attribute("SenderName")!.Value,
|
|
||||||
ClientId = Convert.ToInt32(element.Attribute("ClientId")!.Value),
|
ClientId = Convert.ToInt32(element.Attribute("ClientId")!.Value),
|
||||||
MessageId = element.Attribute("MessageId")!.Value,
|
MessageId = element.Attribute("MessageId")!.Value,
|
||||||
|
SenderName = element.Attribute("SenderName")!.Value,
|
||||||
|
DateDelivery = Convert.ToDateTime(element.Attribute("DateDelivery")!.Value),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(MessageInfoBindingModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Reply = model.Reply;
|
|
||||||
HasRead = model.HasRead;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MessageInfoViewModel GetViewModel => new()
|
public MessageInfoViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
Body = Body,
|
Body = Body,
|
||||||
Subject = Subject,
|
Subject = Subject,
|
||||||
Reply = Reply,
|
|
||||||
HasRead = HasRead,
|
|
||||||
DateDelivery = DateDelivery,
|
|
||||||
SenderName = SenderName,
|
|
||||||
ClientId = ClientId,
|
ClientId = ClientId,
|
||||||
MessageId = MessageId
|
MessageId = MessageId,
|
||||||
|
SenderName = SenderName,
|
||||||
|
DateDelivery = DateDelivery,
|
||||||
};
|
};
|
||||||
|
|
||||||
public XElement GetXElement => new("MessageInfo",
|
public XElement GetXElement => new("MessageInfo",
|
||||||
new XAttribute("Subject", Subject),
|
|
||||||
new XAttribute("Body", Body),
|
new XAttribute("Body", Body),
|
||||||
new XAttribute("Reply", Reply),
|
new XAttribute("Subject", Subject),
|
||||||
new XAttribute("HasRead", HasRead),
|
|
||||||
new XAttribute("ClientId", ClientId),
|
new XAttribute("ClientId", ClientId),
|
||||||
new XAttribute("MessageId", MessageId),
|
new XAttribute("MessageId", MessageId),
|
||||||
new XAttribute("SenderName", SenderName),
|
new XAttribute("SenderName", SenderName),
|
@ -10,6 +10,7 @@ namespace PizzeriaFileImplement.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? ImplementerId { get; set; }
|
||||||
public int PizzaId { get; private set; }
|
public int PizzaId { 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; }
|
||||||
@ -28,6 +29,7 @@ namespace PizzeriaFileImplement.Models
|
|||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
PizzaId = model.PizzaId,
|
PizzaId = model.PizzaId,
|
||||||
ClientId = model.ClientId,
|
ClientId = model.ClientId,
|
||||||
|
ImplementerId = model.ImplementerId,
|
||||||
Count = model.Count,
|
Count = model.Count,
|
||||||
Sum = model.Sum,
|
Sum = model.Sum,
|
||||||
Status = model.Status,
|
Status = model.Status,
|
||||||
@ -48,6 +50,7 @@ namespace PizzeriaFileImplement.Models
|
|||||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
PizzaId = Convert.ToInt32(element.Element("PizzaId")!.Value),
|
PizzaId = Convert.ToInt32(element.Element("PizzaId")!.Value),
|
||||||
ClientId = Convert.ToInt32(element.Element("ClientId")!.Value),
|
ClientId = Convert.ToInt32(element.Element("ClientId")!.Value),
|
||||||
|
ImplementerId = Convert.ToInt32(element.Element("ImplementerId")!.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),
|
||||||
Status = (OrderStatus)(Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value)),
|
Status = (OrderStatus)(Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value)),
|
||||||
@ -72,6 +75,7 @@ namespace PizzeriaFileImplement.Models
|
|||||||
Id = Id,
|
Id = Id,
|
||||||
PizzaId = PizzaId,
|
PizzaId = PizzaId,
|
||||||
ClientId = ClientId,
|
ClientId = ClientId,
|
||||||
|
ImplementerId = ImplementerId,
|
||||||
Count = Count,
|
Count = Count,
|
||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
@ -83,12 +87,11 @@ namespace PizzeriaFileImplement.Models
|
|||||||
new XAttribute("Id", Id),
|
new XAttribute("Id", Id),
|
||||||
new XElement("PizzaId", PizzaId.ToString()),
|
new XElement("PizzaId", PizzaId.ToString()),
|
||||||
new XElement("ClientId", ClientId.ToString()),
|
new XElement("ClientId", ClientId.ToString()),
|
||||||
|
new XElement("ImplementerId", ImplementerId),
|
||||||
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()),
|
||||||
new XElement("DateCreate", DateCreate.ToString()),
|
new XElement("DateCreate", DateCreate.ToString()),
|
||||||
new XElement("DateImplement", DateImplement.ToString()));
|
new XElement("DateImplement", DateImplement.ToString()));
|
||||||
|
|
||||||
public int? ImplementerId => throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -14,6 +14,8 @@ namespace PizzeriaListImplement
|
|||||||
public List<Order> Orders { get; set; }
|
public List<Order> Orders { get; set; }
|
||||||
public List<Pizza> Pizzas { get; set; }
|
public List<Pizza> Pizzas { get; set; }
|
||||||
public List<Client> Clients { get; set; }
|
public List<Client> Clients { get; set; }
|
||||||
|
public List<Implementer> Implementers { get; set; }
|
||||||
|
public List<MessageInfo> Messages { get; set; }
|
||||||
|
|
||||||
private DataListSingleton()
|
private DataListSingleton()
|
||||||
{
|
{
|
||||||
@ -21,6 +23,8 @@ namespace PizzeriaListImplement
|
|||||||
Orders = new List<Order>();
|
Orders = new List<Order>();
|
||||||
Pizzas = new List<Pizza>();
|
Pizzas = new List<Pizza>();
|
||||||
Clients = new List<Client>();
|
Clients = new List<Client>();
|
||||||
|
Implementers = new List<Implementer>();
|
||||||
|
Messages = new List<MessageInfo>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DataListSingleton GetInstance()
|
public static DataListSingleton GetInstance()
|
||||||
|
@ -2,39 +2,117 @@
|
|||||||
using PizzeriaContracts.SearchModels;
|
using PizzeriaContracts.SearchModels;
|
||||||
using PizzeriaContracts.StoragesContracts;
|
using PizzeriaContracts.StoragesContracts;
|
||||||
using PizzeriaContracts.ViewModels;
|
using PizzeriaContracts.ViewModels;
|
||||||
|
using PizzeriaListImplement.Models;
|
||||||
|
|
||||||
namespace PizzeriaListImplement.Implements
|
namespace PizzeriaListImplement.Implements
|
||||||
{
|
{
|
||||||
public class ImplementerStorage : IImplementerStorage
|
public class ImplementerStorage : IImplementerStorage
|
||||||
{
|
{
|
||||||
|
private readonly DataListSingleton _source;
|
||||||
|
public ImplementerStorage()
|
||||||
|
{
|
||||||
|
_source = DataListSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
|
||||||
public ImplementerViewModel? Delete(ImplementerBindingModel model)
|
public ImplementerViewModel? Delete(ImplementerBindingModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
for (int i = 0; i < _source.Implementers.Count; ++i)
|
||||||
|
{
|
||||||
|
if (_source.Implementers[i].Id == model.Id)
|
||||||
|
{
|
||||||
|
var element = _source.Implementers[i];
|
||||||
|
_source.Implementers.RemoveAt(i);
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
foreach (var x in _source.Implementers)
|
||||||
|
{
|
||||||
|
if (model.Id.HasValue && x.Id == model.Id)
|
||||||
|
{
|
||||||
|
return x.GetViewModel;
|
||||||
|
}
|
||||||
|
if (model.ImplementerFIO != null && model.Password != null && x.ImplementerFIO.Equals(model.ImplementerFIO) && x.Password.Equals(model.Password))
|
||||||
|
{
|
||||||
|
return x.GetViewModel;
|
||||||
|
}
|
||||||
|
if (model.ImplementerFIO != null && x.ImplementerFIO.Equals(model.ImplementerFIO))
|
||||||
|
{
|
||||||
|
return x.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
|
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
if (model == null)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
var res = GetElement(model);
|
||||||
|
return res != null ? new() { res } : new();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ImplementerViewModel> result = new();
|
||||||
|
if (model.ImplementerFIO != null)
|
||||||
|
{
|
||||||
|
foreach (var implementer in _source.Implementers)
|
||||||
|
{
|
||||||
|
if (implementer.ImplementerFIO.Equals(model.ImplementerFIO))
|
||||||
|
{
|
||||||
|
result.Add(implementer.GetViewModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ImplementerViewModel> GetFullList()
|
public List<ImplementerViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var result = new List<ImplementerViewModel>();
|
||||||
|
foreach (var implementer in _source.Implementers)
|
||||||
|
{
|
||||||
|
result.Add(implementer.GetViewModel);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImplementerViewModel? Insert(ImplementerBindingModel model)
|
public ImplementerViewModel? Insert(ImplementerBindingModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
model.Id = 1;
|
||||||
|
foreach (var implementer in _source.Implementers)
|
||||||
|
{
|
||||||
|
if (model.Id <= implementer.Id)
|
||||||
|
{
|
||||||
|
model.Id = implementer.Id + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var res = Implementer.Create(model);
|
||||||
|
if (res != null)
|
||||||
|
{
|
||||||
|
_source.Implementers.Add(res);
|
||||||
|
}
|
||||||
|
return res?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImplementerViewModel? Update(ImplementerBindingModel model)
|
public ImplementerViewModel? Update(ImplementerBindingModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
foreach (var implementer in _source.Implementers)
|
||||||
|
{
|
||||||
|
if (implementer.Id == model.Id)
|
||||||
|
{
|
||||||
|
implementer.Update(model);
|
||||||
|
return implementer.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,68 @@
|
|||||||
|
using PizzeriaContracts.BindingModels;
|
||||||
|
using PizzeriaContracts.SearchModels;
|
||||||
|
using PizzeriaContracts.StoragesContracts;
|
||||||
|
using PizzeriaContracts.ViewModels;
|
||||||
|
using PizzeriaListImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PizzeriaListImplement.Implements
|
||||||
|
{
|
||||||
|
public class MessageInfoStorage : IMessageInfoStorage
|
||||||
|
{
|
||||||
|
private readonly DataListSingleton _source;
|
||||||
|
public MessageInfoStorage()
|
||||||
|
{
|
||||||
|
_source = DataListSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MessageInfoViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
List<MessageInfoViewModel> result = new();
|
||||||
|
foreach (var item in _source.Messages)
|
||||||
|
{
|
||||||
|
result.Add(item.GetViewModel);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model)
|
||||||
|
{
|
||||||
|
List<MessageInfoViewModel> result = new();
|
||||||
|
foreach (var item in _source.Messages)
|
||||||
|
{
|
||||||
|
if (item.ClientId.HasValue && item.ClientId == model.ClientId)
|
||||||
|
{
|
||||||
|
result.Add(item.GetViewModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageInfoViewModel? GetElement(MessageInfoSearchModel model)
|
||||||
|
{
|
||||||
|
foreach (var message in _source.Messages)
|
||||||
|
{
|
||||||
|
if (model.MessageId != null && model.MessageId.Equals(message.MessageId))
|
||||||
|
{
|
||||||
|
return message.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageInfoViewModel? Insert(MessageInfoBindingModel model)
|
||||||
|
{
|
||||||
|
var newMessage = MessageInfo.Create(model);
|
||||||
|
if (newMessage == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_source.Messages.Add(newMessage);
|
||||||
|
return newMessage.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -53,6 +53,16 @@ namespace PizzeriaListImplement.Implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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)
|
else if (model.Id.HasValue)
|
||||||
{
|
{
|
||||||
foreach (var order in _source.Orders)
|
foreach (var order in _source.Orders)
|
||||||
@ -100,6 +110,10 @@ namespace PizzeriaListImplement.Implements
|
|||||||
{
|
{
|
||||||
return AttachPizzaName(order.GetViewModel);
|
return AttachPizzaName(order.GetViewModel);
|
||||||
}
|
}
|
||||||
|
else if (model.ImplementerId.HasValue && model.ImplementerId == order.ImplementerId)
|
||||||
|
{
|
||||||
|
return GetViewModel(order);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
60
Pizzeria/PizzeriaListImplement/Models/Implementer.cs
Normal file
60
Pizzeria/PizzeriaListImplement/Models/Implementer.cs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
using PizzeriaContracts.BindingModels;
|
||||||
|
using PizzeriaContracts.ViewModels;
|
||||||
|
using PizzeriaDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PizzeriaListImplement.Models
|
||||||
|
{
|
||||||
|
public class Implementer : IImplementerModel
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Password { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public int WorkExperience { get; private set; }
|
||||||
|
|
||||||
|
public int Qualification { get; private set; }
|
||||||
|
|
||||||
|
public static Implementer? Create(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Password = model.Password,
|
||||||
|
Qualification = model.Qualification,
|
||||||
|
ImplementerFIO = model.ImplementerFIO,
|
||||||
|
WorkExperience = model.WorkExperience,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Password = model.Password;
|
||||||
|
Qualification = model.Qualification;
|
||||||
|
ImplementerFIO = model.ImplementerFIO;
|
||||||
|
WorkExperience = model.WorkExperience;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Password = Password,
|
||||||
|
Qualification = Qualification,
|
||||||
|
ImplementerFIO = ImplementerFIO,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
53
Pizzeria/PizzeriaListImplement/Models/MessageInfo.cs
Normal file
53
Pizzeria/PizzeriaListImplement/Models/MessageInfo.cs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
using PizzeriaContracts.BindingModels;
|
||||||
|
using PizzeriaContracts.ViewModels;
|
||||||
|
using PizzeriaDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PizzeriaListImplement.Models
|
||||||
|
{
|
||||||
|
public class MessageInfo : IMessageInfoModel
|
||||||
|
{
|
||||||
|
public string MessageId { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public int? ClientId { get; private set; }
|
||||||
|
|
||||||
|
public string SenderName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public DateTime DateDelivery { get; private set; } = DateTime.Now;
|
||||||
|
|
||||||
|
public string Subject { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Body { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public static MessageInfo? Create(MessageInfoBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Body = model.Body,
|
||||||
|
Subject = model.Subject,
|
||||||
|
ClientId = model.ClientId,
|
||||||
|
MessageId = model.MessageId,
|
||||||
|
SenderName = model.SenderName,
|
||||||
|
DateDelivery = model.DateDelivery,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageInfoViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Body = Body,
|
||||||
|
Subject = Subject,
|
||||||
|
ClientId = ClientId,
|
||||||
|
MessageId = MessageId,
|
||||||
|
SenderName = SenderName,
|
||||||
|
DateDelivery = DateDelivery,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -15,6 +15,7 @@ namespace PizzeriaListImplement.Models
|
|||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
public int PizzaId { get; private set; }
|
public int PizzaId { get; private set; }
|
||||||
public int ClientId { get; private set; }
|
public int ClientId { get; private set; }
|
||||||
|
public int? ImplementerId { 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.Неизвестен;
|
||||||
@ -32,6 +33,7 @@ namespace PizzeriaListImplement.Models
|
|||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
PizzaId = model.PizzaId,
|
PizzaId = model.PizzaId,
|
||||||
ClientId = model.ClientId,
|
ClientId = model.ClientId,
|
||||||
|
ImplementerId = model.ImplementerId,
|
||||||
Count = model.Count,
|
Count = model.Count,
|
||||||
Sum = model.Sum,
|
Sum = model.Sum,
|
||||||
Status = model.Status,
|
Status = model.Status,
|
||||||
@ -55,13 +57,12 @@ namespace PizzeriaListImplement.Models
|
|||||||
Id = Id,
|
Id = Id,
|
||||||
PizzaId = PizzaId,
|
PizzaId = PizzaId,
|
||||||
ClientId = ClientId,
|
ClientId = ClientId,
|
||||||
|
ImplementerId = ImplementerId,
|
||||||
Count = Count,
|
Count = Count,
|
||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
DateCreate = DateCreate,
|
DateCreate = DateCreate,
|
||||||
DateImplement = DateImplement,
|
DateImplement = DateImplement,
|
||||||
};
|
};
|
||||||
|
|
||||||
public int? ImplementerId => throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,5 +12,5 @@
|
|||||||
"PopHost": "pop.gmail.com",
|
"PopHost": "pop.gmail.com",
|
||||||
"PopPort": "995",
|
"PopPort": "995",
|
||||||
"MailLogin": "laba46466@gmail.com",
|
"MailLogin": "laba46466@gmail.com",
|
||||||
"MailPassword": "klwy ypmv gefu yrug"
|
"MailPassword": "iyin rgai wjdh ocmi"
|
||||||
}
|
}
|
@ -6,6 +6,6 @@
|
|||||||
<add key="PopHost" value="pop.gmail.com" />
|
<add key="PopHost" value="pop.gmail.com" />
|
||||||
<add key="PopPort" value="995" />
|
<add key="PopPort" value="995" />
|
||||||
<add key="MailLogin" value="laba46466@gmail.com" />
|
<add key="MailLogin" value="laba46466@gmail.com" />
|
||||||
<add key="MailPassword" value="klwy ypmv gefu yrug" />
|
<add key="MailPassword" value="iyin rgai wjdh ocmi" />
|
||||||
</appSettings>
|
</appSettings>
|
||||||
</configuration>
|
</configuration>
|
Loading…
Reference in New Issue
Block a user