че а ниче

This commit is contained in:
dasha 2023-05-02 21:20:10 +04:00
parent e38f6cc36f
commit 1c7becb81c
26 changed files with 193 additions and 87 deletions

1
.gitignore vendored
View File

@ -14,6 +14,7 @@
# User-specific files (MonoDevelop/Xamarin Studio) # User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs *.userprefs
ImplementationExtensions ImplementationExtensions
BusinessLogicExtensions
# Mono auto generated files # Mono auto generated files
mono_crash.* mono_crash.*

View File

@ -39,6 +39,7 @@ namespace SushiBarView
{ {
column.Width = columnAttr.Width; column.Width = columnAttr.Width;
} }
column.DefaultCellStyle.Format = columnAttr.Format;
} }
} }
} }

View File

@ -1,5 +1,6 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using SushiBarContracts.BusinessLogicsContracts; using SushiBarContracts.BusinessLogicsContracts;
using SushiBarContracts.DI;
namespace SushiBarView namespace SushiBarView
{ {
@ -40,13 +41,7 @@ namespace SushiBarView
CurrentPage = currentPage CurrentPage = currentPage
}); });
} }
if (list != null) dataGridView.FillAndConfigGrid(list);
{
dataGridView.DataSource = list;
dataGridView.Columns["ClientId"].Visible = false;
dataGridView.Columns["MessageId"].Visible = false;
dataGridView.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
labelPage.Text = "c. " + currentPage; labelPage.Text = "c. " + currentPage;
_logger.LogInformation("Загрузка писем"); _logger.LogInformation("Загрузка писем");
} }
@ -75,7 +70,7 @@ namespace SushiBarView
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormMail)); var service = DependencyManager.Instance.Resolve<FormMail>();
if (service is FormMail form) if (service is FormMail form)
{ {
form.MessageId = Convert.ToString(dataGridView.SelectedRows[0].Cells["MessageId"].Value); form.MessageId = Convert.ToString(dataGridView.SelectedRows[0].Cells["MessageId"].Value);

View File

@ -175,7 +175,7 @@ namespace SushiBarView
private void ShopSushiToolStripMenuItem_Click(object sender, EventArgs e) private void ShopSushiToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormReportShopListSushi)); var service = DependencyManager.Instance.Resolve<FormReportShopListSushi>();
if (service is FormReportShopListSushi form) if (service is FormReportShopListSushi form)
{ {
form.ShowDialog(); form.ShowDialog();
@ -193,7 +193,7 @@ namespace SushiBarView
private void OrdersGroupedByDateToolStripMenuItem_Click(object sender, EventArgs e) private void OrdersGroupedByDateToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrdersGroupedByDate)); var service = DependencyManager.Instance.Resolve<FormReportOrdersGroupedByDate>();
if (service is FormReportOrdersGroupedByDate form) if (service is FormReportOrdersGroupedByDate form)
{ {
form.ShowDialog(); form.ShowDialog();
@ -202,7 +202,7 @@ namespace SushiBarView
private void ShopsToolStripMenuItem_Click(object sender, EventArgs e) private void ShopsToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormShops)); var service = DependencyManager.Instance.Resolve<FormShops>();
if (service is FormShops form) if (service is FormShops form)
{ {
form.ShowDialog(); form.ShowDialog();
@ -211,7 +211,7 @@ namespace SushiBarView
private void ButtonAddSushiInShop_Click(object sender, EventArgs e) private void ButtonAddSushiInShop_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormShopSushi)); var service = DependencyManager.Instance.Resolve<FormShopSushi>();
if (service is FormShopSushi form) if (service is FormShopSushi form)
{ {
form.ShowDialog(); form.ShowDialog();
@ -220,7 +220,7 @@ namespace SushiBarView
private void ButtonSellSushi_Click(object sender, EventArgs e) private void ButtonSellSushi_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormSellSushi)); var service = DependencyManager.Instance.Resolve<FormSellSushi>();
if (service is FormSellSushi form) if (service is FormSellSushi form)
{ {
form.ShowDialog(); form.ShowDialog();

View File

@ -1,6 +1,7 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using SushiBarContracts.BindingModels; using SushiBarContracts.BindingModels;
using SushiBarContracts.BusinessLogicsContracts; using SushiBarContracts.BusinessLogicsContracts;
using SushiBarContracts.DI;
namespace SushiBarView namespace SushiBarView
{ {
@ -22,14 +23,7 @@ namespace SushiBarView
{ {
try try
{ {
var list = _logic.ReadList(null); dataGridView.FillAndConfigGrid(_logic.ReadList(null));
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["ListSushi"].Visible = false;
dataGridView.Columns["ShopName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка магазинов"); _logger.LogInformation("Загрузка магазинов");
} }
catch (Exception ex) catch (Exception ex)
@ -41,7 +35,7 @@ namespace SushiBarView
} }
private void ButtonAdd_Click(object sender, EventArgs e) private void ButtonAdd_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormShop)); var service = DependencyManager.Instance.Resolve<FormShop>();
if (service is FormShop form) if (service is FormShop form)
{ {
if (form.ShowDialog() == DialogResult.OK) if (form.ShowDialog() == DialogResult.OK)
@ -54,7 +48,7 @@ namespace SushiBarView
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormShop)); var service = DependencyManager.Instance.Resolve<FormShop>();
if (service is FormShop form) if (service is FormShop form)
{ {
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);

View File

@ -59,23 +59,7 @@ namespace SushiBarView
option.SetMinimumLevel(LogLevel.Information); option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config"); option.AddNLog("nlog.config");
}); });
;
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
DependencyManager.Instance.RegisterType<IIngredientLogic, IngredientLogic>();
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
DependencyManager.Instance.RegisterType<ISushiLogic, SushiLogic>();
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
DependencyManager.Instance.RegisterType<FormMain>(); DependencyManager.Instance.RegisterType<FormMain>();
DependencyManager.Instance.RegisterType<FormClients>(); DependencyManager.Instance.RegisterType<FormClients>();
DependencyManager.Instance.RegisterType<FormIngredient>(); DependencyManager.Instance.RegisterType<FormIngredient>();
@ -89,6 +73,7 @@ namespace SushiBarView
DependencyManager.Instance.RegisterType<FormImplementers>(); DependencyManager.Instance.RegisterType<FormImplementers>();
DependencyManager.Instance.RegisterType<FormImplementer>(); DependencyManager.Instance.RegisterType<FormImplementer>();
DependencyManager.Instance.RegisterType<FormMails>(); DependencyManager.Instance.RegisterType<FormMails>();
DependencyManager.Instance.RegisterType<FormMail>();
} }
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck(); private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();

