From 9a55fa9c9fa4010bd5c5b0e86d9d9c1aa57ee6b6 Mon Sep 17 00:00:00 2001 From: VictoriaPresnyakova Date: Tue, 9 May 2023 22:09:41 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JewelryStore/DataGridViewExtension.cs | 9 +- JewelryStore/FormClients.cs | 2 +- JewelryStore/FormComponents.cs | 37 +++--- JewelryStore/FormImplementers.cs | 43 ++++--- JewelryStore/FormJewel.cs | 11 +- JewelryStore/FormJewels.cs | 30 +++-- JewelryStore/FormMails.cs | 2 +- JewelryStore/FormMain.cs | 109 +++++------------- .../DI/UnityDependencyContainer.cs | 7 +- .../JewelryStoreContracts.csproj | 1 + .../ViewModels/JewelViewModel.cs | 15 ++- .../FileImplementationExtension.cs | 27 +++++ .../Implements/BackUpInfo.cs | 37 ++++++ JewelryStoreFileImplement/Models/Client.cs | 13 ++- JewelryStoreFileImplement/Models/Component.cs | 10 +- .../Models/Implementer.cs | 20 ++-- JewelryStoreFileImplement/Models/Jewel.cs | 14 ++- JewelryStoreFileImplement/Models/Message.cs | 12 +- JewelryStoreFileImplement/Models/Order.cs | 38 +++--- 19 files changed, 234 insertions(+), 203 deletions(-) create mode 100644 JewelryStoreFileImplement/FileImplementationExtension.cs create mode 100644 JewelryStoreFileImplement/Implements/BackUpInfo.cs diff --git a/JewelryStore/DataGridViewExtension.cs b/JewelryStore/DataGridViewExtension.cs index e55c84e..0d51ce8 100644 --- a/JewelryStore/DataGridViewExtension.cs +++ b/JewelryStore/DataGridViewExtension.cs @@ -9,33 +9,40 @@ namespace JewelryStore { public static class DataGridViewExtension { - public static void FillAndConfigGrid(this DataGridView grid, List? data) + public static void FillandConfigGrid(this DataGridView grid, List? data) { if (data == null) { return; } + grid.DataSource = data; var type = typeof(T); var properties = type.GetProperties(); + foreach (DataGridViewColumn column in grid.Columns) { var property = properties.FirstOrDefault(x => x.Name == column.Name); + if (property == null) { throw new InvalidOperationException($"В типе {type.Name} не найдено свойство с именем {column.Name}"); } + var attribute = property.GetCustomAttributes(typeof(ColumnAttribute), true)?.SingleOrDefault(); + if (attribute == null) { throw new InvalidOperationException($"Не найден атрибут типа ColumnAttribute для свойства {property.Name}"); } + // ищем нужный нам атрибут if (attribute is ColumnAttribute columnAttr) { column.HeaderText = columnAttr.Title; column.Visible = columnAttr.Visible; + if (columnAttr.IsUseAutoSize) { column.AutoSizeMode = (DataGridViewAutoSizeColumnMode)Enum.Parse(typeof(DataGridViewAutoSizeColumnMode), columnAttr.GridViewAutoSize.ToString()); diff --git a/JewelryStore/FormClients.cs b/JewelryStore/FormClients.cs index ddb75cb..a034728 100644 --- a/JewelryStore/FormClients.cs +++ b/JewelryStore/FormClients.cs @@ -32,7 +32,7 @@ namespace JewelryStore { try { - dataGridView.FillAndConfigGrid(_logic.ReadList(null)); + DataGridView.FillandConfigGrid(_logic.ReadList(null)); _logger.LogInformation("Загрузка клиентов"); } catch (Exception ex) diff --git a/JewelryStore/FormComponents.cs b/JewelryStore/FormComponents.cs index 7f7ae33..c7b9479 100644 --- a/JewelryStore/FormComponents.cs +++ b/JewelryStore/FormComponents.cs @@ -3,6 +3,7 @@ using JewelryStore; using JewelryStoreContracts.BindingModels; using JewelryStoreContracts.BusinessLogicsContracts; using Microsoft.Extensions.Logging; +using JewelryStoreContracts.DI; using System; using System.Collections.Generic; using System.ComponentModel; @@ -34,8 +35,8 @@ namespace JewelryStore { try { - DataGridView.FillAndConfigGrid(_logic.ReadList(null)); - _logger.LogInformation("Загрузка компонентов"); + DataGridView.FillandConfigGrid(_logic.ReadList(null)); + _logger.LogInformation("Загрузка компонентов"); } catch (Exception ex) @@ -47,15 +48,12 @@ namespace JewelryStore private void buttonAdd_Click(object sender, EventArgs e) { - var service = DependencyManager.Instance.Resolve(); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } private void buttonUpdate_Click(object sender, EventArgs e) { @@ -98,17 +96,12 @@ namespace JewelryStore { if (dataGridView.SelectedRows.Count == 1) { - var service = - DependencyManager.Instance.Resolve(); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } } } } \ No newline at end of file diff --git a/JewelryStore/FormImplementers.cs b/JewelryStore/FormImplementers.cs index a0b3664..7df4587 100644 --- a/JewelryStore/FormImplementers.cs +++ b/JewelryStore/FormImplementers.cs @@ -1,5 +1,6 @@ using JewelryStoreContracts.BindingModels; using JewelryStoreContracts.BusinessLogicsContracts; +using JewelryStoreContracts.DI; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; @@ -26,32 +27,28 @@ namespace JewelryStore private void AddButton_Click(object sender, EventArgs e) { - var service = DependencyManager.Instance.Resolve(); - if (service is FormImplementer form) - { - if (form.ShowDialog() == DialogResult.OK) - { - LoadData(); - } - } - } + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } private void ChangeButton_Click(object sender, EventArgs e) { - if (DataGridView.SelectedRows.Count == 1) - { - var service = DependencyManager.Instance.Resolve(); + + form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); + + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } private void DeleteButton_Click(object sender, EventArgs e) { @@ -98,7 +95,7 @@ namespace JewelryStore { try { - dataGridView.FillAndConfigGrid(_logic.ReadList(null)); + DataGridView.FillandConfigGrid(_logic.ReadList(null)); _logger.LogInformation("Загрузка исполнителей"); } catch (Exception ex) diff --git a/JewelryStore/FormJewel.cs b/JewelryStore/FormJewel.cs index 875549c..cbe4856 100644 --- a/JewelryStore/FormJewel.cs +++ b/JewelryStore/FormJewel.cs @@ -1,5 +1,6 @@ using JewelryStoreContracts.BindingModels; using JewelryStoreContracts.BusinessLogicsContracts; +using JewelryStoreContracts.DI; using JewelryStoreContracts.SearchModels; using JewelryStoreDataModels.Models; using Microsoft.Extensions.Logging; @@ -84,9 +85,8 @@ namespace JewelryStore private void buttonAdd_Click(object sender, EventArgs e) { - var service = DependencyManager.Instance.Resolve(); + if (form.ShowDialog() == DialogResult.OK) { if (form.ComponentModel == null) @@ -104,16 +104,13 @@ namespace JewelryStore } LoadData(); } - } - } private void buttonChange_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count == 1) { - var service = DependencyManager.Instance.Resolve(); { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); form.Id = id; diff --git a/JewelryStore/FormJewels.cs b/JewelryStore/FormJewels.cs index 325b7d7..67bcdb0 100644 --- a/JewelryStore/FormJewels.cs +++ b/JewelryStore/FormJewels.cs @@ -11,6 +11,8 @@ using System.Windows.Forms; using JewelryStore; using JewelryStoreContracts.BindingModels; using JewelryStoreContracts.BusinessLogicsContracts; +using JewelryStoreContracts.DI; + namespace JewelryStore { public partial class FormJewels : Form //TODO @@ -29,7 +31,7 @@ namespace JewelryStore { try { - DataGridView.FillAndConfigGrid(_logic.ReadList(null)); + DataGridView.FillandConfigGrid(_logic.ReadList(null)); _logger.LogInformation("Загрузка изделий"); } @@ -42,33 +44,29 @@ namespace JewelryStore private void AddButton_Click(object sender, EventArgs e) { - var service = DependencyManager.Instance.Resolve(); - if (service is FormJewel form) - { + if (form.ShowDialog() == DialogResult.OK) { LoadData(); } - } + } private void ChangeButton_Click(object sender, EventArgs e) { if (DataGridView.SelectedRows.Count == 1) { - var service = DependencyManager.Instance.Resolve(); - if (service is FormJewel form) - { - form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); - if (form.ShowDialog() == DialogResult.OK) - { - LoadData(); - } - } - } - } + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + + } + } private void DeleteButton_Click(object sender, EventArgs e) { if (DataGridView.SelectedRows.Count == 1) diff --git a/JewelryStore/FormMails.cs b/JewelryStore/FormMails.cs index 6e44a70..c4e3000 100644 --- a/JewelryStore/FormMails.cs +++ b/JewelryStore/FormMails.cs @@ -29,7 +29,7 @@ namespace JewelryStore { try { - dataGridView.FillAndConfigGrid(_logic.ReadList(null)); + DataGridView.FillandConfigGrid(_logic.ReadList(null)); _logger.LogInformation("Загрузка списка писем"); } catch (Exception ex) diff --git a/JewelryStore/FormMain.cs b/JewelryStore/FormMain.cs index 0069f7b..d3b04c2 100644 --- a/JewelryStore/FormMain.cs +++ b/JewelryStore/FormMain.cs @@ -45,7 +45,7 @@ namespace JewelryStore { try { - dataGridView.FillAndConfigGrid(_orderLogic.ReadList(null)); + dataGridView.FillandConfigGrid(_orderLogic.ReadList(null)); _logger.LogInformation("Загрузка заказов"); } catch (Exception ex) @@ -58,30 +58,23 @@ namespace JewelryStore private void компонентыToolStripMenuItem_Click(object sender, EventArgs e) { - var form = DependencyManager.Instance.Resolve; + var form = DependencyManager.Instance.Resolve(); form.ShowDialog(); } private void драгоценностиToolStripMenuItem_Click(object sender, EventArgs e) { - var service = DependencyManager.Instance.Resolve(); + form.ShowDialog(); + } private void buttonCreate_Click(object sender, EventArgs e) { - var service = DependencyManager.Instance.Resolve(); + form.ShowDialog(); + LoadData(); + } private void buttonToWork_Click(object sender, EventArgs e) { @@ -93,15 +86,7 @@ namespace JewelryStore { var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { - Id = id, - //JewelId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["JewelId"].Value), - //ClientId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ClientId"].Value), - //ImplementerId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ImplementerId"].Value), - //JewelName = dataGridView.SelectedRows[0].Cells["JewelName"].Value.ToString(), - //Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), - //Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), - //Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), - //DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), + Id = id }); if (!operationResult) { @@ -129,15 +114,7 @@ namespace JewelryStore { var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { - Id = id, - //JewelId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["JewelId"].Value), - //ClientId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ClientId"].Value), - //ImplementerId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ImplementerId"].Value), - //JewelName = dataGridView.SelectedRows[0].Cells["JewelName"].Value.ToString(), - //Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), - //Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), - //Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), - //DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), + Id = id }); if (!operationResult) { @@ -165,15 +142,7 @@ namespace JewelryStore var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { - Id = id, - //JewelId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["JewelId"].Value), - //ClientId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ClientId"].Value), - //ImplementerId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ImplementerId"].Value), - //JewelName = dataGridView.SelectedRows[0].Cells["JewelName"].Value.ToString(), - //Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), - //Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), - //Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), - //DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), + Id = id }); if (!operationResult) { @@ -212,58 +181,40 @@ namespace JewelryStore private void компонентыПоИзделиямToolStripMenuItem_Click(object sender, EventArgs e) { - var service = - DependencyManager.Instance.Resolve(); + form.ShowDialog(); + } private void списокЗаказзовToolStripMenuItem_Click(object sender, EventArgs e) { - var service = DependencyManager.Instance.Resolve(); + form.ShowDialog(); + } private void клиентыToolStripMenuItem_Click(object sender, EventArgs e) { - var service = DependencyManager.Instance.Resolve(); + form.ShowDialog(); + } private void запускРаботToolStripMenuItem_Click(object sender, EventArgs e) { { - _workProcess.DoWork(( DependencyManager.Instance.Resolve(), _orderLogic); + MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + } } private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e) { - var service = DependencyManager.Instance.Resolve(); + form.ShowDialog(); + } private void элПисьмаToolStripMenuItem_Click(object sender, EventArgs e) { - var service = DependencyManager.Instance.Resolve(); + form.ShowDialog(); + } private void создатьБекапToolStripMenuItem_Click(object sender, EventArgs e) { diff --git a/JewelryStoreContracts/DI/UnityDependencyContainer.cs b/JewelryStoreContracts/DI/UnityDependencyContainer.cs index e83532e..9217e41 100644 --- a/JewelryStoreContracts/DI/UnityDependencyContainer.cs +++ b/JewelryStoreContracts/DI/UnityDependencyContainer.cs @@ -1,10 +1,7 @@ using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.ComponentModel; using Unity; +using Unity.Lifetime; using Unity.Microsoft.Logging; namespace JewelryStoreContracts.DI { diff --git a/JewelryStoreContracts/JewelryStoreContracts.csproj b/JewelryStoreContracts/JewelryStoreContracts.csproj index 0d7edcf..156d360 100644 --- a/JewelryStoreContracts/JewelryStoreContracts.csproj +++ b/JewelryStoreContracts/JewelryStoreContracts.csproj @@ -10,6 +10,7 @@ + diff --git a/JewelryStoreContracts/ViewModels/JewelViewModel.cs b/JewelryStoreContracts/ViewModels/JewelViewModel.cs index bae786d..e68f13f 100644 --- a/JewelryStoreContracts/ViewModels/JewelViewModel.cs +++ b/JewelryStoreContracts/ViewModels/JewelViewModel.cs @@ -1,4 +1,5 @@ -using JewelryStoreDataModels.Models; +using JewelryStoreContracts.Attributes; +using JewelryStoreDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel; @@ -10,10 +11,14 @@ namespace JewelryStoreContracts.ViewModels { public class JewelViewModel : IJewelModel { - public int Id { get; set; } - public string JewelName { get; set; } = string.Empty; - public double Price { get; set; } - public Dictionary JewelComponents + [Column(visible: false)] + public int Id { get; set; } + [Column("Название изделия", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] + public string JewelName { get; set; } = string.Empty; + [Column("Цена", width: 100)] + public double Price { get; set; } + [Column(visible: false)] + public Dictionary JewelComponents { get; set; diff --git a/JewelryStoreFileImplement/FileImplementationExtension.cs b/JewelryStoreFileImplement/FileImplementationExtension.cs new file mode 100644 index 0000000..6840af2 --- /dev/null +++ b/JewelryStoreFileImplement/FileImplementationExtension.cs @@ -0,0 +1,27 @@ +using JewelryStoreContracts.DI; +using JewelryStoreContracts.StoragesContracts; +using JewelryStoreFileImplement.Implements; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace JewelryStoreFileImplement +{ + public class FileImplementationExtension : IImplementationExtension + { + public int Priority => 1; + + public void RegisterServices() + { + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + } + } +} diff --git a/JewelryStoreFileImplement/Implements/BackUpInfo.cs b/JewelryStoreFileImplement/Implements/BackUpInfo.cs new file mode 100644 index 0000000..abd6713 --- /dev/null +++ b/JewelryStoreFileImplement/Implements/BackUpInfo.cs @@ -0,0 +1,37 @@ +using JewelryStoreContracts.StoragesContracts; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace JewelryStoreFileImplement.Implements +{ + public class BackUpInfo : IBackUpInfo + { + public List? GetList() where T : class, new() + { + var source = DataFileSingleton.GetInstance(); + + return (List?)source.GetType().GetProperties() + .FirstOrDefault(x => x.PropertyType.IsGenericType && x.PropertyType.GetGenericArguments()[0] == typeof(T)) + ?.GetValue(source); + } + + public Type? GetTypeByModelInterface(string modelInterfaceName) + { + var assembly = typeof(BackUpInfo).Assembly; + var types = assembly.GetTypes(); + + foreach (var type in types) + { + if (type.IsClass && type.GetInterface(modelInterfaceName) != null) + { + return type; + } + } + + return null; + } + } +} diff --git a/JewelryStoreFileImplement/Models/Client.cs b/JewelryStoreFileImplement/Models/Client.cs index 3ee800a..9fb90b5 100644 --- a/JewelryStoreFileImplement/Models/Client.cs +++ b/JewelryStoreFileImplement/Models/Client.cs @@ -4,6 +4,7 @@ using JewelryStoreDataModels.Models; using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; @@ -12,10 +13,14 @@ namespace JewelryStoreFileImplement.Models { public class Client : IClientModel { - public int Id { get; private set; } - public string ClientFIO { get; private set; } = string.Empty; - public string Email { get; set; } = string.Empty; - public string Password { get; set; } = string.Empty; + [DataMember] + public int Id { get; private set; } + [DataMember] + public string ClientFIO { get; private set; } = string.Empty; + [DataMember] + public string Email { get; set; } = string.Empty; + [DataMember] + public string Password { get; set; } = string.Empty; public static Client? Create(ClientBindingModel model) { if (model == null) diff --git a/JewelryStoreFileImplement/Models/Component.cs b/JewelryStoreFileImplement/Models/Component.cs index 634fb12..4591750 100644 --- a/JewelryStoreFileImplement/Models/Component.cs +++ b/JewelryStoreFileImplement/Models/Component.cs @@ -4,6 +4,7 @@ using JewelryStoreDataModels.Models; using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; @@ -12,9 +13,12 @@ namespace JewelryStoreFileImplement.Models { public class Component : IComponentModel { - public int Id { get; private set; } - public string ComponentName { get; private set; } = string.Empty; - public double Cost { get; set; } + [DataMember] + public int Id { get; private set; } + [DataMember] + public string ComponentName { get; private set; } = string.Empty; + [DataMember] + public double Cost { get; set; } public static Component? Create(ComponentBindingModel? model) { diff --git a/JewelryStoreFileImplement/Models/Implementer.cs b/JewelryStoreFileImplement/Models/Implementer.cs index e6b305f..11e1720 100644 --- a/JewelryStoreFileImplement/Models/Implementer.cs +++ b/JewelryStoreFileImplement/Models/Implementer.cs @@ -4,6 +4,7 @@ using JewelryStoreDataModels.Models; using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; @@ -12,15 +13,16 @@ namespace JewelryStoreFileImplement.Models { public class Implementer : IImplementerModel { - 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 int Id { get; private set; } + [DataMember] + public string ImplementerFIO { get; private set; } = string.Empty; + [DataMember] + public string Password { get; private set; } = string.Empty; + [DataMember] + public int WorkExperience { get; private set; } + [DataMember] + public int Qualification { get; private set; } + [DataMember] + public int Id { get; private set; } public static Implementer? Create(XElement element) { diff --git a/JewelryStoreFileImplement/Models/Jewel.cs b/JewelryStoreFileImplement/Models/Jewel.cs index 0f171bd..d2b8844 100644 --- a/JewelryStoreFileImplement/Models/Jewel.cs +++ b/JewelryStoreFileImplement/Models/Jewel.cs @@ -7,18 +7,22 @@ using System.Text; using System.Threading.Tasks; using JewelryStoreContracts.BindingModels; using System.Xml.Linq; +using System.Runtime.Serialization; namespace JewelryStoreFileImplement.Models { public class Jewel: IJewelModel { - public int Id { get; private set; } - public string JewelName { get; private set; } = string.Empty; - public double Price { get; private set; } + [DataMember] + public int Id { get; private set; } + [DataMember] + public string JewelName { get; private set; } = string.Empty; + [DataMember] + public double Price { get; private set; } public Dictionary Components { get; private set; } = new(); private Dictionary? _productComponents = null; - - public Dictionary JewelComponents + [DataMember] + public Dictionary JewelComponents { get { diff --git a/JewelryStoreFileImplement/Models/Message.cs b/JewelryStoreFileImplement/Models/Message.cs index 03ba95d..f9d46e7 100644 --- a/JewelryStoreFileImplement/Models/Message.cs +++ b/JewelryStoreFileImplement/Models/Message.cs @@ -4,6 +4,7 @@ using JewelryStoreDataModels.Models; using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; @@ -12,16 +13,17 @@ namespace JewelryStoreFileImplement.Models { public class Message : IMessageInfoModel { + [DataMember] public string MessageId { get; private set; } = string.Empty; - + [DataMember] public int? ClientId { get; private set; } - + [DataMember] public string SenderName { get; private set; } = string.Empty; - + [DataMember] public DateTime DateDelivery { get; private set; } = DateTime.Now; - + [DataMember] public string Subject { get; private set; } = string.Empty; - + [DataMember] public string Body { get; private set; } = string.Empty; public static Message? Create(MessageInfoBindingModel model) diff --git a/JewelryStoreFileImplement/Models/Order.cs b/JewelryStoreFileImplement/Models/Order.cs index 23bcf7c..f106c17 100644 --- a/JewelryStoreFileImplement/Models/Order.cs +++ b/JewelryStoreFileImplement/Models/Order.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Reflection; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; @@ -14,23 +15,26 @@ namespace JewelryStoreFileImplement.Models { public class Order : IOrderModel { - public int JewelId { get; private set; } - public int ClientId { get; private set; } - - public string JewelName { get; private set; } = string.Empty; - public int? ImplementerId { get; private set; } - - public int Count { get; private set; } - - public double Sum { get; private set; } - - public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен; - - public DateTime DateCreate { get; private set; } = DateTime.Now; - - public DateTime? DateImplement { get; private set; } - - public int Id { get; private set; } + [DataMember] + public int JewelId { get; private set; } + [DataMember] + public int ClientId { get; private set; } + [DataMember] + public string JewelName { get; private set; } = string.Empty; + [DataMember] + public int? ImplementerId { get; private set; } + [DataMember] + public int Count { get; private set; } + [DataMember] + public double Sum { get; private set; } + [DataMember] + public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен; + [DataMember] + public DateTime DateCreate { get; private set; } = DateTime.Now; + [DataMember] + public DateTime? DateImplement { get; private set; } + [DataMember] + public int Id { get; private set; } public static Order? Create(OrderBindingModel model) {