This commit is contained in:
VictoriaPresnyakova 2023-05-02 14:50:43 +04:00
parent 50ce8a61b1
commit 7a1e2a6849
26 changed files with 439 additions and 261 deletions

View File

@ -34,21 +34,14 @@ namespace JewelryStore
{ {
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["ComponentName"].AutoSizeMode =
DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка компонентов"); _logger.LogInformation("Загрузка компонентов");
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка загрузки компонентов"); _logger.LogError(ex, "Ошибка загрузки компонентов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBoxIcon.Error);
} }
} }

View File

@ -98,22 +98,14 @@ namespace JewelryStore
{ {
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["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка исполнителей"); _logger.LogInformation("Загрузка исполнителей");
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка загрузки исполнителей"); _logger.LogError(ex, "Ошибка загрузки исполнителей");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
} }
} }
} }

View File

@ -29,23 +29,13 @@ namespace JewelryStore
{ {
try try
{ {
var list = _logic.ReadList(null); DataGridView.FillAndConfigGrid(_logic.ReadList(null));
_logger.LogInformation("Загрузка изделий");
if (list != null)
{
DataGridView.DataSource = list;
DataGridView.Columns["Id"].Visible = false;
DataGridView.Columns["JewelName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
DataGridView.Columns["JewelComponents"].Visible = false;
}
_logger.LogInformation("Загрузка компонентов");
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка загрузки компонентов"); _logger.LogError(ex, "Ошибка загрузки изделий");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }

View File

@ -29,15 +29,8 @@ namespace JewelryStore
{ {
try try
{ {
var list = _logic.ReadList(null); dataGridView.FillAndConfigGrid(_logic.ReadList(null));
if (list != null) _logger.LogInformation("Загрузка списка писем");
{
DataGridView.DataSource = list;
DataGridView.Columns["ClientId"].Visible = false;
DataGridView.Columns["MessageId"].Visible = false;
DataGridView.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка писем");
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -42,25 +42,16 @@ namespace JewelryStore
} }
private void LoadData() private void LoadData()
{ {
_logger.LogInformation("Загрузка заказов");
try try
{ {
var list = _orderLogic.ReadList(null); DataGridView.FillAndConfigGrid(_orderLogic.ReadList(null));
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["JewelId"].Visible = false;
dataGridView.Columns["ClientId"].Visible = false;
dataGridView.Columns["ImplementerId"].Visible = false;
}
_logger.LogInformation("Загрузка заказов"); _logger.LogInformation("Загрузка заказов");
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка загрузки заказов"); _logger.LogError(ex, "Ошибка загрузки заказов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
} }
} }

View File

@ -11,30 +11,24 @@ using JewelryStoreBusinessLogic.OfficePackage;
using JewelryStoreBusinessLogic.OfficePackage.Implements; using JewelryStoreBusinessLogic.OfficePackage.Implements;
using JewelryStoreBusinessLogic.MailWorker; using JewelryStoreBusinessLogic.MailWorker;
using JewelryStoreContracts.BindingModels; using JewelryStoreContracts.BindingModels;
using JewelryStoreContracts.DI;
namespace JewelryStore namespace JewelryStore
{ {
internal static class Program internal static class Program
{ {
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
/// <summary> /// <summary>
/// The main entry point for the application. /// The main entry point for the application.
/// </summary> /// </summary>
[STAThread] [STAThread]
static void Main() static void Main()
{ {
// To customize application configuration such as set high DPI
//settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();
var services = new ServiceCollection(); InitDependency();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
try try
{ {
var mailSender = _serviceProvider.GetService<AbstractMailWorker>(); var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>(); mailSender?.MailConfig(new MailConfigBindingModel
mailSender?.MailConfig(new MailConfigBindingModel
{ {
MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty, MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
MailPassword = System.Configuration.ConfigurationManager.AppSettings["MailPassword"] ?? string.Empty, MailPassword = System.Configuration.ConfigurationManager.AppSettings["MailPassword"] ?? string.Empty,
@ -44,62 +38,56 @@ namespace JewelryStore
PopPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PopPort"]) PopPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PopPort"])
}); });
// ñîçäàåì òàéìåð
var timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 100000); var timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 100000);
} }
catch (Exception ex) catch (Exception ex)
{ {
var logger = _serviceProvider.GetService<ILogger>(); var logger = DependencyManager.Instance.Resolve<ILogger>();
logger?.LogError(ex, "Îøèáêà ðàáîòû ñ ïî÷òîé"); logger?.LogError(ex, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
} }
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
} }
private static void ConfigureServices(ServiceCollection services)
private static void InitDependency()
{ {
services.AddLogging(option => DependencyManager.InitDependency();
DependencyManager.Instance.AddLogging(option =>
{ {
option.SetMinimumLevel(LogLevel.Information); option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config"); option.AddNLog("nlog.config");
}); });
services.AddTransient<IComponentStorage, ComponentStorage>(); DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
services.AddTransient<IOrderStorage, OrderStorage>(); DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
services.AddTransient<IJewelStorage, JewelStorage>(); DependencyManager.Instance.RegisterType<IJewelLogic, JewelLogic>();
services.AddTransient<IClientStorage, ClientStorage>(); DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
services.AddTransient<IImplementerStorage, ImplementerStorage>(); DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>(); DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
services.AddTransient<IWorkProcess, WorkModeling>(); DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
services.AddSingleton<AbstractMailWorker, MailKitWorker>(); DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
services.AddTransient<IComponentLogic, ComponentLogic>(); DependencyManager.Instance.RegisterType<FormMain>();
services.AddTransient<IOrderLogic, OrderLogic>(); DependencyManager.Instance.RegisterType<FormComponent>();
services.AddTransient<IJewelLogic, JewelLogic>(); DependencyManager.Instance.RegisterType<FormComponents>();
services.AddTransient<IClientLogic, ClientLogic>(); DependencyManager.Instance.RegisterType<FormCreateOrder>();
services.AddTransient<IReportLogic, ReportLogic>(); DependencyManager.Instance.RegisterType<FormJewel>();
services.AddTransient<IImplementerLogic, ImplementerLogic>(); DependencyManager.Instance.RegisterType<FormJewelComponent>();
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>(); DependencyManager.Instance.RegisterType<FormJewels>();
services.AddTransient<IBackUpLogic, BackUpLogic>(); DependencyManager.Instance.RegisterType<FormReportJewelComponents>();
DependencyManager.Instance.RegisterType<FormReportOrders>();
DependencyManager.Instance.RegisterType<FormClients>();
services.AddTransient<AbstractSaveToExcel, SaveToExcel>(); DependencyManager.Instance.RegisterType<FormImplementers>();
services.AddTransient<AbstractSaveToWord, SaveToWord>(); DependencyManager.Instance.RegisterType<FormImplementer>();
services.AddTransient<AbstractSaveToPdf, SaveToPdf>(); DependencyManager.Instance.RegisterType<FormMails>();
services.AddTransient<FormMain>();
services.AddTransient<FormComponent>();
services.AddTransient<FormComponents>();
services.AddTransient<FormCreateOrder>();
services.AddTransient<FormJewel>();
services.AddTransient<FormJewelComponent>();
services.AddTransient<FormJewels>();
services.AddTransient<FormReportJewelComponents>();
services.AddTransient<FormReportOrders>();
services.AddTransient<FormClients>();
services.AddTransient<FormImplementer>();
services.AddTransient<FormImplementers>();
services.AddTransient<FormMails>();
} }
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck(); private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
} }
} }

View File

@ -0,0 +1,62 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JewelryStoreContracts.DI
{
public class ServiceDependencyContainer : IDependencyContainer
{
private ServiceProvider? _serviceProvider;
private readonly ServiceCollection _serviceCollection;
public ServiceDependencyContainer()
{
_serviceCollection = new ServiceCollection();
}
public void AddLogging(Action<ILoggingBuilder> configure)
{
_serviceCollection.AddLogging(configure);
}
public void RegisterType<T, U>(bool isSingle) where U : class, T where T : class
{
if (isSingle)
{
_serviceCollection.AddSingleton<T, U>();
}
else
{
_serviceCollection.AddTransient<T, U>();
}
_serviceProvider = null;
}
public void RegisterType<T>(bool isSingle) where T : class
{
if (isSingle)
{
_serviceCollection.AddSingleton<T>();
}
else
{
_serviceCollection.AddTransient<T>();
}
_serviceProvider = null;
}
public T Resolve<T>()
{
if (_serviceProvider == null)
{
_serviceProvider = _serviceCollection.BuildServiceProvider();
}
return _serviceProvider.GetService<T>()!;
}
}
}

View File

@ -0,0 +1,42 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity;
using Unity.Microsoft.Logging;
namespace JewelryStoreContracts.DI
{
public class UnityDependencyContainer : IDependencyContainer
{
private readonly IUnityContainer _container;
public UnityDependencyContainer()
{
_container = new UnityContainer();
}
public void AddLogging(Action<ILoggingBuilder> configure)
{
var factory = LoggerFactory.Create(configure);
_container.AddExtension(new LoggingExtension(factory));
}
public void RegisterType<T>(bool isSingle) where T : class
{
_container.RegisterType<T>(isSingle ? TypeLifetime.Singleton : TypeLifetime.Transient);
}
public T Resolve<T>()
{
return _container.Resolve<T>();
}
void IDependencyContainer.RegisterType<T, U>(bool isSingle)
{
_container.RegisterType<T, U>(isSingle ? TypeLifetime.Singleton : TypeLifetime.Transient);
}
}
}

View File

@ -9,6 +9,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" /> <PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
<PackageReference Include="Unity" Version="5.11.10" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,4 +1,5 @@
using JewelryStoreDataModels.Models; using JewelryStoreContracts.Attributes;
using JewelryStoreDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -10,9 +11,13 @@ namespace JewelryStoreContracts.ViewModels
{ {
public class ClientViewModel : IClientModel public class ClientViewModel : IClientModel
{ {
[Column(visible: false)]
public int Id { get; set; } public int Id { get; set; }
[Column("ФИО клиента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string ClientFIO { get; set; } = string.Empty; public string ClientFIO { get; set; } = string.Empty;
[Column("Логин (эл. почта)", width: 150)]
public string Email { get; set; } = string.Empty; public string Email { get; set; } = string.Empty;
[Column("Пароль", width: 150)]
public string Password { get; set; } = string.Empty; public string Password { get; set; } = string.Empty;
} }
} }

View File

@ -1,4 +1,5 @@
using JewelryStoreDataModels.Models; using JewelryStoreContracts.Attributes;
using JewelryStoreDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -10,10 +11,11 @@ namespace JewelryStoreContracts.ViewModels
{ {
public class ComponentViewModel : IComponentModel public class ComponentViewModel : IComponentModel
{ {
[Column(visible: false)]
public int Id { get; set; } public int Id { get; set; }
[DisplayName("Название компонента")] [Column("Название компонента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string ComponentName { get; set; } = string.Empty; public string ComponentName { get; set; } = string.Empty;
[DisplayName("Цена")] [Column("Цена", width: 80)]
public double Cost { get; set; } public double Cost { get; set; }
} }
} }

View File

@ -1,4 +1,5 @@
using JewelryStoreDataModels.Models; using JewelryStoreContracts.Attributes;
using JewelryStoreDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -10,18 +11,16 @@ namespace JewelryStoreContracts.ViewModels
{ {
public class ImplementerViewModel : IImplementerModel public class ImplementerViewModel : IImplementerModel
{ {
[Column(visible: false)]
public int Id { get; set; } public int Id { get; set; }
[Column("ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
[DisplayName("ФИО исполнителя")]
public string ImplementerFIO { get; set; } = string.Empty; public string ImplementerFIO { get; set; } = string.Empty;
[Column("Пароль", width: 150)]
[DisplayName("Пароль")]
public string Password { get; set; } = string.Empty; public string Password { get; set; } = string.Empty;
[Column("Стаж работы", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
[DisplayName("Стаж работы")]
public int WorkExperience { get; set; } public int WorkExperience { get; set; }
[Column("Квалификация", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
[DisplayName("Квалификация")]
public int Qualification { get; set; } public int Qualification { get; set; }
} }
} }

View File

@ -11,9 +11,7 @@ namespace JewelryStoreContracts.ViewModels
public class JewelViewModel : IJewelModel public class JewelViewModel : IJewelModel
{ {
public int Id { get; set; } public int Id { get; set; }
[DisplayName("Название драгоценности")]
public string JewelName { get; set; } = string.Empty; public string JewelName { get; set; } = string.Empty;
[DisplayName("Цена")]
public double Price { get; set; } public double Price { get; set; }
public Dictionary<int, (IComponentModel, int)> JewelComponents public Dictionary<int, (IComponentModel, int)> JewelComponents
{ {

View File

@ -1,4 +1,5 @@
using JewelryStoreDataModels.Models; using JewelryStoreContracts.Attributes;
using JewelryStoreDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -10,20 +11,17 @@ namespace JewelryStoreContracts.ViewModels
{ {
public class MessageInfoViewModel : IMessageInfoModel public class MessageInfoViewModel : IMessageInfoModel
{ {
[Column(visible: false)]
public string MessageId { get; set; } = string.Empty; public string MessageId { get; set; } = string.Empty;
[Column(visible: false)]
public int? ClientId { get; set; } public int? ClientId { get; set; }
[Column("Отправитель", gridViewAutoSize: GridViewAutoSize.DisplayedCells, isUseAutoSize: true)]
[DisplayName("Имя отправителя")]
public string SenderName { get; set; } = string.Empty; public string SenderName { get; set; } = string.Empty;
[Column("Дата письма", width: 100)]
[DisplayName("Дата отправления")]
public DateTime DateDelivery { get; set; } public DateTime DateDelivery { get; set; }
[Column("Заголовок", width: 150)]
[DisplayName("Тема")]
public string Subject { get; set; } = string.Empty; public string Subject { get; set; } = string.Empty;
[Column("Текст", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
[DisplayName("Содержание")]
public string Body { get; set; } = string.Empty; public string Body { get; set; } = string.Empty;
} }
} }

View File

@ -1,4 +1,5 @@
using JewelryStoreDataModels.Enums; using JewelryStoreContracts.Attributes;
using JewelryStoreDataModels.Enums;
using JewelryStoreDataModels.Models; using JewelryStoreDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -11,31 +12,31 @@ namespace JewelryStoreContracts.ViewModels
{ {
public class OrderViewModel : IOrderModel public class OrderViewModel : IOrderModel
{ {
[DisplayName("Номер")]
[Column("Номер", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
public int Id { get; set; } public int Id { get; set; }
[Column(visible: false)]
public int JewelId { get; set; } public int JewelId { get; set; }
[Column(visible: false)]
public int ClientId { get; set; } public int ClientId { get; set; }
[Column("Изделие", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
[DisplayName("Драгоценность")]
public string JewelName { get; set; } = string.Empty; public string JewelName { get; set; } = string.Empty;
[Column("Фамилия исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
[DisplayName("ФИО исполнителя")]
public string ImplementerFIO { get; set; } = string.Empty; public string ImplementerFIO { get; set; } = string.Empty;
[Column("Фамилия клиента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
[DisplayName("Клиент")]
public string ClientFIO { get; set; } = string.Empty; public string ClientFIO { get; set; } = string.Empty;
[Column("Количество", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
[DisplayName("Количество")]
public int Count { get; set; } public int Count { get; set; }
[Column("Сумма", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
[DisplayName("Сумма")]
public double Sum { get; set; } public double Sum { get; set; }
[DisplayName("Статус")] [Column("Статус", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
[DisplayName("Дата создания")] [Column("Дата создания", width: 100)]
public DateTime DateCreate { get; set; } = DateTime.Now; public DateTime DateCreate { get; set; } = DateTime.Now;
[DisplayName("Дата выполнения")] [Column("Дата выполнения", width: 100)]
public DateTime? DateImplement { get; set; } public DateTime? DateImplement { get; set; }
[Column(visible: false)]
public int? ImplementerId { get; set; } public int? ImplementerId { get; set; }
} }

View File

@ -0,0 +1,28 @@
using JewelryStoreContracts.DI;
using JewelryStoreContracts.StoragesContracts;
using JewelryStoreDatabaseImplement.Implements;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JewelryStoreDatabaseImplement
{
public class DatabaseImplementationExtension : IImplementationExtension
{
public int Priority => 2;
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>();
}
}
}

View File

@ -8,17 +8,24 @@ using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Runtime.Serialization;
namespace JewelryStoreDatabaseImplement.Models namespace JewelryStoreDatabaseImplement.Models
{ {
[DataContract]
public class Client : IClientModel public class Client : IClientModel
{ {
[DataMember]
public int Id { get; private set; } public int Id { get; private set; }
[Required] [Required]
[DataMember]
public string ClientFIO { get; set; } = string.Empty; public string ClientFIO { get; set; } = string.Empty;
[Required] [Required]
[DataMember]
public string Email { get; set; } = string.Empty; public string Email { get; set; } = string.Empty;
[Required] [Required]
[DataMember]
public string Password { get; set; } = string.Empty; public string Password { get; set; } = string.Empty;
[ForeignKey("ClientId")] [ForeignKey("ClientId")]

View File

@ -4,17 +4,23 @@ using JewelryStoreDatabaseImplement.Models;
using JewelryStoreDataModels.Models; using JewelryStoreDataModels.Models;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace JewelryStoreDatabaseImplement.Models namespace JewelryStoreDatabaseImplement.Models
{ {
[DataContract]
public class Component : IComponentModel public class Component : IComponentModel
{ {
[DataMember]
public int Id { get; private set; } public int Id { get; private set; }
[Required] [Required]
[DataMember]
public string ComponentName { get; private set; } = string.Empty; public string ComponentName { get; private set; } = string.Empty;
[Required] [Required]
[DataMember]
public double Cost { get; set; } public double Cost { get; set; }
[ForeignKey("ComponentId")] [ForeignKey("ComponentId")]

View File

@ -8,23 +8,31 @@ using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Runtime.Serialization;
namespace JewelryStoreDatabaseImplement.Models namespace JewelryStoreDatabaseImplement.Models
{ {
[DataContract]
public class Implementer : IImplementerModel public class Implementer : IImplementerModel
{ {
[Required] [Required]
[DataMember]
public string ImplementerFIO { get; private set; } = string.Empty; public string ImplementerFIO { get; private set; } = string.Empty;
[Required] [Required]
[DataMember]
public string Password { get; private set; } = string.Empty; public string Password { get; private set; } = string.Empty;
[Required] [Required]
[DataMember]
public int WorkExperience { get; private set; } public int WorkExperience { get; private set; }
[Required] [Required]
[DataMember]
public int Qualification { get; private set; } public int Qualification { get; private set; }
[DataMember]
public int Id { get; private set; } public int Id { get; private set; }
[ForeignKey("ImplementerId")] [ForeignKey("ImplementerId")]

View File

@ -8,22 +8,29 @@ using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Runtime.Serialization;
namespace JewelryStoreDatabaseImplement.Models namespace JewelryStoreDatabaseImplement.Models
{ {
[DataContract]
public class Jewel : IJewelModel public class Jewel : IJewelModel
{ {
[DataMember]
public int Id { get; set; } public int Id { get; set; }
[Required] [Required]
[DataMember]
public string JewelName { get; set; } = string.Empty; public string JewelName { get; set; } = string.Empty;
[Required] [Required]
[DataMember]
public double Price { get; set; } public double Price { get; set; }
private Dictionary<int, (IComponentModel, int)>? _jewelComponents = null; private Dictionary<int, (IComponentModel, int)>? _jewelComponents = null;
[NotMapped] [NotMapped]
[DataMember]
public Dictionary<int, (IComponentModel, int)> JewelComponents public Dictionary<int, (IComponentModel, int)> JewelComponents
{ {
get get

View File

@ -2,22 +2,29 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.Runtime.Serialization;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace JewelryStoreDatabaseImplement.Models namespace JewelryStoreDatabaseImplement.Models
{ {
[DataContract]
public class JewelComponent public class JewelComponent
{ {
[DataMember]
public int Id { get; set; } public int Id { get; set; }
[Required] [Required]
[DataMember]
public int JewelId { get; set; } public int JewelId { get; set; }
[Required] [Required]
[DataMember]
public int ComponentId { get; set; } public int ComponentId { get; set; }
[Required] [Required]
[DataMember]
public int Count { get; set; } public int Count { get; set; }
public virtual Component Component { get; set; } = new(); public virtual Component Component { get; set; } = new();

View File

@ -5,14 +5,18 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.Runtime.Serialization;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace JewelryStoreDatabaseImplement.Models namespace JewelryStoreDatabaseImplement.Models
{ {
[DataContract]
public class Message: IMessageInfoModel public class Message: IMessageInfoModel
{ {
[Key] [Key]
[DataMember]
public string MessageId { get; private set; } = string.Empty; public string MessageId { get; private set; } = string.Empty;
public int? ClientId { get; private set; } public int? ClientId { get; private set; }
[Required] [Required]

View File

@ -8,29 +8,36 @@ using JewelryStoreContracts.BindingModels;
using JewelryStoreDataModels.Models; using JewelryStoreDataModels.Models;
using JewelryStoreDataModels.Enums; using JewelryStoreDataModels.Enums;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
namespace JewelryStoreDatabaseImplement.Models namespace JewelryStoreDatabaseImplement.Models
{ {
[DataContract]
public class Order : IOrderModel public class Order : IOrderModel
{ {
public int Id { get; private set; } public int Id { get; private set; }
[DataMember]
public int JewelId { get; private set; } public int JewelId { get; private set; }
[Required] [Required]
[DataMember]
public int ClientId { get; set; } public int ClientId { get; set; }
[DataMember]
public int? ImplementerId { get; private set; } public int? ImplementerId { get; private set; }
[DataMember]
public string JewelName { get; private set; } = string.Empty; public string JewelName { get; private set; } = string.Empty;
[Required] [Required]
[DataMember]
public int Count { get; private set; } public int Count { get; private set; }
[Required] [Required]
[DataMember]
public double Sum { get; private set; } public double Sum { get; private set; }
[Required] [Required]
[DataMember]
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен; public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
[Required] [Required]

View File

@ -0,0 +1,22 @@
using JewelryStoreContracts.StoragesContracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JewelryStoreListImplement.Implements
{
public class BackUpInfo : IBackUpInfo
{
public List<T>? GetList<T>() where T : class, new()
{
throw new NotImplementedException();
}
public Type? GetTypeByModelInterface(string modelInterfaceName)
{
throw new NotImplementedException();
}
}
}

View File

@ -1,5 +1,6 @@
using JewelryStoreContracts.BindingModels; using JewelryStoreContracts.BindingModels;
using JewelryStoreContracts.SearchModels; using JewelryStoreContracts.SearchModels;
using JewelryStoreContracts.StoragesContracts;
using JewelryStoreContracts.ViewModels; using JewelryStoreContracts.ViewModels;
using JewelryStoreListImplement.Models; using JewelryStoreListImplement.Models;
using System; using System;
@ -10,7 +11,7 @@ using System.Threading.Tasks;
namespace JewelryStoreListImplement.Implements namespace JewelryStoreListImplement.Implements
{ {
public class ImplementerStorage public class ImplementerStorage : IImplementerStorage
{ {
private readonly DataListSingleton _source; private readonly DataListSingleton _source;
public ImplementerStorage() public ImplementerStorage()

View File

@ -0,0 +1,26 @@
using JewelryStoreContracts.DI;
using JewelryStoreContracts.StoragesContracts;
using JewelryStoreListImplement.Implements;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JewelryStoreListImplement
{
public class ListImplementationExtension : IImplementationExtension
{
public int Priority => 0;
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>();
}
}
}