View File

@ -0,0 +1,34 @@
using SushiBarBusinessLogic.BusinessLogics;
using SushiBarBusinessLogic.MailWorker;
using SushiBarBusinessLogic.OfficePackage.Implements;
using SushiBarBusinessLogic.OfficePackage;
using SushiBarContracts.BusinessLogicsContracts;
using SushiBarContracts.DI;
namespace SushiBarBusinessLogic
{
public class BusinessLogicExtension : IBusinessLogicExtension
{
public int Priority => 0;
public void RegisterServices()
{
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
DependencyManager.Instance.RegisterType<IIngredientLogic, IngredientLogic>();
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
DependencyManager.Instance.RegisterType<ISushiLogic, SushiLogic>();
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
DependencyManager.Instance.RegisterType<IShopLogic, ShopLogic>();
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
}
}
}

View File

@ -23,4 +23,8 @@
<ProjectReference Include="..\SushiBarContracts\SushiBarContracts.csproj" /> <ProjectReference Include="..\SushiBarContracts\SushiBarContracts.csproj" />
</ItemGroup> </ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy /Y &quot;$(TargetDir)*.dll&quot; &quot;$(SolutionDir)BusinessLogicExtensions\*.dll&quot;" />
</Target>
</Project> </Project>

View File

@ -13,13 +13,16 @@
public bool IsUseAutoSize { get; private set; } public bool IsUseAutoSize { get; private set; }
public ColumnAttribute(string title = "", bool visible = true, int width = 0, GridViewAutoSize gridViewAutoSize = GridViewAutoSize.None, bool isUseAutoSize = false) public string Format { get; private set; }
public ColumnAttribute(string title = "", bool visible = true, int width = 0, GridViewAutoSize gridViewAutoSize = GridViewAutoSize.None, bool isUseAutoSize = false, string format = "")
{ {
Title = title; Title = title;
Visible = visible; Visible = visible;
Width = width; Width = width;
GridViewAutoSize = gridViewAutoSize; GridViewAutoSize = gridViewAutoSize;
IsUseAutoSize = isUseAutoSize; IsUseAutoSize = isUseAutoSize;
Format = format;
} }
} }
} }

