one step is required

This commit is contained in:
Viltskaa 2023-05-04 16:10:15 +04:00
parent fe06793f3c
commit 8fdc5bc1cc
25 changed files with 389 additions and 263 deletions

View File

@ -1,6 +1,7 @@
using Microsoft.Extensions.Logging;
using SushiBarContracts.BindingModels;
using SushiBarContracts.BusinessLogicsContracts;
using SushiBarContracts.DI;
namespace SushiBar
{
@ -18,39 +19,32 @@ namespace SushiBar
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormComponent));
if (service is FormComponent form)
{
if (form.ShowDialog() == DialogResult.OK)
var service = DependencyManager.Instance.Resolve<FormComponent>();
if (service is not { }) return;
if (service.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonEdit_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormComponent));
if (service is FormComponent form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
if (dataGridView.SelectedRows.Count != 1) return;
var service = DependencyManager.Instance.Resolve<FormComponent>();
if (service is not { }) return;
service.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (service.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonRemove_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Delete record?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (dataGridView.SelectedRows.Count != 1) return;
if (MessageBox.Show("Delete record?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) !=
DialogResult.Yes) return;
var id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Delete component");
try
{
@ -69,8 +63,6 @@ namespace SushiBar
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonReload_Click(object sender, EventArgs e)
{

View File

@ -1,6 +1,7 @@
using Microsoft.Extensions.Logging;
using SushiBarContracts.BindingModels;
using SushiBarContracts.BusinessLogicsContracts;
using SushiBarContracts.DI;
namespace SushiBar
{
@ -17,31 +18,24 @@ namespace SushiBar
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
if (service is FormImplementer form)
{
if (form.ShowDialog() == DialogResult.OK)
var service = DependencyManager.Instance.Resolve<FormImplementer>();
if (service.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonEdit_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
if (service is FormImplementer form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
if (dataGridView.SelectedRows.Count != 1) return;
var service = DependencyManager.Instance.Resolve<FormImplementer>();
if (service == null) return;
service.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (service.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDelete_Click(object sender, EventArgs e)
{

View File

@ -1,7 +1,9 @@
using Microsoft.Extensions.Logging;
using SushiBarBusinessLogic.BusinessLogics;
using SushiBarContracts.Attributes;
using SushiBarContracts.BindingModels;
using SushiBarContracts.BusinessLogicsContracts;
using SushiBarContracts.DI;
using SushiBarDataModels.Enums;
namespace SushiBar
@ -32,34 +34,15 @@ namespace SushiBar
private void LoadData()
{
_logger.LogInformation("Load components");
try
{
var list = _orderLogic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["SushiId"].Visible = false;
dataGridView.Columns["ClientId"].Visible = false;
dataGridView.Columns["ImplementerId"].Visible = false;
dataGridView.Columns["ClientFio"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Error on load orders");
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
dataGridView.FillAndConfigGrid(_orderLogic.ReadList(null));
}
private void ButtonCreateOrder_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
if (service is FormCreateOrder form)
{
form.ShowDialog();
var service = DependencyManager.Instance.Resolve<FormCreateOrder>();
service.ShowDialog();
LoadData();
}
}
private void ButtonSubmit_Click(object sender, EventArgs e)
{
@ -96,9 +79,8 @@ namespace SushiBar
private void ButtonReady_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (dataGridView.SelectedRows.Count != 1) return;
var id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Order №{id}. Change status on -Ready",id);
try
{
@ -123,15 +105,13 @@ namespace SushiBar
_logger.LogError(ex, "Error on change status");
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void ButtonIssue_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (dataGridView.SelectedRows.Count != 1) return;
var id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Order №{id}. Change status on -Issued", id);
try
{
@ -158,7 +138,6 @@ namespace SushiBar
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void ButtonReload_Click(object sender, EventArgs e)
{
@ -172,85 +151,61 @@ namespace SushiBar
private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
if (service is FormComponents form)
{
form.ShowDialog();
}
var service = DependencyManager.Instance.Resolve<FormComponents>();
service.ShowDialog();
}
private void SushiToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormSushiMoreThenOne));
if (service is FormSushiMoreThenOne form)
{
form.ShowDialog();
}
var service = DependencyManager.Instance.Resolve<FormSushiMoreThenOne>();
service.ShowDialog();
}
private void ListComponentsToolStripMenuItem_Click(object sender, EventArgs e)
{
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
if (dialog.ShowDialog() == DialogResult.OK)
{
if (dialog.ShowDialog() != DialogResult.OK) return;
_reportLogic.SaveSushiToWordFile(new ReportBindingModel
{
FileName = dialog.FileName
});
MessageBox.Show("Complete", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void ComponentsOnSushiToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormSushiOnComponents));
if (service is FormSushiOnComponents form)
{
form.ShowDialog();
}
var service = DependencyManager.Instance.Resolve<FormSushiOnComponents>();
service.ShowDialog();
}
private void ListOrdersToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
if (service is FormReportOrders form)
{
form.ShowDialog();
}
var service = DependencyManager.Instance.Resolve<FormReportOrders>();
service.ShowDialog();
}
private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
if (service is FormClients form)
{
form.ShowDialog();
}
var service = DependencyManager.Instance.Resolve<FormClients>();
service.ShowDialog();
}
private void StartWorkToolStripMenuItem_Click(object sender, EventArgs e)
{
_workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic);
_workProcess.DoWork(DependencyManager.Instance.Resolve<IImplementerLogic>(), _orderLogic);
MessageBox.Show("Process work is started", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void ImplementersToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormImplementers));
if (service is FormImplementers form)
{
form.ShowDialog();
}
var service = DependencyManager.Instance.Resolve<FormImplementers>();
service.ShowDialog();
}
private void MailsToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormMails));
if (service is FormMails form)
{
form.ShowDialog();
}
var service = DependencyManager.Instance.Resolve<FormMails>();
service.ShowDialog();
}
private void CreateBackupStripMenuItem_Click(object sender, EventArgs e)
@ -266,7 +221,6 @@ namespace SushiBar
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

View File

@ -1,6 +1,7 @@
using Microsoft.Extensions.Logging;
using SushiBarContracts.BindingModels;
using SushiBarContracts.BusinessLogicsContracts;
using SushiBarContracts.DI;
using SushiBarContracts.SearchModels;
using SushiBarDataModels.Models;
@ -27,8 +28,7 @@ namespace SushiBar
_logger.LogInformation("Load components");
try
{
if (_sushiComponents != null)
{
if (_sushiComponents == null) return;
dataGridView.Rows.Clear();
foreach (var pc in _sushiComponents)
{
@ -36,7 +36,6 @@ namespace SushiBar
}
textBoxPrice.Text = CalcPrice().ToString();
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Error loading components for sushi");
@ -82,7 +81,7 @@ namespace SushiBar
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormSushiComponent));
var service = DependencyManager.Instance.Resolve<FormSushiComponent>();
if (service is FormSushiComponent form)
{
if (form.ShowDialog() == DialogResult.OK)
@ -109,7 +108,7 @@ namespace SushiBar
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormSushiComponent));
var service = DependencyManager.Instance.Resolve<FormSushiComponent>();
if (service is FormSushiComponent form)
{
int id =

View File

@ -1,6 +1,7 @@
using Microsoft.Extensions.Logging;
using SushiBarContracts.BindingModels;
using SushiBarContracts.BusinessLogicsContracts;
using SushiBarContracts.DI;
namespace SushiBar
{
@ -38,7 +39,7 @@ namespace SushiBar
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormSushi));
var service = DependencyManager.Instance.Resolve<FormSushi>();
if (service is FormSushi form)
{
if (form.ShowDialog() == DialogResult.OK)
@ -52,7 +53,7 @@ namespace SushiBar
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormSushi));
var service = DependencyManager.Instance.Resolve<FormSushi>();
if (service is FormSushi form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);

View File

@ -1,4 +1,3 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using SushiBarBusinessLogic.BusinessLogics;
@ -7,26 +6,20 @@ using SushiBarBusinessLogic.OfficePackage;
using SushiBarBusinessLogic.OfficePackage.Implements;
using SushiBarContracts.BindingModels;
using SushiBarContracts.BusinessLogicsContracts;
using SushiBarContracts.StoragesContracts;
using SushiBarDatabaseImplement.Implements;
using SushiBarContracts.DI;
namespace SushiBar
{
internal static class Program
{
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
[STAThread]
static void Main()
{
ApplicationConfiguration.Initialize();
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
InitDependency();
try
{
var mailSender = _serviceProvider.GetService<AbstractMailWorker>();
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
mailSender?.MailConfig(new MailConfigBindingModel
{
MailLogin =
@ -49,56 +42,54 @@ namespace SushiBar
}
catch(Exception ex)
{
var logger = _serviceProvider.GetService<ILogger>();
var logger = DependencyManager.Instance.Resolve<ILogger>();
logger?.LogError(ex, "Error on working w/ email");
}
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
}
private static void ConfigureServices(IServiceCollection services)
private static void InitDependency()
{
services.AddLogging(option =>
DependencyManager.InitDependency();
DependencyManager.Instance.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
services.AddTransient<IComponentStorage, ComponentStorage>();
services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<ISushiStorage, SushiStorage>();
services.AddTransient<IClientStorage, ClientStorage>();
services.AddTransient<IImplementerStorage, ImplementerStorage>();
services.AddTransient<IMessageInfoStorage, MessageStorage>();
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
DependencyManager.Instance.RegisterType<ISushiLogic, SushiLogic>();
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<ISushiLogic, SushiLogic>();
services.AddTransient<IReportLogic, ReportLogic>();
services.AddTransient<IClientLogic, ClientLogic>();
services.AddTransient<IImplementerLogic, ImplementerLogic>();
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
services.AddTransient<IBackUpLogic, BackUpLogic>();
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
services.AddTransient<IWorkProcess, WorkModeling>();
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
services.AddTransient<AbstractSaveToWord, SaveToWord>();
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
services.AddTransient<FormMain>();
services.AddTransient<FormComponent>();
services.AddTransient<FormComponents>();
services.AddTransient<FormCreateOrder>();
services.AddTransient<FormSushi>();
services.AddTransient<FormSushiComponent>();
services.AddTransient<FormSushiMoreThenOne>();
services.AddTransient<FormReportOrders>();
services.AddTransient<FormSushiOnComponents>();
services.AddTransient<FormClients>();
services.AddTransient<FormImplementers>();
services.AddTransient<FormImplementer>();
services.AddTransient<FormMails>();
DependencyManager.Instance.RegisterType<FormMain>();
DependencyManager.Instance.RegisterType<FormComponent>();
DependencyManager.Instance.RegisterType<FormComponents>();
DependencyManager.Instance.RegisterType<FormCreateOrder>();
DependencyManager.Instance.RegisterType<FormSushi>();
DependencyManager.Instance.RegisterType<FormSushiComponent>();
DependencyManager.Instance.RegisterType<FormSushiMoreThenOne>();
DependencyManager.Instance.RegisterType<FormSushiOnComponents>();
DependencyManager.Instance.RegisterType<FormReportOrders>();
DependencyManager.Instance.RegisterType<FormClients>();
DependencyManager.Instance.RegisterType<FormImplementers>();
DependencyManager.Instance.RegisterType<FormImplementer>();
DependencyManager.Instance.RegisterType<FormMails>();
}
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
private static void MailCheck(object obj) =>
DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
}
}

View File

@ -10,4 +10,5 @@ public class MessageInfoBindingModel : IMessageInfoModel
public DateTime DateDelivery { get; set; }
public string Subject { get; set; } = string.Empty;
public string Body { get; set; } = string.Empty;
public int Id { get; }
}

View File

@ -0,0 +1,56 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace SushiBarContracts.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,37 @@
using Microsoft.Extensions.Logging;
using Unity;
using Unity.Microsoft.Logging;
namespace SushiBarContracts.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

@ -18,6 +18,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Unity" Version="5.11.10" />
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
</ItemGroup>
</Project>

View File

@ -1,15 +1,16 @@
using System.ComponentModel;
using SushiBarContracts.Attributes;
using SushiBarDataModels.Models;
namespace SushiBarContracts.ViewModels;
public class ClientViewModel : IClientModel
{
[Column(visible: false)]
public int Id { get; set; }
[DisplayName("FIO client")]
[Column("FIO client", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string ClientFio { get; set; } = string.Empty;
[DisplayName("Email")]
[Column("Email", width: 150)]
public string Email { get; set; } = string.Empty;
[DisplayName("Password")]
[Column("Password", width : 150)]
public string Password { get; set; } = string.Empty;
}

View File

@ -1,16 +1,15 @@
using SushiBarDataModels.Models;
using System.ComponentModel;
using SushiBarContracts.Attributes;
namespace SushiBarContracts.ViewModels
{
public class ComponentViewModel : IComponentModel
{
[Column(visible: false)]
public int Id { get; set; }
[DisplayName("Name of Component")]
[Column("Name of Component", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string ComponentName { get; set; } = string.Empty;
[DisplayName("Cost")]
[Column("Cost", width: 80)]
public double Cost { get; set; }
}

View File

@ -1,20 +1,19 @@
using System.ComponentModel;
using SushiBarContracts.Attributes;
using SushiBarDataModels.Models;
namespace SushiBarContracts.ViewModels;
public class ImplementerViewModel : IImplementerModel
{
[Column(visible : false)]
public int Id { get; init; }
[DisplayName("Implementer FIO")]
[Column("Implementer FIO", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string ImplementerFio { get; set; } = string.Empty;
[Column("Password", width: 150)]
public string Password { get; set; } = string.Empty;
[DisplayName("Work Experience")]
[Column("Work Experience", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
public int WorkExperience { get; set; }
[DisplayName("Qualification")]
[Column("Qualification", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
public int Qualification { get; set; }
}

View File

@ -1,16 +1,22 @@
using System.ComponentModel;
using SushiBarContracts.Attributes;
using SushiBarDataModels.Models;
namespace SushiBarContracts.ViewModels;
public class MessageInfoViewModel : IMessageInfoModel
{
[Column(visible: false)]
public string MessageId { get; set; }
[Column(visible: false)]
public int? ClientId { get; set; }
[DisplayName("Sender name")]
[Column("Sender name", gridViewAutoSize: GridViewAutoSize.DisplayedCells, isUseAutoSize: true)]
public string SenderName { get; set; }
[DisplayName("Date delivery")]
[Column("Date delivery", width: 100)]
public DateTime DateDelivery { get; set; }
[Column("Subject", width:150)]
public string Subject { get; set; }
[Column("Body", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string Body { get; set; }
[Column(visible:false)]
public int Id { get; }
}

View File

@ -1,40 +1,43 @@
using SushiBarDataModels.Enums;
using SushiBarDataModels.Models;
using System.ComponentModel;
using SushiBarContracts.Attributes;
namespace SushiBarContracts.ViewModels
{
public class OrderViewModel : IOrderModel
{
[DisplayName("Number")]
[Column("Number", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
public int Id { get; init; }
[Column(visible:false)]
public int SushiId { get; init; }
[Column(visible:false)]
public int ClientId { get; init; }
[Column(visible:false)]
public int? ImplementerId { get; set; }
[DisplayName("Client FIO")]
[Column("Client FIO", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string ClientFio { get; init; } = string.Empty;
[DisplayName("Implementer FIO")]
[Column("Implementer FIO", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string ImplementerFio { get; set; } = string.Empty;
[DisplayName("Name of Product")]
[Column("Name of Product", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
public string SushiName { get; init; } = string.Empty;
[DisplayName("Count")]
[Column("Count", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
public int Count { get; set; }
[DisplayName("Sum")]
[Column("Sum", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
public double Sum { get; set; }
[DisplayName("Status")]
[Column("Status", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
public OrderStatus Status { get; set; } = OrderStatus.Unknown;
[DisplayName("Date Create")]
[Column("Date Create", width:100)]
public DateTime DateCreate { get; set; } = DateTime.Now;
[DisplayName("Date Implement")]
[Column("Date Implement", width:100)]
public DateTime? DateImplement { get; set; }
}
}

View File

@ -1,4 +1,6 @@
namespace SushiBarContracts.ViewModels
using SushiBarContracts.Attributes;
namespace SushiBarContracts.ViewModels
{
public class ReportOrdersViewModel
{

View File

@ -1,17 +1,20 @@
using SushiBarDataModels.Models;
using System.ComponentModel;
using SushiBarContracts.Attributes;
namespace SushiBarContracts.ViewModels
{
public class SushiViewModel : ISushiModel
{
[Column(visible:false)]
public int Id { get; set; }
[DisplayName("Name of Product")]
[Column("Name of Product", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string SushiName { get; set; } = string.Empty;
[DisplayName("Cost")]
[Column("Cost", width:100)]
public double Price { get; set; }
[Column(visible:false)]
public Dictionary<int, (IComponentModel, int)> SushiComponents { get; set; } = new();
}
}

View File

@ -47,4 +47,6 @@ public class Message : IMessageInfoModel
SenderName = SenderName,
DateDelivery = DateDelivery,
};
public int Id { get; }
}

View File

@ -66,4 +66,6 @@ public class Message : IMessageInfoModel
new XAttribute("SenderName", SenderName),
new XAttribute("DateDelivery", DateDelivery)
);
public int Id { get; }
}

View File

@ -1,6 +1,6 @@
namespace SushiBarDataModels.Models;
public interface IMessageInfoModel
public interface IMessageInfoModel : IId
{
string MessageId { get; }
int? ClientId { get; }

View File

@ -0,0 +1,17 @@
using SushiBarContracts.BusinessLogicsContracts;
using SushiBarContracts.StoragesContracts;
namespace SushibarListImplement.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

@ -0,0 +1,39 @@
using SushiBarContracts.BindingModels;
using SushiBarContracts.SearchModels;
using SushiBarContracts.StoragesContracts;
using SushiBarContracts.ViewModels;
namespace SushibarListImplement.Implements;
public class ClientStorage : IClientStorage
{
public List<ClientViewModel> GetFullList()
{
throw new NotImplementedException();
}
public List<ClientViewModel> GetFilteredList(ClientSearchModel? model)
{
throw new NotImplementedException();
}
public ClientViewModel? GetElement(ClientSearchModel model)
{
throw new NotImplementedException();
}
public ClientViewModel? Insert(ClientBindingModel model)
{
throw new NotImplementedException();
}
public ClientViewModel? Update(ClientBindingModel model)
{
throw new NotImplementedException();
}
public ClientViewModel? Delete(ClientBindingModel model)
{
throw new NotImplementedException();
}
}

View File

@ -0,0 +1,20 @@
using SushiBarContracts.DI;
using SushiBarContracts.StoragesContracts;
using SushibarListImplement.Implements;
namespace SushibarListImplement;
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<ISushiStorage, SushiStorage>();
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
}
}

View File

@ -39,4 +39,6 @@ public class Message : IMessageInfoModel
ClientId = ClientId,
MessageId = MessageId
};
public int Id { get; }
}

View File

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