ошибки
This commit is contained in:
parent
ee7089972d
commit
9a55fa9c9f
@ -9,33 +9,40 @@ namespace JewelryStore
|
||||
{
|
||||
public static class DataGridViewExtension
|
||||
{
|
||||
public static void FillAndConfigGrid<T>(this DataGridView grid, List<T>? data)
|
||||
public static void FillandConfigGrid<T>(this DataGridView grid, List<T>? 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());
|
||||
|
@ -32,7 +32,7 @@ namespace JewelryStore
|
||||
{
|
||||
try
|
||||
{
|
||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||
DataGridView.FillandConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Загрузка клиентов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -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<FormComponent));
|
||||
if (service is FormComponent form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormComponent>();
|
||||
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<FormComponent));
|
||||
if (service is FormComponent form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormComponent>();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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<FormImplementer));
|
||||
var form = DependencyManager.Instance.Resolve<FormImplementer>();
|
||||
|
||||
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<FormImplementer));
|
||||
if (service is FormImplementer form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (DataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var form = DependencyManager.Instance.Resolve<FormImplementer>();
|
||||
|
||||
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)
|
||||
|
@ -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<FormJewelComponent));
|
||||
if (service is FormJewelComponent form)
|
||||
{
|
||||
var form = DependencyManager.Instance.Resolve<FormJewelComponent>();
|
||||
|
||||
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<FormJewelComponent));
|
||||
if (service is FormJewelComponent form)
|
||||
var form = DependencyManager.Instance.Resolve<FormJewelComponent>();
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||
form.Id = id;
|
||||
|
@ -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<FormJewel));
|
||||
var form = DependencyManager.Instance.Resolve<FormJewel>();
|
||||
|
||||
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<FormJewel));
|
||||
var form = DependencyManager.Instance.Resolve<FormJewel>();
|
||||
|
||||
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)
|
||||
|
@ -29,7 +29,7 @@ namespace JewelryStore
|
||||
{
|
||||
try
|
||||
{
|
||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||
DataGridView.FillandConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Загрузка списка писем");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -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<FormComponents>;
|
||||
var form = DependencyManager.Instance.Resolve<FormComponents>();
|
||||
form.ShowDialog();
|
||||
|
||||
}
|
||||
|
||||
private void драгоценностиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = DependencyManager.Instance.Resolve<FormJewels));
|
||||
|
||||
if (service is FormJewels form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormJewels>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
private void buttonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = DependencyManager.Instance.Resolve<FormCreateOrder));
|
||||
if (service is FormCreateOrder form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormCreateOrder>();
|
||||
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<OrderStatus>(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<OrderStatus>(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<OrderStatus>(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<FormReportJewelComponents));
|
||||
if (service is FormReportJewelComponents form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormReportJewelComponents>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
private void списокЗаказзовToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = DependencyManager.Instance.Resolve<FormReportOrders));
|
||||
if (service is FormReportOrders form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormReportOrders>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = DependencyManager.Instance.Resolve<FormClients));
|
||||
if (service is FormClients form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormClients>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
private void запускРаботToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
{
|
||||
|
||||
_workProcess.DoWork(( DependencyManager.Instance.Resolve<IImplementerLogic)) as IImplementerLogic)!, _orderLogic);
|
||||
MessageBox.Show("Процесс обработки запущен", "Сообщение",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
_workProcess.DoWork(DependencyManager.Instance.Resolve<IImplementerLogic>(), _orderLogic);
|
||||
MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = DependencyManager.Instance.Resolve<FormImplementers));
|
||||
|
||||
if (service is FormImplementers form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormImplementers>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
private void элПисьмаToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = DependencyManager.Instance.Resolve<FormMails));
|
||||
if (service is FormMails form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormMails>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
private void создатьБекапToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -10,6 +10,7 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||
<PackageReference Include="Unity" Version="5.11.10" />
|
||||
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -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<int, (IComponentModel, int)> 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<int, (IComponentModel, int)> JewelComponents
|
||||
{
|
||||
get;
|
||||
set;
|
||||
|
27
JewelryStoreFileImplement/FileImplementationExtension.cs
Normal file
27
JewelryStoreFileImplement/FileImplementationExtension.cs
Normal file
@ -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<IClientStorage, ClientStorage>();
|
||||
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
|
||||
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||
DependencyManager.Instance.RegisterType<IJewelStorage, JewelStorage>();
|
||||
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||
}
|
||||
}
|
||||
}
|
37
JewelryStoreFileImplement/Implements/BackUpInfo.cs
Normal file
37
JewelryStoreFileImplement/Implements/BackUpInfo.cs
Normal file
@ -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<T>? GetList<T>() where T : class, new()
|
||||
{
|
||||
var source = DataFileSingleton.GetInstance();
|
||||
|
||||
return (List<T>?)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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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)
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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<int, int> Components { get; private set; } = new();
|
||||
private Dictionary<int, (IComponentModel, int)>? _productComponents = null;
|
||||
|
||||
public Dictionary<int, (IComponentModel, int)> JewelComponents
|
||||
[DataMember]
|
||||
public Dictionary<int, (IComponentModel, int)> JewelComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user