View File

@ -21,15 +21,17 @@ namespace SushiBarContracts.DI
/// Иницализация библиотек, в которых идут установки зависомстей /// Иницализация библиотек, в которых идут установки зависомстей
/// </summary> /// </summary>
public static void InitDependency() public static void InitDependency()
{ {
var ext = ServiceProviderLoader.GetImplementationExtensions(); var ext = ServiceProviderLoader.GetImplementationExtensions();
if (ext == null) var extLogic = ServiceProviderLoader.GetBusinessLogicExtensions();
if (ext == null || extLogic == null)
{ {
throw new ArgumentNullException("Отсутствуют компоненты для загрузки зависимостей по модулям"); throw new ArgumentNullException("Отсутствуют компоненты для загрузки зависимостей по модулям");
} }
// регистрируем зависимости // регистрируем зависимости
ext.RegisterServices(); ext.RegisterServices();
} extLogic.RegisterServices();
}
/// <summary> /// <summary>
/// Регистрация логгера /// Регистрация логгера

View File

@ -0,0 +1,11 @@
namespace SushiBarContracts.DI
{
public interface IBusinessLogicExtension
{
public int Priority { get; }
/// <summary>
/// Регистрация сервисов
/// </summary>
public void RegisterServices();
}
}

View File

@ -37,6 +37,39 @@ namespace SushiBarContracts.DI
return source; return source;
} }
/// <summary>
/// Загрузка всех классов-реализаций IBusinessLogicExtension
/// </summary>
/// <returns></returns>
public static IBusinessLogicExtension? GetBusinessLogicExtensions()
{
IBusinessLogicExtension? source = null;
var files = Directory.GetFiles(TryGetBusinessLogicExtensionsFolder(), "*.dll", SearchOption.AllDirectories);
foreach (var file in files.Distinct())
{
Assembly asm = Assembly.LoadFrom(file);
foreach (var t in asm.GetExportedTypes())
{
if (t.IsClass && typeof(IBusinessLogicExtension).IsAssignableFrom(t))
{
if (source == null)
{
source = (IBusinessLogicExtension)Activator.CreateInstance(t)!;
}
else
{
var newSource = (IBusinessLogicExtension)Activator.CreateInstance(t)!;
if (newSource.Priority > source.Priority)
{
source = newSource;
}
}
}
}
}
return source;
}
private static string TryGetImplementationExtensionsFolder() private static string TryGetImplementationExtensionsFolder()
{ {
var directory = new DirectoryInfo(Directory.GetCurrentDirectory()); var directory = new DirectoryInfo(Directory.GetCurrentDirectory());
@ -46,5 +79,15 @@ namespace SushiBarContracts.DI
} }
return $"{directory?.FullName}\\ImplementationExtensions"; return $"{directory?.FullName}\\ImplementationExtensions";
} }
private static string TryGetBusinessLogicExtensionsFolder()
{
var directory = new DirectoryInfo(Directory.GetCurrentDirectory());
while (directory != null && !directory.GetDirectories("BusinessLogicExtensions", SearchOption.AllDirectories).Any(x => x.Name == "BusinessLogicExtensions"))
{
directory = directory.Parent;
}
return $"{directory?.FullName}\\BusinessLogicExtensions";
}
} }
} }

View File

@ -9,7 +9,7 @@ namespace SushiBarContracts.ViewModels
public int Id { get; set; } public int Id { get; set; }
[Column(title: "Ингредиент", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] [Column(title: "Ингредиент", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string IngredientName { get; set; } = string.Empty; public string IngredientName { get; set; } = string.Empty;
[Column(title: "Цена", width: 150)] [Column(title: "Цена", width: 150, format: "c2")]
public double Cost { get; set; } public double Cost { get; set; }
} }
} }

View File

@ -1,6 +1,5 @@
using SushiBarContracts.Attributes; using SushiBarContracts.Attributes;
using SushiBarDataModels.Models; using SushiBarDataModels.Models;
using System.ComponentModel;
namespace SushiBarContracts.ViewModels namespace SushiBarContracts.ViewModels
{ {
@ -15,7 +14,7 @@ namespace SushiBarContracts.ViewModels
[Column(title: "Отправитель", width: 150)] [Column(title: "Отправитель", width: 150)]
public string SenderName { get; set; } = string.Empty; public string SenderName { get; set; } = string.Empty;
[Column(title: "Дата письма", width: 150)] [Column(title: "Дата письма", width: 150, format: "g")]
public DateTime DateDelivery { get; set; } public DateTime DateDelivery { get; set; }
[Column(title: "Заголовок", width: 150)] [Column(title: "Заголовок", width: 150)]
@ -26,10 +25,10 @@ namespace SushiBarContracts.ViewModels
[Column(visible: false)] [Column(visible: false)]
public int Id => throw new NotImplementedException(); public int Id => throw new NotImplementedException();
[DisplayName("Прочитано")] [Column(title: "Прочитано", width: 100)]
public bool HasRead { get; set; } public bool HasRead { get; set; }
[DisplayName("Ответ")] [Column(title: "Ответ", width: 150)]
public string? Answer { get; set; } public string? Answer { get; set; }
} }
} }

View File

@ -22,13 +22,13 @@ namespace SushiBarContracts.ViewModels
public string ImplementerFIO { get; set; } = string.Empty; public string ImplementerFIO { get; set; } = string.Empty;
[Column(title: "Количество", width: 100)] [Column(title: "Количество", width: 100)]
public int Count { get; set; } public int Count { get; set; }
[Column(title: "Сумма", width: 50)] [Column(title: "Сумма", width: 80, format: "c2")]
public double Sum { get; set; } public double Sum { get; set; }
[Column(title: "Статус", width: 50)] [Column(title: "Статус", width: 100)]
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
[Column(title: "Дата создания", width: 100)] [Column(title: "Дата создания", width: 100, format: "g")]
public DateTime DateCreate { get; set; } = DateTime.Now; public DateTime DateCreate { get; set; } = DateTime.Now;
[Column(title: "Дата выполнения", width: 100)] [Column(title: "Дата выполнения", width: 100, format: "g")]
public DateTime? DateImplement { get; set; } public DateTime? DateImplement { get; set; }
} }
} }

View File

@ -1,22 +1,21 @@
using SushiBarDataModels.Models; using SushiBarContracts.Attributes;
using System.ComponentModel; using SushiBarDataModels.Models;
namespace SushiBarContracts.ViewModels namespace SushiBarContracts.ViewModels
{ {
public class ShopViewModel : IShopModel public class ShopViewModel : IShopModel
{ {
[Column(visible: false)]
public int Id { get; set; } public int Id { get; set; }
[DisplayName("Название магазина")] [Column(title: "Магазин", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string ShopName { get; set; } = string.Empty; public string ShopName { get; set; } = string.Empty;
[Column(title: "Адрес", width: 80)]
[DisplayName("Адрес магазина")]
public string Address { get; set; } = string.Empty; public string Address { get; set; } = string.Empty;
[Column(title: "Дата открытия", width: 80, format: "d")]
[DisplayName("Дата открытия")]
public DateTime DateOpening { get; set; } = DateTime.Now; public DateTime DateOpening { get; set; } = DateTime.Now;
[DisplayName("Максимальное количество суши")] [Column(title: "Максимальное количество суши", width: 80)]
public int MaxCountSushi { get; set; } public int MaxCountSushi { get; set; }
[Column(visible: false)]
public Dictionary<int, (ISushiModel, int)> ListSushi public Dictionary<int, (ISushiModel, int)> ListSushi
{ {
get; get;

View File

@ -1,6 +1,5 @@
using SushiBarContracts.Attributes; using SushiBarContracts.Attributes;
using SushiBarDataModels.Models; using SushiBarDataModels.Models;
using System.ComponentModel;
namespace SushiBarContracts.ViewModels namespace SushiBarContracts.ViewModels
{ {
@ -10,7 +9,7 @@ namespace SushiBarContracts.ViewModels
public int Id { get; set; } public int Id { get; set; }
[Column(title: "Суши", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] [Column(title: "Суши", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string SushiName { get; set; } = string.Empty; public string SushiName { get; set; } = string.Empty;
[Column(title: "Цена", width: 150)] [Column(title: "Цена", width: 150, format: "c2")]
public double Price { get; set; } public double Price { get; set; }
[Column(visible: false)] [Column(visible: false)]
public Dictionary<int, (IIngredientModel, int)> SushiIngredients public Dictionary<int, (IIngredientModel, int)> SushiIngredients

View File

@ -15,7 +15,8 @@ namespace SushiBarDatabaseImplement
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>(); DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>(); DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>(); DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
DependencyManager.Instance.RegisterType<ISushiStorage, SushiStorage>(); DependencyManager.Instance.RegisterType<ISushiStorage, SushiStorage>();
DependencyManager.Instance.RegisterType<IShopStorage, ShopStorage>();
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>(); DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
} }
} }

View File

@ -26,8 +26,10 @@ namespace SushiBarDatabaseImplement.Models
[DataMember] [DataMember]
[Required] [Required]
public string Body { get; private set; } = string.Empty; public string Body { get; private set; } = string.Empty;
[DataMember]
[Required] [Required]
public bool HasRead { get; set; } public bool HasRead { get; set; }
[DataMember]
public string? Answer { get; set; } public string? Answer { get; set; }
public static Message? Create(MessageInfoBindingModel model) public static Message? Create(MessageInfoBindingModel model)

View File

@ -3,24 +3,30 @@ using SushiBarContracts.ViewModels;
using SushiBarDataModels.Models; using SushiBarDataModels.Models;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Xml.Linq; using System.Runtime.Serialization;
namespace SushiBarDatabaseImplement.Models namespace SushiBarDatabaseImplement.Models
{ {
[DataContract]
public class Shop : IShopModel public class Shop : IShopModel
{ {
[DataMember]
public int Id { get; private set; } public int Id { get; private set; }
[DataMember]
[Required] [Required]
public string ShopName { get; private set; } = string.Empty; public string ShopName { get; private set; } = string.Empty;
[DataMember]
[Required] [Required]
public string Address { get; private set; } = string.Empty; public string Address { get; private set; } = string.Empty;
[DataMember]
[Required] [Required]
public DateTime DateOpening { get; private set; } public DateTime DateOpening { get; private set; }
[DataMember]
[Required] [Required]
public int MaxCountSushi { get; private set; } public int MaxCountSushi { get; private set; }
private Dictionary<int, (ISushiModel, int)>? _shopSushi = null; private Dictionary<int, (ISushiModel, int)>? _shopSushi = null;
[DataMember]
[NotMapped] [NotMapped]
public Dictionary<int, (ISushiModel, int)> ListSushi public Dictionary<int, (ISushiModel, int)> ListSushi
{ {
@ -33,11 +39,11 @@ namespace SushiBarDatabaseImplement.Models
{ {
if (_shopSushi.ContainsKey(x.SushiId)) if (_shopSushi.ContainsKey(x.SushiId))
{ {
_shopSushi[x.SushiId] = (x.Sushi as ISushiModel, _shopSushi[x.SushiId].Item2 + x.Count); _shopSushi[x.SushiId] = (x.Sushi, _shopSushi[x.SushiId].Item2 + x.Count);
} }
else else
{ {
_shopSushi[x.SushiId] = (x.Sushi as ISushiModel, x.Count); _shopSushi[x.SushiId] = (x.Sushi, x.Count);
} }
}); });
} }

View File

@ -17,6 +17,7 @@ namespace SushiBarFileImplement
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>(); DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
DependencyManager.Instance.RegisterType<ISushiStorage, SushiStorage>(); DependencyManager.Instance.RegisterType<ISushiStorage, SushiStorage>();
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>(); DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
DependencyManager.Instance.RegisterType<IShopStorage, ShopStorage>();
} }
} }
} }

View File

@ -22,9 +22,9 @@ namespace SushiBarFileImplement.Models
public string Subject { get; private set; } = string.Empty; public string Subject { get; private set; } = string.Empty;
[DataMember] [DataMember]
public string Body { get; private set; } = string.Empty; public string Body { get; private set; } = string.Empty;
[DataMember]
public bool HasRead { get; set; } public bool HasRead { get; set; }
[DataMember]
public string? Answer { get; set; } public string? Answer { get; set; }
public static Message? Create(MessageInfoBindingModel model) public static Message? Create(MessageInfoBindingModel model)
@ -40,6 +40,9 @@ namespace SushiBarFileImplement.Models
DateDelivery = model.DateDelivery, DateDelivery = model.DateDelivery,
SenderName = model.SenderName, SenderName = model.SenderName,
ClientId = model.ClientId, ClientId = model.ClientId,
MessageId = model.MessageId,
HasRead = model.HasRead,
Answer = model.Answer
}; };
} }
@ -79,14 +82,20 @@ namespace SushiBarFileImplement.Models
DateDelivery = DateDelivery, DateDelivery = DateDelivery,
SenderName = SenderName, SenderName = SenderName,
ClientId = ClientId, ClientId = ClientId,
MessageId = MessageId,
HasRead = HasRead,
Answer = Answer
}; };
public XElement GetXElement => new("MessageInfo", public XElement GetXElement => new("MessageInfo",
new XAttribute("Subject", Subject), new XAttribute("Subject", Subject),
new XAttribute("Body", Body), new XAttribute("Body", Body),
new XAttribute("ClientId", ClientId), new XAttribute("ClientId", ClientId),
new XAttribute("MessageId", MessageId), new XAttribute("MessageId", MessageId),
new XAttribute("SenderName", SenderName), new XAttribute("SenderName", SenderName),
new XAttribute("DateDelivery", DateDelivery),
new XAttribute("HasRead", HasRead),
new XAttribute("Answer", Answer)
); );
public int Id => throw new NotImplementedException(); public int Id => throw new NotImplementedException();

View File

@ -2,17 +2,23 @@
using SushiBarContracts.BindingModels; using SushiBarContracts.BindingModels;
using SushiBarContracts.ViewModels; using SushiBarContracts.ViewModels;
using SushiBarDataModels.Models; using SushiBarDataModels.Models;
using System.Reflection.Metadata; using System.Runtime.Serialization;
using System.Xml.Linq; using System.Xml.Linq;
namespace SushiBarFileImplement.Models namespace SushiBarFileImplement.Models
{ {
[DataContract]
public class Shop : IShopModel public class Shop : IShopModel
{ {
[DataMember]
public int Id { get; private set; } public int Id { get; private set; }
[DataMember]
public string ShopName { get; private set; } = string.Empty; public string ShopName { get; private set; } = string.Empty;
[DataMember]
public string Address { get; private set; } = string.Empty; public string Address { get; private set; } = string.Empty;
[DataMember]
public DateTime DateOpening { get; private set; } public DateTime DateOpening { get; private set; }
[DataMember]
public int MaxCountSushi { get; private set; } public int MaxCountSushi { get; private set; }
public Dictionary<int, int> CountSushi public Dictionary<int, int> CountSushi
{ {
@ -21,6 +27,7 @@ namespace SushiBarFileImplement.Models
} = new(); } = new();
private Dictionary<int, (ISushiModel, int)>? _shopSushi = null; private Dictionary<int, (ISushiModel, int)>? _shopSushi = null;
[DataMember]
public Dictionary<int, (ISushiModel, int)> ListSushi public Dictionary<int, (ISushiModel, int)> ListSushi
{ {
get get

View File

@ -17,6 +17,7 @@ namespace SushiBarListImplement
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>(); DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
DependencyManager.Instance.RegisterType<ISushiStorage, SushiStorage>(); DependencyManager.Instance.RegisterType<ISushiStorage, SushiStorage>();
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>(); DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
DependencyManager.Instance.RegisterType<IShopStorage, ShopStorage>();
} }
} }
} }

View File

@ -1,26 +1,28 @@
using SushiBarContracts.BindingModels; using SushiBarContracts.BindingModels;
using SushiBarContracts.ViewModels; using SushiBarContracts.ViewModels;
using SushiBarDataModels.Models; using SushiBarDataModels.Models;
using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization;
namespace SushiBarListImplement.Models namespace SushiBarListImplement.Models
{ {
[DataContract]
public class Message : IMessageInfoModel public class Message : IMessageInfoModel
{ {
[DataMember]
public string MessageId { get; private set; } = string.Empty; public string MessageId { get; private set; } = string.Empty;
[DataMember]
public int? ClientId { get; private set; } public int? ClientId { get; private set; }
[DataMember]
public string SenderName { get; private set; } = string.Empty; public string SenderName { get; private set; } = string.Empty;
[DataMember]
public DateTime DateDelivery { get; private set; } = DateTime.Now; public DateTime DateDelivery { get; private set; } = DateTime.Now;
[DataMember]
public string Subject { get; private set; } = string.Empty; public string Subject { get; private set; } = string.Empty;
[DataMember]
public string Body { get; private set; } = string.Empty; public string Body { get; private set; } = string.Empty;
[DataMember]
public bool HasRead { get; set; } public bool HasRead { get; set; }
[DataMember]
public string? Answer { get; set; } public string? Answer { get; set; }
public static Message? Create(MessageInfoBindingModel model) public static Message? Create(MessageInfoBindingModel model)

View File

@ -1,15 +1,22 @@
using SushiBarContracts.BindingModels; using SushiBarContracts.BindingModels;
using SushiBarContracts.ViewModels; using SushiBarContracts.ViewModels;
using SushiBarDataModels.Models; using SushiBarDataModels.Models;
using System.Runtime.Serialization;
namespace SushiBarListImplement.Models namespace SushiBarListImplement.Models
{ {
[DataContract]
public class Shop : IShopModel public class Shop : IShopModel
{ {
[DataMember]
public int Id { get; private set; } public int Id { get; private set; }
public string ShopName { get; private set; } = string.Empty; [DataMember]
public string Address { get; private set; } = string.Empty; public string ShopName { get; private set; } = string.Empty;
[DataMember]
public string Address { get; private set; } = string.Empty;
[DataMember]
public DateTime DateOpening { get; private set; } public DateTime DateOpening { get; private set; }
[DataMember]
public Dictionary<int, (ISushiModel, int)> ListSushi public Dictionary<int, (ISushiModel, int)> ListSushi
{ {
get; get;