ПИбд-23 Насыров Артур Газинурович Лабораторная работа №6 Усложненная #13
@ -16,10 +16,10 @@ namespace FlowerShopBusinessLogic.BusinessLogic
|
|||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IClientStorage _clientStorage;
|
private readonly IClientStorage _clientStorage;
|
||||||
public ClientLogic(ILogger<ClientLogic> logger, IClientStorage componentStorage)
|
public ClientLogic(ILogger<ClientLogic> logger, IClientStorage clientStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_clientStorage = componentStorage;
|
_clientStorage = clientStorage;
|
||||||
}
|
}
|
||||||
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
|
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
|
||||||
{
|
{
|
||||||
|
126
FlowerShopBusinessLogic/ImplementerLogic.cs
Normal file
126
FlowerShopBusinessLogic/ImplementerLogic.cs
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
using FlowerShopContracts.BindingModels;
|
||||||
|
using FlowerShopContracts.BusinessLogicsContracts;
|
||||||
|
using FlowerShopContracts.SearchModels;
|
||||||
|
using FlowerShopContracts.StoragesContracts;
|
||||||
|
using FlowerShopContracts.ViewModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FlowerShopBusinessLogic.BusinessLogic
|
||||||
|
{
|
||||||
|
public class ImplementerLogic : IImplementerLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IImplementerStorage _implementerStorage;
|
||||||
|
public ImplementerLogic(ILogger<ImplementerLogic> logger, IImplementerStorage
|
||||||
|
implementerStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_implementerStorage = implementerStorage;
|
||||||
|
}
|
||||||
|
public List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("ReadList. ImplementerFIO:{ClientFIO}. Id:{ Id}", model?.ImplementerFIO, model?.Id);
|
||||||
|
var list = model == null ? _implementerStorage.GetFullList() : _implementerStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
public ImplementerViewModel? ReadElement(ImplementerSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement. ImplementerFIO:{ImplementerFIO}.Id:{ Id}", model.ImplementerFIO, model.Id);
|
||||||
|
var element = _implementerStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement element not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
public bool Create(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_implementerStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Update(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_implementerStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Delete(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||||
|
if (_implementerStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
private void CheckModel(ImplementerBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.ImplementerFIO))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет ФИО исполнителя",
|
||||||
|
nameof(model.ImplementerFIO));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Password))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет пароля клиента",
|
||||||
|
nameof(model.Password));
|
||||||
|
}
|
||||||
|
if (model.WorkExperience < 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Стаж меньше 0",
|
||||||
|
nameof(model.WorkExperience));
|
||||||
|
}
|
||||||
|
if (model.Qualification < 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Квалификация меньше 0", nameof(model.Qualification));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Implementer. ImplementerFIO:{ImplementerFIO}." +
|
||||||
|
"Password:{ Password}. WorkExperience:{ WorkExperience}. Qualification:{ Qualification}. Id: { Id} ",
|
||||||
|
model.ImplementerFIO, model.Password, model.WorkExperience, model.Qualification, model.Id);
|
||||||
|
var element = _implementerStorage.GetElement(new ImplementerSearchModel
|
||||||
|
{
|
||||||
|
ImplementerFIO = model.ImplementerFIO,
|
||||||
|
});
|
||||||
|
if (element != null && element.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Исполнитель с таким ФИО уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -21,6 +21,7 @@ namespace FlowerShopBusinessLogic.BusinessLogic
|
|||||||
private readonly IShopStorage _shopStorage;
|
private readonly IShopStorage _shopStorage;
|
||||||
private readonly IShopLogic _shopLogic;
|
private readonly IShopLogic _shopLogic;
|
||||||
private readonly IFlowerStorage _flowerStorage;
|
private readonly IFlowerStorage _flowerStorage;
|
||||||
|
static readonly object locker = new object();
|
||||||
|
|
||||||
public OrderLogic(IOrderStorage orderStorage, IShopStorage shopStorage, IShopLogic shopLogic, IFlowerStorage flowerStorage, ILogger<OrderLogic> logger)
|
public OrderLogic(IOrderStorage orderStorage, IShopStorage shopStorage, IShopLogic shopLogic, IFlowerStorage flowerStorage, ILogger<OrderLogic> logger)
|
||||||
{
|
{
|
||||||
@ -30,7 +31,22 @@ namespace FlowerShopBusinessLogic.BusinessLogic
|
|||||||
_shopLogic = shopLogic;
|
_shopLogic = shopLogic;
|
||||||
_flowerStorage = flowerStorage;
|
_flowerStorage = flowerStorage;
|
||||||
}
|
}
|
||||||
|
public OrderViewModel? ReadElement(OrderSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement. Id:{ Id}", model.Id);
|
||||||
|
var element = _orderStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement element not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("ReadList. Id:{ Id}", model?.Id);
|
_logger.LogInformation("ReadList. Id:{ Id}", model?.Id);
|
||||||
@ -60,42 +76,47 @@ namespace FlowerShopBusinessLogic.BusinessLogic
|
|||||||
|
|
||||||
public bool ChangeStatus(OrderBindingModel model, OrderStatus status)
|
public bool ChangeStatus(OrderBindingModel model, OrderStatus status)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model,false);
|
||||||
var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||||
if (element == null)
|
if (element == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Read operation failed");
|
_logger.LogWarning("Read operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (element.Status != status - 1)
|
if (!(element.Status == status - 1 || (element.Status == OrderStatus.Готов )))
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Status change operation failed");
|
_logger.LogWarning("Status change operation failed");
|
||||||
throw new InvalidOperationException("Текущий статус заказа не может быть переведен в выбранный");
|
throw new InvalidOperationException("Текущий статус заказа не может быть переведен в выбранный");
|
||||||
}
|
}
|
||||||
if (element.Status == OrderStatus.Готов)
|
if (element.Status == OrderStatus.Готов || element.Status == OrderStatus.Ожидает)
|
||||||
{
|
{
|
||||||
var flower = _flowerStorage.GetElement(new FlowerSearchModel() { Id = model.FlowerId });
|
var flower = _flowerStorage.GetElement(new FlowerSearchModel() { Id = element.FlowerId });
|
||||||
if (flower == null)
|
if (flower == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Status update to " + status.ToString() + " operation failed. Document not found.");
|
_logger.LogWarning("Status update to " + status.ToString() + " operation failed. Document not found.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (CheckSupply(flower, model.Count) == false)
|
if (CheckSupply(flower, element.Count) == false)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Status update to " + status.ToString() + " operation failed. Shop supply error.");
|
_logger.LogWarning("Status update to " + status.ToString() + " operation failed. Shop supply error.");
|
||||||
return false;
|
status = OrderStatus.Ожидает;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
model.Status = status;
|
model.Status = status;
|
||||||
if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now;
|
if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now;
|
||||||
|
if (element.ImplementerId.HasValue)
|
||||||
|
model.ImplementerId = element.ImplementerId;
|
||||||
_orderStorage.Update(model);
|
_orderStorage.Update(model);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TakeOrderInWork(OrderBindingModel model)
|
public bool TakeOrderInWork(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
lock (locker)
|
||||||
{
|
{
|
||||||
return ChangeStatus(model, OrderStatus.Выполняется);
|
return ChangeStatus(model, OrderStatus.Выполняется);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool FinishOrder(OrderBindingModel model)
|
public bool FinishOrder(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
|
184
FlowerShopBusinessLogic/WorkProcess.cs
Normal file
184
FlowerShopBusinessLogic/WorkProcess.cs
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
using FlowerShopContracts.BindingModels;
|
||||||
|
using FlowerShopContracts.BusinessLogicsContracts;
|
||||||
|
using FlowerShopContracts.SearchModels;
|
||||||
|
using FlowerShopContracts.ViewModels;
|
||||||
|
using FlowerShopDataModels.Enums;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FlowerShopBusinessLogic
|
||||||
|
{
|
||||||
|
public class WorkProcess : IWorkProcess
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly Random _rnd;
|
||||||
|
private IOrderLogic? _orderLogic;
|
||||||
|
public WorkProcess(ILogger<WorkProcess> logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_rnd = new Random(1000);
|
||||||
|
}
|
||||||
|
public void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic)
|
||||||
|
{
|
||||||
|
_orderLogic = orderLogic;
|
||||||
|
var implementers = implementerLogic.ReadList(null);
|
||||||
|
if (implementers == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("DoWork. Implementers is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var deliveredOrders = _orderLogic.ReadList(new OrderSearchModel
|
||||||
|
{
|
||||||
|
Status = OrderStatus.Выдан
|
||||||
|
});
|
||||||
|
var allOrders = _orderLogic.ReadList(null);
|
||||||
|
if (allOrders == null || deliveredOrders == null || allOrders.Count == deliveredOrders.Count )
|
||||||
|
{
|
||||||
|
_logger.LogWarning("DoWork. Orders is null or empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
deliveredOrders.ForEach(x=> allOrders.Remove(x));
|
||||||
|
_logger.LogDebug("DoWork for {Count} orders", allOrders.Count);
|
||||||
|
foreach (var implementer in implementers)
|
||||||
|
{
|
||||||
|
Task.Run(() => WorkerWorkAsync(implementer, allOrders));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// Иммитация работы исполнителя
|
||||||
|
private async Task WorkerWorkAsync(ImplementerViewModel implementer, List<OrderViewModel> orders)
|
||||||
|
{
|
||||||
|
if (_orderLogic == null || implementer == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await DeliverWaitingOrder(implementer);
|
||||||
|
await RunOrderInWork(implementer);
|
||||||
|
await Task.Run(() =>
|
||||||
|
{
|
||||||
|
foreach (var order in orders)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logger.LogDebug("DoWork. Worker {Id} try get order { Order}", implementer.Id, order.Id);
|
||||||
|
// пытаемся назначить заказ на исполнителя
|
||||||
|
_orderLogic.TakeOrderInWork(new OrderBindingModel
|
||||||
|
{
|
||||||
|
Id = order.Id,
|
||||||
|
ImplementerId = implementer.Id
|
||||||
|
});
|
||||||
|
// делаем работу
|
||||||
|
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 1000) * order.Count);
|
||||||
|
_logger.LogDebug("DoWork. Worker {Id} finish order { Order}", implementer.Id, order.Id);
|
||||||
|
|
||||||
|
_orderLogic.FinishOrder(new OrderBindingModel
|
||||||
|
{
|
||||||
|
Id = order.Id
|
||||||
|
});
|
||||||
|
_orderLogic.DeliveryOrder(new OrderBindingModel { Id = order.Id });
|
||||||
|
// отдыхаем
|
||||||
|
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
||||||
|
}
|
||||||
|
// кто-то мог уже перехватить заказ, игнорируем ошибку
|
||||||
|
catch (InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, "Error try get work");
|
||||||
|
}
|
||||||
|
// заканчиваем выполнение имитации в случае иной ошибки
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error while do work");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/// Ищем заказ, которые уже в работе (вдруг исполнителя прервали)
|
||||||
|
private async Task RunOrderInWork(ImplementerViewModel implementer)
|
||||||
|
{
|
||||||
|
if (_orderLogic == null || implementer == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var runOrder = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel
|
||||||
|
{
|
||||||
|
ImplementerId = implementer.Id,
|
||||||
|
Status = OrderStatus.Выполняется
|
||||||
|
}));
|
||||||
|
if (runOrder == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogDebug("DoWork. Worker {Id} back to order {Order}", implementer.Id, runOrder.Id);
|
||||||
|
// доделываем работу
|
||||||
|
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 300) *runOrder.Count);
|
||||||
|
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, runOrder.Id);
|
||||||
|
_orderLogic.FinishOrder(new OrderBindingModel
|
||||||
|
{
|
||||||
|
Id = runOrder.Id
|
||||||
|
});
|
||||||
|
_orderLogic.DeliveryOrder(new OrderBindingModel { Id = runOrder.Id });
|
||||||
|
// отдыхаем
|
||||||
|
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
||||||
|
}
|
||||||
|
// заказа может не быть, просто игнорируем ошибку
|
||||||
|
catch (InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, "Error try get work");
|
||||||
|
}
|
||||||
|
// а может возникнуть иная ошибка, тогда просто заканчиваем выполнение имитации
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error while do work");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private async Task DeliverWaitingOrder(ImplementerViewModel implementer)
|
||||||
|
{
|
||||||
|
if (_orderLogic == null || implementer == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var waitingOrders = await Task.Run(() => _orderLogic.ReadList(new OrderSearchModel
|
||||||
|
{
|
||||||
|
ImplementerId = implementer.Id,
|
||||||
|
Status = OrderStatus.Ожидает
|
||||||
|
}));
|
||||||
|
if (waitingOrders == null || waitingOrders.Count == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("DeliverWaitingOrder. Find some waitig order for implementer:{id}.Count:{count}", implementer.Id, waitingOrders.Count);
|
||||||
|
foreach (var waitingOrder in waitingOrders)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logger.LogInformation("DeliverWaitingOrder. Trying to deliver order id:{id}", waitingOrder.Id);
|
||||||
|
var res = _orderLogic.DeliveryOrder(new OrderBindingModel
|
||||||
|
{
|
||||||
|
Id = waitingOrder.Id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (ArgumentException ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, "DeliverWaitingOrder. Fault");
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, "Error try deliver order");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error while do work");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
18
FlowerShopContracts/BindingModels/ImplementerBindingModel.cs
Normal file
18
FlowerShopContracts/BindingModels/ImplementerBindingModel.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using FlowerShopDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FlowerShopContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class ImplementerBindingModel : IImplementerModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
public int WorkExperience { get; set; } = 0;
|
||||||
|
public int Qualification { get; set; } = 0;
|
||||||
|
public string Password { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
@ -18,6 +18,7 @@ namespace FlowerShopContracts.BindingModels
|
|||||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
|
public int? ImplementerId { get; set; } = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
using FlowerShopContracts.BindingModels;
|
||||||
|
using FlowerShopContracts.SearchModels;
|
||||||
|
using FlowerShopContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FlowerShopContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IImplementerLogic
|
||||||
|
{
|
||||||
|
List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model);
|
||||||
|
ImplementerViewModel? ReadElement(ImplementerSearchModel model);
|
||||||
|
bool Create(ImplementerBindingModel model);
|
||||||
|
bool Update(ImplementerBindingModel model);
|
||||||
|
bool Delete(ImplementerBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -16,5 +16,6 @@ namespace FlowerShopContracts.BusinessLogicsContracts
|
|||||||
bool TakeOrderInWork(OrderBindingModel model);
|
bool TakeOrderInWork(OrderBindingModel model);
|
||||||
bool FinishOrder(OrderBindingModel model);
|
bool FinishOrder(OrderBindingModel model);
|
||||||
bool DeliveryOrder(OrderBindingModel model);
|
bool DeliveryOrder(OrderBindingModel model);
|
||||||
|
OrderViewModel? ReadElement(OrderSearchModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
13
FlowerShopContracts/BusinessLogicsContracts/IWorkProcess.cs
Normal file
13
FlowerShopContracts/BusinessLogicsContracts/IWorkProcess.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FlowerShopContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IWorkProcess
|
||||||
|
{
|
||||||
|
void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic);
|
||||||
|
}
|
||||||
|
}
|
16
FlowerShopContracts/SearchModels/ImplementerSearchModel.cs
Normal file
16
FlowerShopContracts/SearchModels/ImplementerSearchModel.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using FlowerShopDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FlowerShopContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class ImplementerSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string? ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
public string? Password { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using FlowerShopDataModels.Enums;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -12,6 +13,8 @@ namespace FlowerShopContracts.SearchModels
|
|||||||
public DateTime? DateFrom { get; set; }
|
public DateTime? DateFrom { get; set; }
|
||||||
public DateTime? DateTo { get; set; }
|
public DateTime? DateTo { get; set; }
|
||||||
public int? ClientId { get; set; }
|
public int? ClientId { get; set; }
|
||||||
|
public int? ImplementerId { get; set; }
|
||||||
|
public OrderStatus? Status { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
21
FlowerShopContracts/StoragesContracts/IImplementerStorage.cs
Normal file
21
FlowerShopContracts/StoragesContracts/IImplementerStorage.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using FlowerShopContracts.BindingModels;
|
||||||
|
using FlowerShopContracts.SearchModels;
|
||||||
|
using FlowerShopContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FlowerShopContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IImplementerStorage
|
||||||
|
{
|
||||||
|
List<ImplementerViewModel> GetFullList();
|
||||||
|
List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model);
|
||||||
|
ImplementerViewModel? GetElement(ImplementerSearchModel model);
|
||||||
|
ImplementerViewModel? Insert(ImplementerBindingModel model);
|
||||||
|
ImplementerViewModel? Update(ImplementerBindingModel model);
|
||||||
|
ImplementerViewModel? Delete(ImplementerBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
23
FlowerShopContracts/ViewModels/ImplementerViewModel.cs
Normal file
23
FlowerShopContracts/ViewModels/ImplementerViewModel.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using FlowerShopDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FlowerShopContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ImplementerViewModel : IImplementerModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[DisplayName("ФИО исполнителя")]
|
||||||
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Стаж работы")]
|
||||||
|
public int WorkExperience { get; set; } = 0;
|
||||||
|
[DisplayName("Квалификация")]
|
||||||
|
public int Qualification { get; set; } = 0;
|
||||||
|
[DisplayName("Пароль")]
|
||||||
|
public string Password { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
@ -14,8 +14,11 @@ namespace FlowerShopContracts.ViewModels
|
|||||||
[DisplayName("Номер")]
|
[DisplayName("Номер")]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int FlowerId { get; set; }
|
public int FlowerId { get; set; }
|
||||||
|
public int? ImplementerId { get; set; } = null;
|
||||||
[DisplayName("Изделие")]
|
[DisplayName("Изделие")]
|
||||||
public string FlowerName { get; set; } = string.Empty;
|
public string FlowerName { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Исполнитель")]
|
||||||
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
[DisplayName("Количество")]
|
[DisplayName("Количество")]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
[DisplayName("Сумма")]
|
[DisplayName("Сумма")]
|
||||||
|
16
FlowerShopDataModels/IImplementerModel.cs
Normal file
16
FlowerShopDataModels/IImplementerModel.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FlowerShopDataModels.Models
|
||||||
|
{
|
||||||
|
public interface IImplementerModel : IId
|
||||||
|
{
|
||||||
|
string ImplementerFIO { get; }
|
||||||
|
string Password { get; }
|
||||||
|
int WorkExperience { get; }
|
||||||
|
int Qualification { get; }
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,7 @@
|
|||||||
Принят = 0,
|
Принят = 0,
|
||||||
Выполняется = 1,
|
Выполняется = 1,
|
||||||
Готов = 2,
|
Готов = 2,
|
||||||
Выдан = 3
|
Ожидает = 3,
|
||||||
|
Выдан = 4
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,6 +25,7 @@ namespace FlowerShopDatabaseImplement
|
|||||||
public virtual DbSet<Shop> Shops { set; get; }
|
public virtual DbSet<Shop> Shops { set; get; }
|
||||||
public virtual DbSet<ShopFlower> ShopFlowers { set; get; }
|
public virtual DbSet<ShopFlower> ShopFlowers { set; get; }
|
||||||
public virtual DbSet<Client> Clients { set; get; }
|
public virtual DbSet<Client> Clients { set; get; }
|
||||||
|
public virtual DbSet<Implementer> Implementers { set; get; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
65
FlowerShopDatabaseImplement/Implementer.cs
Normal file
65
FlowerShopDatabaseImplement/Implementer.cs
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using FlowerShopContracts.BindingModels;
|
||||||
|
using FlowerShopContracts.ViewModels;
|
||||||
|
using FlowerShopDataModels.Models;
|
||||||
|
|
||||||
|
namespace FlowerShopDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Implementer : IImplementerModel
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
[Required]
|
||||||
|
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string Password { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public int Qualification { get; set; } = 0;
|
||||||
|
[Required]
|
||||||
|
public int WorkExperience { get; set; } = 0;
|
||||||
|
[ForeignKey("ImplementerId")]
|
||||||
|
public virtual List<Order> Orders { get; set; } =
|
||||||
|
new();
|
||||||
|
public static Implementer? Create(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Password = model.Password,
|
||||||
|
Qualification = model.Qualification,
|
||||||
|
ImplementerFIO = model.ImplementerFIO,
|
||||||
|
WorkExperience = model.WorkExperience,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Password = model.Password;
|
||||||
|
Qualification = model.Qualification;
|
||||||
|
ImplementerFIO = model.ImplementerFIO;
|
||||||
|
WorkExperience = model.WorkExperience;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Password = Password,
|
||||||
|
Qualification = Qualification,
|
||||||
|
ImplementerFIO = ImplementerFIO,
|
||||||
|
WorkExperience = WorkExperience,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
87
FlowerShopDatabaseImplement/ImplementerStorage.cs
Normal file
87
FlowerShopDatabaseImplement/ImplementerStorage.cs
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using FlowerShopContracts.BindingModels;
|
||||||
|
using FlowerShopContracts.SearchModels;
|
||||||
|
using FlowerShopContracts.StoragesContracts;
|
||||||
|
using FlowerShopContracts.ViewModels;
|
||||||
|
using FlowerShopDatabaseImplement.Models;
|
||||||
|
|
||||||
|
namespace FlowerShopDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class ImplementerStorage : IImplementerStorage
|
||||||
|
{
|
||||||
|
public ImplementerViewModel? Delete(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new FlowerShopDataBase();
|
||||||
|
var res = context.Implementers.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (res != null)
|
||||||
|
{
|
||||||
|
context.Implementers.Remove(res);
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
return res?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ImplementerFIO) && string.IsNullOrEmpty(model.Password) &&
|
||||||
|
!model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new FlowerShopDataBase();
|
||||||
|
return context.Implementers
|
||||||
|
.FirstOrDefault(x => (string.IsNullOrEmpty(model.ImplementerFIO) || x.ImplementerFIO == model.ImplementerFIO) &&
|
||||||
|
(!model.Id.HasValue || x.Id == model.Id) &&
|
||||||
|
(string.IsNullOrEmpty(model.Password) || x.Password == model.Password))
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
var res = GetElement(model);
|
||||||
|
return res != null ? new() { res } : new();
|
||||||
|
}
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ImplementerViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new FlowerShopDataBase();
|
||||||
|
return context.Implementers.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? Insert(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new FlowerShopDataBase();
|
||||||
|
var res = Implementer.Create(model);
|
||||||
|
if (res != null)
|
||||||
|
{
|
||||||
|
context.Implementers.Add(res);
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
return res?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? Update(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new FlowerShopDataBase();
|
||||||
|
var res = context.Implementers.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (res != null)
|
||||||
|
{
|
||||||
|
res.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
return res?.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||||||
namespace FlowerShopDatabaseImplement.Migrations
|
namespace FlowerShopDatabaseImplement.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(FlowerShopDataBase))]
|
[DbContext(typeof(FlowerShopDataBase))]
|
||||||
[Migration("20240420112416_InitialCreate")]
|
[Migration("20240507180802_InitialCreate")]
|
||||||
partial class InitialCreate
|
partial class InitialCreate
|
||||||
{
|
{
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
@ -115,6 +115,33 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
b.ToTable("FlowerComponents");
|
b.ToTable("FlowerComponents");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
||||||
|
|
||||||
|
b.Property<string>("ImplementerFIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("Qualification")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("WorkExperience")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Implementers");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.Order", b =>
|
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.Order", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
@ -138,6 +165,9 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
b.Property<int>("FlowerId")
|
b.Property<int>("FlowerId")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int?>("ImplementerId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<int>("Status")
|
b.Property<int>("Status")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
@ -150,6 +180,8 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasIndex("FlowerId");
|
b.HasIndex("FlowerId");
|
||||||
|
|
||||||
|
b.HasIndex("ImplementerId");
|
||||||
|
|
||||||
b.ToTable("Orders");
|
b.ToTable("Orders");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -239,9 +271,15 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("FlowerShopDatabaseImplement.Models.Implementer", "Implementer")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ImplementerId");
|
||||||
|
|
||||||
b.Navigation("Client");
|
b.Navigation("Client");
|
||||||
|
|
||||||
b.Navigation("Flower");
|
b.Navigation("Flower");
|
||||||
|
|
||||||
|
b.Navigation("Implementer");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.ShopFlower", b =>
|
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.ShopFlower", b =>
|
||||||
@ -282,6 +320,11 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
b.Navigation("ShopFlowers");
|
b.Navigation("ShopFlowers");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.Shop", b =>
|
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.Shop", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("Flowers");
|
b.Navigation("Flowers");
|
@ -52,6 +52,22 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
table.PrimaryKey("PK_Flowers", x => x.Id);
|
table.PrimaryKey("PK_Flowers", x => x.Id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Implementers",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
ImplementerFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Qualification = table.Column<int>(type: "int", nullable: false),
|
||||||
|
WorkExperience = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Implementers", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Shops",
|
name: "Shops",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
@ -107,7 +123,8 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||||
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true),
|
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||||
FlowerId = table.Column<int>(type: "int", nullable: false),
|
FlowerId = table.Column<int>(type: "int", nullable: false),
|
||||||
ClientId = table.Column<int>(type: "int", nullable: false)
|
ClientId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
ImplementerId = table.Column<int>(type: "int", nullable: true)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
@ -124,6 +141,11 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
principalTable: "Flowers",
|
principalTable: "Flowers",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Orders_Implementers_ImplementerId",
|
||||||
|
column: x => x.ImplementerId,
|
||||||
|
principalTable: "Implementers",
|
||||||
|
principalColumn: "Id");
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
@ -173,6 +195,11 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
table: "Orders",
|
table: "Orders",
|
||||||
column: "FlowerId");
|
column: "FlowerId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Orders_ImplementerId",
|
||||||
|
table: "Orders",
|
||||||
|
column: "ImplementerId");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_ShopFlowers_FlowerId",
|
name: "IX_ShopFlowers_FlowerId",
|
||||||
table: "ShopFlowers",
|
table: "ShopFlowers",
|
||||||
@ -201,6 +228,9 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Clients");
|
name: "Clients");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Implementers");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Flowers");
|
name: "Flowers");
|
||||||
|
|
@ -113,6 +113,33 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
b.ToTable("FlowerComponents");
|
b.ToTable("FlowerComponents");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
||||||
|
|
||||||
|
b.Property<string>("ImplementerFIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("Qualification")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("WorkExperience")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Implementers");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.Order", b =>
|
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.Order", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
@ -136,6 +163,9 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
b.Property<int>("FlowerId")
|
b.Property<int>("FlowerId")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int?>("ImplementerId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<int>("Status")
|
b.Property<int>("Status")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
@ -148,6 +178,8 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasIndex("FlowerId");
|
b.HasIndex("FlowerId");
|
||||||
|
|
||||||
|
b.HasIndex("ImplementerId");
|
||||||
|
|
||||||
b.ToTable("Orders");
|
b.ToTable("Orders");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -237,14 +269,15 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("FlowerShopDatabaseImplement.Models.Implementer", "Implementer")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ImplementerId");
|
||||||
|
|
||||||
b.Navigation("Client");
|
b.Navigation("Client");
|
||||||
|
|
||||||
b.Navigation("Flower");
|
b.Navigation("Flower");
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.Client", b =>
|
b.Navigation("Implementer");
|
||||||
{
|
|
||||||
b.Navigation("Orders");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.ShopFlower", b =>
|
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.ShopFlower", b =>
|
||||||
@ -266,6 +299,11 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
b.Navigation("Shop");
|
b.Navigation("Shop");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.Component", b =>
|
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.Component", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("FlowerComponents");
|
b.Navigation("FlowerComponents");
|
||||||
@ -280,6 +318,11 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
b.Navigation("ShopFlowers");
|
b.Navigation("ShopFlowers");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.Shop", b =>
|
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.Shop", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("Flowers");
|
b.Navigation("Flowers");
|
||||||
|
@ -31,6 +31,8 @@ namespace FlowerShopDatabaseImplement.Models
|
|||||||
public int ClientId { get; private set; }
|
public int ClientId { get; private set; }
|
||||||
public virtual Client? Client { get; private set; }
|
public virtual Client? Client { get; private set; }
|
||||||
public virtual Flower? Flower { get; set; }
|
public virtual Flower? Flower { get; set; }
|
||||||
|
public int? ImplementerId { get; private set; } = null;
|
||||||
|
public virtual Implementer? Implementer { get; private set; }
|
||||||
public static Order? Create(OrderBindingModel model)
|
public static Order? Create(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
@ -47,6 +49,7 @@ namespace FlowerShopDatabaseImplement.Models
|
|||||||
DateImplement = model.DateImplement,
|
DateImplement = model.DateImplement,
|
||||||
FlowerId = model.FlowerId,
|
FlowerId = model.FlowerId,
|
||||||
ClientId = model.ClientId,
|
ClientId = model.ClientId,
|
||||||
|
ImplementerId = model.ImplementerId,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,6 +61,7 @@ namespace FlowerShopDatabaseImplement.Models
|
|||||||
}
|
}
|
||||||
Status = model.Status;
|
Status = model.Status;
|
||||||
DateImplement = model.DateImplement;
|
DateImplement = model.DateImplement;
|
||||||
|
ImplementerId = model.ImplementerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel GetViewModel => new()
|
public OrderViewModel GetViewModel => new()
|
||||||
@ -67,11 +71,13 @@ namespace FlowerShopDatabaseImplement.Models
|
|||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
ClientId = ClientId,
|
ClientId = ClientId,
|
||||||
|
ImplementerId = ImplementerId,
|
||||||
DateCreate = DateCreate,
|
DateCreate = DateCreate,
|
||||||
DateImplement = DateImplement,
|
DateImplement = DateImplement,
|
||||||
FlowerName = Flower?.FlowerName ?? String.Empty ,
|
FlowerName = Flower?.FlowerName ?? String.Empty ,
|
||||||
Id = Id,
|
Id = Id,
|
||||||
ClientFIO = Client?.ClientFIO ?? String.Empty,
|
ClientFIO = Client?.ClientFIO ?? String.Empty,
|
||||||
|
ImplementerFIO = (Implementer != null ? Implementer.ImplementerFIO : string.Empty)
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,31 +18,36 @@ namespace FlowerShopDatabaseImplement.Implements
|
|||||||
public List<OrderViewModel> GetFullList()
|
public List<OrderViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
using var context = new FlowerShopDataBase();
|
using var context = new FlowerShopDataBase();
|
||||||
return context.Orders.Include(x => x.Flower).Include(x => x.Client)
|
return context.Orders.Include(x => x.Flower).
|
||||||
.Select(x => x.GetViewModel)
|
Include(x => x.Client).Include(x => x.Implementer).Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
using var context = new FlowerShopDataBase();
|
using var context = new FlowerShopDataBase();
|
||||||
return context.Orders.Include(x => x.Flower)
|
return context.Orders.Include(x => x.Flower)
|
||||||
.Where(x => ((!model.Id.HasValue || x.Id == model.Id) &&
|
.Where(x => ((!model.Id.HasValue || x.Id == model.Id) &&
|
||||||
(!model.DateFrom.HasValue || x.DateCreate >= model.DateFrom) &&
|
(!model.DateFrom.HasValue || x.DateCreate >= model.DateFrom) &&
|
||||||
(!model.DateTo.HasValue || x.DateCreate <= model.DateTo) &&
|
(!model.DateTo.HasValue || x.DateCreate <= model.DateTo) &&
|
||||||
(!model.ClientId.HasValue || x.ClientId == model.ClientId)))
|
(!model.ClientId.HasValue || x.ClientId == model.ClientId)&&
|
||||||
|
(!model.Status.HasValue || x.Status == model.Status)
|
||||||
|
))
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
using var context = new FlowerShopDataBase();
|
using var context = new FlowerShopDataBase();
|
||||||
return context.Orders.Include(x => x.Flower).Include(x => x.Client).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
return context.Orders
|
||||||
|
.Include(x => x.Flower)
|
||||||
|
.Include(x => x.Client)
|
||||||
|
.Include(x => x.Implementer)
|
||||||
|
.FirstOrDefault(
|
||||||
|
x => (model.Id.HasValue && x.Id == model.Id) ||
|
||||||
|
(model.ImplementerId.HasValue && model.Status.HasValue &&
|
||||||
|
x.ImplementerId == model.ImplementerId && x.Status == model.Status))?
|
||||||
|
.GetViewModel;
|
||||||
}
|
}
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
public OrderViewModel? Insert(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
@ -59,8 +64,8 @@ namespace FlowerShopDatabaseImplement.Implements
|
|||||||
public OrderViewModel? Update(OrderBindingModel model)
|
public OrderViewModel? Update(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new FlowerShopDataBase();
|
using var context = new FlowerShopDataBase();
|
||||||
var order = context.Orders.Include(x => x.Flower).Include(x => x.Client).FirstOrDefault(x => x.Id ==
|
var order = context.Orders.Include(x => x.Flower).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(x => x.Id == model.Id);
|
||||||
model.Id);
|
|
||||||
if (order == null)
|
if (order == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
@ -72,7 +77,7 @@ namespace FlowerShopDatabaseImplement.Implements
|
|||||||
public OrderViewModel? Delete(OrderBindingModel model)
|
public OrderViewModel? Delete(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new FlowerShopDataBase();
|
using var context = new FlowerShopDataBase();
|
||||||
var element = context.Orders.Include(x => x.Flower).Include(x => x.Client).FirstOrDefault(rec => rec.Id == model.Id);
|
var element = context.Orders.Include(x => x.Flower).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
if (element != null)
|
if (element != null)
|
||||||
{
|
{
|
||||||
context.Orders.Remove(element);
|
context.Orders.Remove(element);
|
||||||
|
@ -15,9 +15,9 @@ namespace FlowerShopDatabaseImplement.Models
|
|||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
[Required]
|
[Required]
|
||||||
public string ShopName { get; private set; }
|
public string ShopName { get; private set; } = String.Empty;
|
||||||
[Required]
|
[Required]
|
||||||
public string Address { get; private set; }
|
public string Address { get; private set; } = String.Empty;
|
||||||
[Required]
|
[Required]
|
||||||
public DateTime DateOpen { get; private set; }
|
public DateTime DateOpen { get; private set; }
|
||||||
[Required]
|
[Required]
|
||||||
|
@ -13,9 +13,11 @@ internal class DataFileSingleton
|
|||||||
|
|
||||||
private readonly string ShopFileName = "Shops.xml";
|
private readonly string ShopFileName = "Shops.xml";
|
||||||
public List<Component> Components { get; private set; }
|
public List<Component> Components { get; private set; }
|
||||||
|
private readonly string ImplementerFileName = "Implementer.xml";
|
||||||
public List<Order> Orders { get; private set; }
|
public List<Order> Orders { get; private set; }
|
||||||
public List<Flower> Flowers { get; private set; }
|
public List<Flower> Flowers { get; private set; }
|
||||||
public List<Client> Clients { get; private set; }
|
public List<Client> Clients { get; private set; }
|
||||||
|
public List<Implementer> Implementers { get; private set; }
|
||||||
|
|
||||||
public List<Shop> Shops { get; private set; }
|
public List<Shop> Shops { get; private set; }
|
||||||
public static DataFileSingleton GetInstance()
|
public static DataFileSingleton GetInstance()
|
||||||
@ -26,6 +28,8 @@ internal class DataFileSingleton
|
|||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
public void SaveImplementers() => SaveData(Implementers, ImplementerFileName,
|
||||||
|
"Implementers", x => x.GetXElement);
|
||||||
public void SaveComponents() => SaveData(Components, ComponentFileName,
|
public void SaveComponents() => SaveData(Components, ComponentFileName,
|
||||||
"Components", x => x.GetXElement);
|
"Components", x => x.GetXElement);
|
||||||
public void SaveFlowers() => SaveData(Flowers, FlowerFileName,
|
public void SaveFlowers() => SaveData(Flowers, FlowerFileName,
|
||||||
@ -41,8 +45,8 @@ internal class DataFileSingleton
|
|||||||
Flowers = LoadData(FlowerFileName, "Flower", x => Flower.Create(x)!)!;
|
Flowers = LoadData(FlowerFileName, "Flower", x => Flower.Create(x)!)!;
|
||||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||||
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
|
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
|
||||||
|
|
||||||
Shops = LoadData(ShopFileName, "Shop", x => Shop.Create(x)!)!;
|
Shops = LoadData(ShopFileName, "Shop", x => Shop.Create(x)!)!;
|
||||||
|
Implementers = LoadData(ImplementerFileName, "Implementer", x =>Implementer.Create(x)!)!;
|
||||||
}
|
}
|
||||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
||||||
{
|
{
|
||||||
|
78
FlowerShopFileImplement/Implementer.cs
Normal file
78
FlowerShopFileImplement/Implementer.cs
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
using FlowerShopContracts.BindingModels;
|
||||||
|
using FlowerShopContracts.ViewModels;
|
||||||
|
using FlowerShopDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace FlowerShopFileImplement.Models
|
||||||
|
{
|
||||||
|
public class Implementer : IImplementerModel
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||||
|
public string Password { get; set; } = string.Empty;
|
||||||
|
public int Qualification { get; set; } = 0;
|
||||||
|
public int WorkExperience { get; set; } = 0;
|
||||||
|
public static Implementer? Create(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Implementer()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ImplementerFIO = model.ImplementerFIO,
|
||||||
|
Password = model.Password,
|
||||||
|
WorkExperience = model.WorkExperience,
|
||||||
|
Qualification = model.Qualification
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ImplementerFIO = model.ImplementerFIO;
|
||||||
|
Password = model.Password;
|
||||||
|
WorkExperience = model.WorkExperience;
|
||||||
|
Qualification = model.Qualification;
|
||||||
|
}
|
||||||
|
public ImplementerViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ImplementerFIO = ImplementerFIO,
|
||||||
|
Password = Password,
|
||||||
|
WorkExperience = WorkExperience,
|
||||||
|
Qualification = Qualification
|
||||||
|
};
|
||||||
|
public static Implementer? Create(XElement element)
|
||||||
|
{
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Implementer()
|
||||||
|
{
|
||||||
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
|
ImplementerFIO = element.Element("ImplementerFIO")!.Value,
|
||||||
|
Password = element.Element("Password")!.Value,
|
||||||
|
Qualification = Convert.ToInt32(element.Element("Qualification")!.Value),
|
||||||
|
WorkExperience = Convert.ToInt32(element.Element("WorkExperience")!.Value)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public XElement GetXElement => new("Implementer",
|
||||||
|
new XAttribute("Id", Id),
|
||||||
|
new XElement("ImplementerFIO", ImplementerFIO),
|
||||||
|
new XElement("Password", Password),
|
||||||
|
new XElement("Qualification", Qualification.ToString()),
|
||||||
|
new XElement("WorkExperience", WorkExperience.ToString())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
84
FlowerShopFileImplement/ImplementerStorage.cs
Normal file
84
FlowerShopFileImplement/ImplementerStorage.cs
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
using FlowerShopContracts.BindingModels;
|
||||||
|
using FlowerShopContracts.SearchModels;
|
||||||
|
using FlowerShopContracts.StoragesContracts;
|
||||||
|
using FlowerShopContracts.ViewModels;
|
||||||
|
using FlowerShopFileImplement.Models;
|
||||||
|
using FlowerShopFileImplement.Implements;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FlowerShopFileImplement.Implements
|
||||||
|
{
|
||||||
|
public class ImplementerStorage : IImplementerStorage
|
||||||
|
{
|
||||||
|
private readonly DataFileSingleton source;
|
||||||
|
public ImplementerStorage()
|
||||||
|
{
|
||||||
|
source = DataFileSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
public List<ImplementerViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
return source.Implementers
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel
|
||||||
|
model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ImplementerFIO) && string.IsNullOrEmpty(model.Password))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
return source.Implementers
|
||||||
|
.Where(x => (string.IsNullOrEmpty(model.ImplementerFIO) || x.ImplementerFIO.Contains(model.ImplementerFIO)) &&
|
||||||
|
(string.IsNullOrEmpty(model.Password) || x.Password.Contains(model.Password)))
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
||||||
|
{
|
||||||
|
return source.Implementers
|
||||||
|
.FirstOrDefault(x => (string.IsNullOrEmpty(model.ImplementerFIO) || x.ImplementerFIO == model.ImplementerFIO) &&
|
||||||
|
(!model.Id.HasValue || x.Id == model.Id) && (string.IsNullOrEmpty(model.Password) || x.Password == model.Password))
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
public ImplementerViewModel? Insert(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
model.Id = source.Implementers.Count > 0 ? source.Implementers.Max(x =>
|
||||||
|
x.Id) + 1 : 1;
|
||||||
|
var newImplementer = Implementer.Create(model);
|
||||||
|
if (newImplementer == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
source.Implementers.Add(newImplementer);
|
||||||
|
source.SaveImplementers();
|
||||||
|
return newImplementer.GetViewModel;
|
||||||
|
}
|
||||||
|
public ImplementerViewModel? Update(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
var implementer = source.Implementers.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (implementer == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
implementer.Update(model);
|
||||||
|
source.SaveImplementers();
|
||||||
|
return implementer.GetViewModel;
|
||||||
|
}
|
||||||
|
public ImplementerViewModel? Delete(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
var element = source.Implementers.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
source.Implementers.Remove(element);
|
||||||
|
source.SaveImplementers();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -16,6 +16,7 @@ namespace FlowerShopFileImplement.Models
|
|||||||
public DateTime DateCreate { get; private set; }
|
public DateTime DateCreate { get; private set; }
|
||||||
public DateTime? DateImplement { get; private set; }
|
public DateTime? DateImplement { get; private set; }
|
||||||
public int ClientId { get; private set; }
|
public int ClientId { get; private set; }
|
||||||
|
public int? ImplementerId { get; private set; } = null;
|
||||||
|
|
||||||
|
|
||||||
public static Order? Create(OrderBindingModel model)
|
public static Order? Create(OrderBindingModel model)
|
||||||
@ -34,6 +35,7 @@ namespace FlowerShopFileImplement.Models
|
|||||||
DateCreate = model.DateCreate,
|
DateCreate = model.DateCreate,
|
||||||
DateImplement = model.DateImplement,
|
DateImplement = model.DateImplement,
|
||||||
ClientId = model.ClientId,
|
ClientId = model.ClientId,
|
||||||
|
ImplementerId = model.ImplementerId,
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -47,6 +49,7 @@ namespace FlowerShopFileImplement.Models
|
|||||||
{
|
{
|
||||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
FlowerId = Convert.ToInt32(element.Element("FlowerId")!.Value),
|
FlowerId = Convert.ToInt32(element.Element("FlowerId")!.Value),
|
||||||
|
ImplementerId = Convert.ToInt32(element.Element("ImplementerId")!.Value),
|
||||||
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
||||||
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
||||||
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value.ToString()),
|
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value.ToString()),
|
||||||
@ -71,6 +74,7 @@ namespace FlowerShopFileImplement.Models
|
|||||||
Count = Count,
|
Count = Count,
|
||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
ClientId = ClientId,
|
ClientId = ClientId,
|
||||||
|
ImplementerId = ImplementerId,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
DateCreate = DateCreate,
|
DateCreate = DateCreate,
|
||||||
DateImplement = DateImplement,
|
DateImplement = DateImplement,
|
||||||
@ -83,6 +87,7 @@ namespace FlowerShopFileImplement.Models
|
|||||||
new XElement("Status", Status.ToString()),
|
new XElement("Status", Status.ToString()),
|
||||||
new XElement("DateCreate", DateCreate.ToString()),
|
new XElement("DateCreate", DateCreate.ToString()),
|
||||||
new XElement("ClientId", ClientId),
|
new XElement("ClientId", ClientId),
|
||||||
|
new XElement("ImplementerId", ImplementerId),
|
||||||
new XElement("DateImplement", DateImplement.ToString())
|
new XElement("DateImplement", DateImplement.ToString())
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ namespace FlowerShopFileImplement.Implements
|
|||||||
public List<OrderViewModel> GetFullList()
|
public List<OrderViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
return source.Orders
|
return source.Orders
|
||||||
.Select(x => AccessFlowerStorage(x.GetViewModel))
|
.Select(x => AccessStorage(x.GetViewModel))
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,12 +33,17 @@ namespace FlowerShopFileImplement.Implements
|
|||||||
{
|
{
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
return source.Orders
|
return source.Orders.Where(x => (
|
||||||
.Where(x => ((!model.Id.HasValue || x.Id == model.Id) &&
|
(!model.Id.HasValue || x.Id == model.Id) &&
|
||||||
(!model.DateFrom.HasValue || x.DateCreate >= model.DateFrom) &&
|
(!model.DateFrom.HasValue || x.DateCreate >= model.DateFrom) &&
|
||||||
(!model.DateTo.HasValue || x.DateCreate <= model.DateTo) &&
|
(!model.DateTo.HasValue || x.DateCreate <= model.DateTo)
|
||||||
(!model.ClientId.HasValue || x.ClientId == model.ClientId)))
|
&&
|
||||||
.Select(x => AccessFlowerStorage(x.GetViewModel))
|
(!model.ClientId.HasValue || x.ClientId == model.ClientId)
|
||||||
|
&&
|
||||||
|
(!model.Status.HasValue || x.Status == model.Status)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.Select(x => AccessStorage(x.GetViewModel))
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +53,11 @@ namespace FlowerShopFileImplement.Implements
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return AccessFlowerStorage(source.Orders.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel);
|
return AccessStorage(source.Orders
|
||||||
|
.FirstOrDefault(
|
||||||
|
x => ((model.Id.HasValue && x.Id == model.Id) ||
|
||||||
|
(model.ImplementerId.HasValue && model.Status.HasValue &&
|
||||||
|
x.ImplementerId == model.ImplementerId && x.Status == model.Status)))?.GetViewModel ?? new());
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
public OrderViewModel? Insert(OrderBindingModel model)
|
||||||
@ -61,7 +70,7 @@ namespace FlowerShopFileImplement.Implements
|
|||||||
}
|
}
|
||||||
source.Orders.Add(newOrder);
|
source.Orders.Add(newOrder);
|
||||||
source.SaveOrders();
|
source.SaveOrders();
|
||||||
return AccessFlowerStorage(newOrder.GetViewModel);
|
return AccessStorage(newOrder.GetViewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? Update(OrderBindingModel model)
|
public OrderViewModel? Update(OrderBindingModel model)
|
||||||
@ -73,7 +82,7 @@ namespace FlowerShopFileImplement.Implements
|
|||||||
}
|
}
|
||||||
order.Update(model);
|
order.Update(model);
|
||||||
source.SaveOrders();
|
source.SaveOrders();
|
||||||
return AccessFlowerStorage(order.GetViewModel);
|
return AccessStorage(order.GetViewModel);
|
||||||
}
|
}
|
||||||
public OrderViewModel? Delete(OrderBindingModel model)
|
public OrderViewModel? Delete(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
@ -83,35 +92,25 @@ namespace FlowerShopFileImplement.Implements
|
|||||||
{
|
{
|
||||||
source.Orders.Remove(element);
|
source.Orders.Remove(element);
|
||||||
source.SaveOrders();
|
source.SaveOrders();
|
||||||
return AccessFlowerStorage(element.GetViewModel);
|
return AccessStorage(element.GetViewModel);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel AccessFlowerStorage(OrderViewModel model)
|
public OrderViewModel AccessStorage(OrderViewModel model)
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
return null;
|
|
||||||
foreach (var flower in source.Flowers)
|
|
||||||
{
|
|
||||||
if (flower.Id == model.FlowerId)
|
|
||||||
{
|
|
||||||
model.FlowerName = flower.FlowerName;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel AccessClientStorage(OrderViewModel model)
|
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
return null;
|
return null;
|
||||||
|
var flower = source.Flowers.FirstOrDefault(x => x.Id == model.Id);
|
||||||
var client = source.Clients.FirstOrDefault(x => x.Id == model.Id);
|
var client = source.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
var implementer = source.Implementers.FirstOrDefault(x => x.Id == model.ImplementerId);
|
||||||
|
if (flower != null)
|
||||||
|
model.FlowerName = flower.FlowerName;
|
||||||
if (client != null)
|
if (client != null)
|
||||||
model.ClientFIO = client.ClientFIO;
|
model.ClientFIO = client.ClientFIO;
|
||||||
|
if (implementer != null)
|
||||||
|
model.ImplementerFIO = implementer.ImplementerFIO;
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ namespace FlowerShopListImplement
|
|||||||
public List<Flower> Flowers { get; set; }
|
public List<Flower> Flowers { get; set; }
|
||||||
public List<Shop> Shops { get; set; }
|
public List<Shop> Shops { get; set; }
|
||||||
public List<Client> Clients { get; set; }
|
public List<Client> Clients { get; set; }
|
||||||
|
public List<Implementer> Implementers { get; set; }
|
||||||
|
|
||||||
private DataListSingleton()
|
private DataListSingleton()
|
||||||
{
|
{
|
||||||
|
54
FlowerShopListImplement/Implementer.cs
Normal file
54
FlowerShopListImplement/Implementer.cs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
using FlowerShopContracts.BindingModels;
|
||||||
|
using FlowerShopContracts.ViewModels;
|
||||||
|
using FlowerShopDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FlowerShopListImplement.Models
|
||||||
|
{
|
||||||
|
public class Implementer : IImplementerModel
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||||
|
public string Password { get; set; } = string.Empty;
|
||||||
|
public int WorkExperience { get; set; } = 0;
|
||||||
|
public int Qualification { get; set; } = 0;
|
||||||
|
public static Implementer? Create(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Implementer()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ImplementerFIO = model.ImplementerFIO,
|
||||||
|
Password = model.Password,
|
||||||
|
WorkExperience = model.WorkExperience,
|
||||||
|
Qualification = model.Qualification
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ImplementerFIO = model.ImplementerFIO;
|
||||||
|
Password = model.Password;
|
||||||
|
WorkExperience = model.WorkExperience;
|
||||||
|
Qualification = model.Qualification;
|
||||||
|
}
|
||||||
|
public ImplementerViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ImplementerFIO = ImplementerFIO,
|
||||||
|
Password = Password,
|
||||||
|
WorkExperience = WorkExperience,
|
||||||
|
Qualification = Qualification
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
103
FlowerShopListImplement/ImplemeterStorage.cs
Normal file
103
FlowerShopListImplement/ImplemeterStorage.cs
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
using FlowerShopContracts.BindingModels;
|
||||||
|
using FlowerShopContracts.SearchModels;
|
||||||
|
using FlowerShopContracts.StoragesContracts;
|
||||||
|
using FlowerShopContracts.ViewModels;
|
||||||
|
using FlowerShopListImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FlowerShopListImplement.Implements
|
||||||
|
{
|
||||||
|
public class ImplementerStorage : IImplementerStorage
|
||||||
|
{
|
||||||
|
private readonly DataListSingleton _source;
|
||||||
|
public ImplementerStorage()
|
||||||
|
{
|
||||||
|
_source = DataListSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
public List<ImplementerViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
var result = new List<ImplementerViewModel>();
|
||||||
|
foreach (var implementer in _source.Implementers)
|
||||||
|
{
|
||||||
|
result.Add(implementer.GetViewModel);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel
|
||||||
|
model)
|
||||||
|
{
|
||||||
|
var result = new List<ImplementerViewModel>();
|
||||||
|
if (string.IsNullOrEmpty(model.ImplementerFIO) && string.IsNullOrEmpty(model.Password))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
foreach (var implementer in _source.Implementers)
|
||||||
|
{
|
||||||
|
if (implementer.ImplementerFIO.Contains(model.ImplementerFIO))
|
||||||
|
{
|
||||||
|
result.Add(implementer.GetViewModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
||||||
|
{
|
||||||
|
foreach (var implementer in _source.Implementers)
|
||||||
|
{
|
||||||
|
if ((string.IsNullOrEmpty(model.ImplementerFIO) || implementer.ImplementerFIO == model.ImplementerFIO) &&
|
||||||
|
(!model.Id.HasValue || implementer.Id == model.Id) && (string.IsNullOrEmpty(model.Password) || implementer.Password == model.Password))
|
||||||
|
{
|
||||||
|
return implementer.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public ImplementerViewModel? Insert(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
model.Id = 1;
|
||||||
|
foreach (var implementer in _source.Implementers)
|
||||||
|
{
|
||||||
|
if (model.Id <= implementer.Id)
|
||||||
|
{
|
||||||
|
model.Id = implementer.Id + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var newImplementer = Implementer.Create(model);
|
||||||
|
if (newImplementer == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_source.Implementers.Add(newImplementer);
|
||||||
|
return newImplementer.GetViewModel;
|
||||||
|
}
|
||||||
|
public ImplementerViewModel? Update(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
foreach (var implementer in _source.Implementers)
|
||||||
|
{
|
||||||
|
if (model.Id == implementer.Id)
|
||||||
|
{
|
||||||
|
implementer.Update(model);
|
||||||
|
return implementer.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public ImplementerViewModel? Delete(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _source.Implementers.Count; ++i)
|
||||||
|
{
|
||||||
|
if (_source.Implementers[i].Id == model.Id)
|
||||||
|
{
|
||||||
|
var element = _source.Implementers[i];
|
||||||
|
_source.Implementers.RemoveAt(i);
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace FlowerShopListImplement.Models
|
namespace FlowerShopListImplement.Models
|
||||||
{
|
{
|
||||||
@ -17,6 +18,7 @@ namespace FlowerShopListImplement.Models
|
|||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
public double Sum { get; private set; }
|
public double Sum { get; private set; }
|
||||||
public int ClientId { get; private set; }
|
public int ClientId { get; private set; }
|
||||||
|
public int? ImplementerId { get; private set; }
|
||||||
|
|
||||||
public OrderStatus Status { get; private set; }
|
public OrderStatus Status { get; private set; }
|
||||||
public DateTime DateCreate { get; private set; }
|
public DateTime DateCreate { get; private set; }
|
||||||
@ -38,6 +40,7 @@ namespace FlowerShopListImplement.Models
|
|||||||
DateCreate = model.DateCreate,
|
DateCreate = model.DateCreate,
|
||||||
DateImplement = model.DateImplement,
|
DateImplement = model.DateImplement,
|
||||||
ClientId = model.ClientId,
|
ClientId = model.ClientId,
|
||||||
|
ImplementerId = model.ImplementerId
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -51,6 +54,7 @@ namespace FlowerShopListImplement.Models
|
|||||||
FlowerId = model.FlowerId;
|
FlowerId = model.FlowerId;
|
||||||
Count = model.Count;
|
Count = model.Count;
|
||||||
ClientId = model.ClientId;
|
ClientId = model.ClientId;
|
||||||
|
ImplementerId = model.ImplementerId;
|
||||||
Sum = model.Sum;
|
Sum = model.Sum;
|
||||||
Status = model.Status;
|
Status = model.Status;
|
||||||
DateCreate = model.DateCreate;
|
DateCreate = model.DateCreate;
|
||||||
@ -61,6 +65,7 @@ namespace FlowerShopListImplement.Models
|
|||||||
Id = Id,
|
Id = Id,
|
||||||
FlowerId = FlowerId,
|
FlowerId = FlowerId,
|
||||||
ClientId = ClientId,
|
ClientId = ClientId,
|
||||||
|
ImplementerId = ImplementerId,
|
||||||
Count = Count,
|
Count = Count,
|
||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
|
@ -23,12 +23,11 @@ namespace FlowerShopListImplement.Implements
|
|||||||
var result = new List<OrderViewModel>();
|
var result = new List<OrderViewModel>();
|
||||||
foreach (var order in _source.Orders)
|
foreach (var order in _source.Orders)
|
||||||
{
|
{
|
||||||
result.Add(AccessFlowerStorage(order.GetViewModel));
|
result.Add(AccessStorage(order.GetViewModel));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
model)
|
|
||||||
{
|
{
|
||||||
var result = new List<OrderViewModel>();
|
var result = new List<OrderViewModel>();
|
||||||
if (!model.Id.HasValue)
|
if (!model.Id.HasValue)
|
||||||
@ -40,9 +39,10 @@ namespace FlowerShopListImplement.Implements
|
|||||||
if ((!model.Id.HasValue || order.Id == model.Id) &&
|
if ((!model.Id.HasValue || order.Id == model.Id) &&
|
||||||
(!model.DateFrom.HasValue || order.DateCreate >= model.DateFrom) &&
|
(!model.DateFrom.HasValue || order.DateCreate >= model.DateFrom) &&
|
||||||
(!model.DateTo.HasValue || order.DateCreate <= model.DateTo) &&
|
(!model.DateTo.HasValue || order.DateCreate <= model.DateTo) &&
|
||||||
(!model.ClientId.HasValue || order.ClientId == model.ClientId))
|
(!model.ClientId.HasValue || order.ClientId == model.ClientId)&&
|
||||||
|
(!model.Status.HasValue || order.Status == model.Status));
|
||||||
{
|
{
|
||||||
result.Add(AccessFlowerStorage(order.GetViewModel));
|
result.Add(AccessStorage(order.GetViewModel));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -55,7 +55,9 @@ namespace FlowerShopListImplement.Implements
|
|||||||
}
|
}
|
||||||
foreach (var order in _source.Orders)
|
foreach (var order in _source.Orders)
|
||||||
{
|
{
|
||||||
if (model.Id.HasValue && order.Id == model.Id)
|
if ((model.Id.HasValue && order.Id == model.Id) ||
|
||||||
|
(model.ImplementerId.HasValue && model.Status.HasValue &&
|
||||||
|
order.ImplementerId == model.ImplementerId && order.Status == model.Status))
|
||||||
{
|
{
|
||||||
return order.GetViewModel;
|
return order.GetViewModel;
|
||||||
}
|
}
|
||||||
@ -125,5 +127,22 @@ namespace FlowerShopListImplement.Implements
|
|||||||
model.ClientFIO = client.ClientFIO;
|
model.ClientFIO = client.ClientFIO;
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public OrderViewModel AccessStorage(OrderViewModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
return null;
|
||||||
|
var flower = _source.Flowers.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
var client = _source.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
var implementer = _source.Implementers.FirstOrDefault(x => x.Id == model.ImplementerId);
|
||||||
|
if (flower != null)
|
||||||
|
model.FlowerName = flower.FlowerName;
|
||||||
|
if (client != null)
|
||||||
|
model.ClientFIO = client.ClientFIO;
|
||||||
|
if (implementer != null)
|
||||||
|
model.ImplementerFIO = implementer.ImplementerFIO;
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
103
FlowerShopRestApi/Controllers/ImplementerController.cs
Normal file
103
FlowerShopRestApi/Controllers/ImplementerController.cs
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
using FlowerShopContracts.BindingModels;
|
||||||
|
using FlowerShopContracts.BusinessLogicsContracts;
|
||||||
|
using FlowerShopContracts.SearchModels;
|
||||||
|
using FlowerShopContracts.ViewModels;
|
||||||
|
using FlowerShopDataModels.Enums;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace FlowerShopRestApi.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]/[action]")]
|
||||||
|
[ApiController]
|
||||||
|
public class ImplementerController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IOrderLogic _order;
|
||||||
|
private readonly IImplementerLogic _logic;
|
||||||
|
public ImplementerController(IOrderLogic order, IImplementerLogic logic,
|
||||||
|
ILogger<ImplementerController> logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_order = order;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public ImplementerViewModel? Login(string login, string password)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _logic.ReadElement(new ImplementerSearchModel
|
||||||
|
{
|
||||||
|
ImplementerFIO = login,
|
||||||
|
Password = password
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка авторизации сотрудника");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public List<OrderViewModel>? GetNewOrders()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _order.ReadList(new OrderSearchModel
|
||||||
|
{
|
||||||
|
Status = OrderStatus.Принят
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения новых заказов");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public OrderViewModel? GetImplementerOrder(int implementerId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _order.ReadElement(new OrderSearchModel
|
||||||
|
{
|
||||||
|
ImplementerId = implementerId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения текущего заказа исполнителя");
|
||||||
|
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void TakeOrderInWork(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_order.TakeOrderInWork(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка перевода заказа с №{Id} в работу",
|
||||||
|
model.Id);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void FinishOrder(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_order.FinishOrder(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка отметки о готовности заказа с №{ Id}", model.Id);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
162
ProjectFlowerShop/ImplementerForm.Designer.cs
generated
Normal file
162
ProjectFlowerShop/ImplementerForm.Designer.cs
generated
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
namespace ProjectFlowerShop
|
||||||
|
{
|
||||||
|
partial class ImplementerForm
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
FIOTextBox = new TextBox();
|
||||||
|
PasswordTextBox = new TextBox();
|
||||||
|
QualificationTextBox = new TextBox();
|
||||||
|
WorkExperienceTextBox = new TextBox();
|
||||||
|
label1 = new Label();
|
||||||
|
label2 = new Label();
|
||||||
|
label3 = new Label();
|
||||||
|
label4 = new Label();
|
||||||
|
SaveButton = new Button();
|
||||||
|
CancelButton = new Button();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// FIOTextBox
|
||||||
|
//
|
||||||
|
FIOTextBox.Location = new Point(124, 19);
|
||||||
|
FIOTextBox.Name = "FIOTextBox";
|
||||||
|
FIOTextBox.Size = new Size(411, 27);
|
||||||
|
FIOTextBox.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// PasswordTextBox
|
||||||
|
//
|
||||||
|
PasswordTextBox.Location = new Point(124, 52);
|
||||||
|
PasswordTextBox.Name = "PasswordTextBox";
|
||||||
|
PasswordTextBox.Size = new Size(411, 27);
|
||||||
|
PasswordTextBox.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// QualificationTextBox
|
||||||
|
//
|
||||||
|
QualificationTextBox.Location = new Point(124, 85);
|
||||||
|
QualificationTextBox.Name = "QualificationTextBox";
|
||||||
|
QualificationTextBox.Size = new Size(411, 27);
|
||||||
|
QualificationTextBox.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// WorkExperienceTextBox
|
||||||
|
//
|
||||||
|
WorkExperienceTextBox.Location = new Point(124, 118);
|
||||||
|
WorkExperienceTextBox.Name = "WorkExperienceTextBox";
|
||||||
|
WorkExperienceTextBox.Size = new Size(411, 27);
|
||||||
|
WorkExperienceTextBox.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(9, 19);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(42, 20);
|
||||||
|
label1.TabIndex = 4;
|
||||||
|
label1.Text = "ФИО";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(9, 52);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(62, 20);
|
||||||
|
label2.TabIndex = 5;
|
||||||
|
label2.Text = "Пароль";
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
label3.AutoSize = true;
|
||||||
|
label3.Location = new Point(9, 85);
|
||||||
|
label3.Name = "label3";
|
||||||
|
label3.Size = new Size(111, 20);
|
||||||
|
label3.TabIndex = 6;
|
||||||
|
label3.Text = "Квалификация";
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
label4.AutoSize = true;
|
||||||
|
label4.Location = new Point(9, 118);
|
||||||
|
label4.Name = "label4";
|
||||||
|
label4.Size = new Size(99, 20);
|
||||||
|
label4.TabIndex = 7;
|
||||||
|
label4.Text = "Стаж работы";
|
||||||
|
//
|
||||||
|
// SaveButton
|
||||||
|
//
|
||||||
|
SaveButton.Location = new Point(341, 151);
|
||||||
|
SaveButton.Name = "SaveButton";
|
||||||
|
SaveButton.Size = new Size(94, 29);
|
||||||
|
SaveButton.TabIndex = 8;
|
||||||
|
SaveButton.Text = "Сохранить";
|
||||||
|
SaveButton.UseVisualStyleBackColor = true;
|
||||||
|
SaveButton.Click += SaveButton_Click;
|
||||||
|
//
|
||||||
|
// CancelButton
|
||||||
|
//
|
||||||
|
CancelButton.Location = new Point(441, 151);
|
||||||
|
CancelButton.Name = "CancelButton";
|
||||||
|
CancelButton.Size = new Size(94, 29);
|
||||||
|
CancelButton.TabIndex = 9;
|
||||||
|
CancelButton.Text = "Отмена";
|
||||||
|
CancelButton.UseVisualStyleBackColor = true;
|
||||||
|
CancelButton.Click += CancelButton_Click;
|
||||||
|
//
|
||||||
|
// ImplementerForm
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(548, 186);
|
||||||
|
Controls.Add(CancelButton);
|
||||||
|
Controls.Add(SaveButton);
|
||||||
|
Controls.Add(label4);
|
||||||
|
Controls.Add(label3);
|
||||||
|
Controls.Add(label2);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Controls.Add(WorkExperienceTextBox);
|
||||||
|
Controls.Add(QualificationTextBox);
|
||||||
|
Controls.Add(PasswordTextBox);
|
||||||
|
Controls.Add(FIOTextBox);
|
||||||
|
Name = "ImplementerForm";
|
||||||
|
Text = "Исполнитель";
|
||||||
|
Load += ImplementerForm_Load;
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private TextBox FIOTextBox;
|
||||||
|
private TextBox PasswordTextBox;
|
||||||
|
private TextBox QualificationTextBox;
|
||||||
|
private TextBox WorkExperienceTextBox;
|
||||||
|
private Label label1;
|
||||||
|
private Label label2;
|
||||||
|
private Label label3;
|
||||||
|
private Label label4;
|
||||||
|
private Button SaveButton;
|
||||||
|
private Button CancelButton;
|
||||||
|
}
|
||||||
|
}
|
109
ProjectFlowerShop/ImplementerForm.cs
Normal file
109
ProjectFlowerShop/ImplementerForm.cs
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
using FlowerShopContracts.BindingModels;
|
||||||
|
using FlowerShopContracts.BusinessLogicsContracts;
|
||||||
|
using FlowerShopContracts.SearchModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace ProjectFlowerShop
|
||||||
|
{
|
||||||
|
public partial class ImplementerForm : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IImplementerLogic _logic;
|
||||||
|
private int? _id;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
public ImplementerForm(ILogger<ImplementerForm> logger, IImplementerLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ImplementerForm_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_id.HasValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение исполнителя");
|
||||||
|
var view = _logic.ReadElement(new ImplementerSearchModel
|
||||||
|
{
|
||||||
|
Id =
|
||||||
|
_id.Value
|
||||||
|
});
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
FIOTextBox.Text = view.ImplementerFIO;
|
||||||
|
PasswordTextBox.Text = view.Password;
|
||||||
|
QualificationTextBox.Text = view.Qualification.ToString();
|
||||||
|
WorkExperienceTextBox.Text = view.WorkExperience.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения исполнителя");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(FIOTextBox.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните ФИО", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(PasswordTextBox.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните пароль", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Сохранение компонента");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = new ImplementerBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
ImplementerFIO = FIOTextBox.Text,
|
||||||
|
Password = PasswordTextBox.Text,
|
||||||
|
Qualification = Convert.ToInt32(QualificationTextBox.Text),
|
||||||
|
WorkExperience = Convert.ToInt32(WorkExperienceTextBox.Text),
|
||||||
|
};
|
||||||
|
var operationResult = _id.HasValue ? _logic.Update(model) :
|
||||||
|
_logic.Create(model);
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка сохранения исполнителя");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CancelButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
ProjectFlowerShop/ImplementerForm.resx
Normal file
120
ProjectFlowerShop/ImplementerForm.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
114
ProjectFlowerShop/ImplementersForm.Designer.cs
generated
Normal file
114
ProjectFlowerShop/ImplementersForm.Designer.cs
generated
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
namespace ProjectFlowerShop
|
||||||
|
{
|
||||||
|
partial class ImplementersForm
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
dataGridView1 = new DataGridView();
|
||||||
|
CreateButton = new Button();
|
||||||
|
ChangeButton = new Button();
|
||||||
|
DeleteButton = new Button();
|
||||||
|
RefreshButton = new Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView1
|
||||||
|
//
|
||||||
|
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView1.Location = new Point(12, 12);
|
||||||
|
dataGridView1.Name = "dataGridView1";
|
||||||
|
dataGridView1.RowHeadersWidth = 51;
|
||||||
|
dataGridView1.RowTemplate.Height = 29;
|
||||||
|
dataGridView1.Size = new Size(565, 426);
|
||||||
|
dataGridView1.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// CreateButton
|
||||||
|
//
|
||||||
|
CreateButton.Location = new Point(583, 12);
|
||||||
|
CreateButton.Name = "CreateButton";
|
||||||
|
CreateButton.Size = new Size(205, 29);
|
||||||
|
CreateButton.TabIndex = 1;
|
||||||
|
CreateButton.Text = "Создать";
|
||||||
|
CreateButton.UseVisualStyleBackColor = true;
|
||||||
|
CreateButton.Click += CreateButton_Click;
|
||||||
|
//
|
||||||
|
// ChangeButton
|
||||||
|
//
|
||||||
|
ChangeButton.Location = new Point(583, 47);
|
||||||
|
ChangeButton.Name = "ChangeButton";
|
||||||
|
ChangeButton.Size = new Size(205, 29);
|
||||||
|
ChangeButton.TabIndex = 2;
|
||||||
|
ChangeButton.Text = "Изменить";
|
||||||
|
ChangeButton.UseVisualStyleBackColor = true;
|
||||||
|
ChangeButton.Click += ChangeButton_Click;
|
||||||
|
//
|
||||||
|
// DeleteButton
|
||||||
|
//
|
||||||
|
DeleteButton.Location = new Point(583, 82);
|
||||||
|
DeleteButton.Name = "DeleteButton";
|
||||||
|
DeleteButton.Size = new Size(205, 29);
|
||||||
|
DeleteButton.TabIndex = 3;
|
||||||
|
DeleteButton.Text = "Удалить";
|
||||||
|
DeleteButton.UseVisualStyleBackColor = true;
|
||||||
|
DeleteButton.Click += DeleteButton_Click;
|
||||||
|
//
|
||||||
|
// RefreshButton
|
||||||
|
//
|
||||||
|
RefreshButton.Location = new Point(583, 117);
|
||||||
|
RefreshButton.Name = "RefreshButton";
|
||||||
|
RefreshButton.Size = new Size(205, 29);
|
||||||
|
RefreshButton.TabIndex = 4;
|
||||||
|
RefreshButton.Text = "Обновить";
|
||||||
|
RefreshButton.UseVisualStyleBackColor = true;
|
||||||
|
RefreshButton.Click += RefreshButton_Click;
|
||||||
|
//
|
||||||
|
// ImplementersForm
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(800, 450);
|
||||||
|
Controls.Add(RefreshButton);
|
||||||
|
Controls.Add(DeleteButton);
|
||||||
|
Controls.Add(ChangeButton);
|
||||||
|
Controls.Add(CreateButton);
|
||||||
|
Controls.Add(dataGridView1);
|
||||||
|
Name = "ImplementersForm";
|
||||||
|
Text = "Исполнители";
|
||||||
|
Load += ImplementersForm_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView1;
|
||||||
|
private Button CreateButton;
|
||||||
|
private Button ChangeButton;
|
||||||
|
private Button DeleteButton;
|
||||||
|
private Button RefreshButton;
|
||||||
|
}
|
||||||
|
}
|
125
ProjectFlowerShop/ImplementersForm.cs
Normal file
125
ProjectFlowerShop/ImplementersForm.cs
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
using FlowerShopContracts.BindingModels;
|
||||||
|
using FlowerShopContracts.BusinessLogicsContracts;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace ProjectFlowerShop
|
||||||
|
{
|
||||||
|
public partial class ImplementersForm : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IImplementerLogic _logic;
|
||||||
|
public ImplementersForm(ILogger<ImplementersForm> logger, IImplementerLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ImplementersForm_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logic.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView1.DataSource = list;
|
||||||
|
dataGridView1.Columns["Id"].Visible = false;
|
||||||
|
dataGridView1.Columns["ImplementerFIO"].AutoSizeMode =
|
||||||
|
DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView1.Columns["Password"].AutoSizeMode =
|
||||||
|
DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView1.Columns["Qualification"].AutoSizeMode =
|
||||||
|
DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView1.Columns["WorkExperience"].AutoSizeMode =
|
||||||
|
DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Загрузка компонентов");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки исполнителей");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void CreateButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(ImplementerForm));
|
||||||
|
if (service is ImplementerForm form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ChangeButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView1.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service =
|
||||||
|
Program.ServiceProvider?.GetService(typeof(ImplementerForm));
|
||||||
|
if (service is ImplementerForm form)
|
||||||
|
{
|
||||||
|
form.Id =
|
||||||
|
Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DeleteButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView1.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос",
|
||||||
|
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
int id =
|
||||||
|
Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
_logger.LogInformation("Удаление компонента");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!_logic.Delete(new ImplementerBindingModel
|
||||||
|
{
|
||||||
|
Id = id
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка удаления исполнителя");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
ProjectFlowerShop/ImplementersForm.resx
Normal file
120
ProjectFlowerShop/ImplementersForm.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
175
ProjectFlowerShop/MainForm.Designer.cs
generated
175
ProjectFlowerShop/MainForm.Designer.cs
generated
@ -30,25 +30,27 @@
|
|||||||
{
|
{
|
||||||
menuStrip1 = new MenuStrip();
|
menuStrip1 = new MenuStrip();
|
||||||
ToolStripMenu = new ToolStripMenuItem();
|
ToolStripMenu = new ToolStripMenuItem();
|
||||||
|
клиентыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
КомпонентыStripMenuItem = new ToolStripMenuItem();
|
КомпонентыStripMenuItem = new ToolStripMenuItem();
|
||||||
ЦветыStripMenuItem = new ToolStripMenuItem();
|
ЦветыStripMenuItem = new ToolStripMenuItem();
|
||||||
клиентыToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
магазиныToolStripMenuItem = new ToolStripMenuItem();
|
магазиныToolStripMenuItem = new ToolStripMenuItem();
|
||||||
поставкиToolStripMenuItem = new ToolStripMenuItem();
|
поставкиToolStripMenuItem = new ToolStripMenuItem();
|
||||||
продажиToolStripMenuItem = new ToolStripMenuItem();
|
продажиToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
исполнителиToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
начатьРаботуToolStripMenuItem = new ToolStripMenuItem();
|
||||||
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
списокКомпонентовToolStripMenuItem = new ToolStripMenuItem();
|
списокКомпонентовToolStripMenuItem = new ToolStripMenuItem();
|
||||||
компонентыToolStripMenuItem = new ToolStripMenuItem();
|
компонентыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
|
списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
списокМагазиновToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
цветыПоМагазинамToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
заказыПоДатамToolStripMenuItem = new ToolStripMenuItem();
|
||||||
DataGridView = new DataGridView();
|
DataGridView = new DataGridView();
|
||||||
CreateOrderButton = new Button();
|
CreateOrderButton = new Button();
|
||||||
TakeInWorkButton = new Button();
|
TakeInWorkButton = new Button();
|
||||||
ReadyButton = new Button();
|
ReadyButton = new Button();
|
||||||
IssuedButton = new Button();
|
IssuedButton = new Button();
|
||||||
RefreshButton = new Button();
|
RefreshButton = new Button();
|
||||||
списокМагазиновToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
цветыПоМагазинамToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
заказыПоДатамToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
menuStrip1.SuspendLayout();
|
menuStrip1.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit();
|
((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
@ -59,60 +61,73 @@
|
|||||||
menuStrip1.Items.AddRange(new ToolStripItem[] { ToolStripMenu, отчетыToolStripMenuItem });
|
menuStrip1.Items.AddRange(new ToolStripItem[] { ToolStripMenu, отчетыToolStripMenuItem });
|
||||||
menuStrip1.Location = new Point(0, 0);
|
menuStrip1.Location = new Point(0, 0);
|
||||||
menuStrip1.Name = "menuStrip1";
|
menuStrip1.Name = "menuStrip1";
|
||||||
menuStrip1.Size = new Size(1296, 28);
|
menuStrip1.Size = new Size(1414, 28);
|
||||||
menuStrip1.TabIndex = 0;
|
menuStrip1.TabIndex = 0;
|
||||||
menuStrip1.Text = "menuStrip1";
|
menuStrip1.Text = "menuStrip1";
|
||||||
//
|
//
|
||||||
// ToolStripMenu
|
// ToolStripMenu
|
||||||
//
|
//
|
||||||
ToolStripMenu.DropDownItems.AddRange(new ToolStripItem[] { КомпонентыStripMenuItem, ЦветыStripMenuItem, клиентыToolStripMenuItem });
|
ToolStripMenu.DropDownItems.AddRange(new ToolStripItem[] { клиентыToolStripMenuItem, КомпонентыStripMenuItem, ЦветыStripMenuItem, магазиныToolStripMenuItem, поставкиToolStripMenuItem, продажиToolStripMenuItem, исполнителиToolStripMenuItem, начатьРаботуToolStripMenuItem });
|
||||||
ToolStripMenu.DropDownItems.AddRange(new ToolStripItem[] { КомпонентыStripMenuItem, ЦветыStripMenuItem, магазиныToolStripMenuItem, поставкиToolStripMenuItem, продажиToolStripMenuItem });
|
|
||||||
ToolStripMenu.Name = "ToolStripMenu";
|
ToolStripMenu.Name = "ToolStripMenu";
|
||||||
ToolStripMenu.Size = new Size(117, 24);
|
ToolStripMenu.Size = new Size(117, 24);
|
||||||
ToolStripMenu.Text = "Справочники";
|
ToolStripMenu.Text = "Справочники";
|
||||||
//
|
//
|
||||||
|
// клиентыToolStripMenuItem
|
||||||
|
//
|
||||||
|
клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
|
||||||
|
клиентыToolStripMenuItem.Size = new Size(193, 26);
|
||||||
|
клиентыToolStripMenuItem.Text = "Клиенты";
|
||||||
|
клиентыToolStripMenuItem.Click += клиентыToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
// КомпонентыStripMenuItem
|
// КомпонентыStripMenuItem
|
||||||
//
|
//
|
||||||
КомпонентыStripMenuItem.Name = "КомпонентыStripMenuItem";
|
КомпонентыStripMenuItem.Name = "КомпонентыStripMenuItem";
|
||||||
КомпонентыStripMenuItem.Size = new Size(224, 26);
|
КомпонентыStripMenuItem.Size = new Size(193, 26);
|
||||||
КомпонентыStripMenuItem.Text = "Компоненты";
|
КомпонентыStripMenuItem.Text = "Компоненты";
|
||||||
КомпонентыStripMenuItem.Click += КомпонентыStripMenuItem_Click;
|
КомпонентыStripMenuItem.Click += КомпонентыStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// ЦветыStripMenuItem
|
// ЦветыStripMenuItem
|
||||||
//
|
//
|
||||||
ЦветыStripMenuItem.Name = "ЦветыStripMenuItem";
|
ЦветыStripMenuItem.Name = "ЦветыStripMenuItem";
|
||||||
ЦветыStripMenuItem.Size = new Size(224, 26);
|
ЦветыStripMenuItem.Size = new Size(193, 26);
|
||||||
ЦветыStripMenuItem.Text = "Цветы";
|
ЦветыStripMenuItem.Text = "Цветы";
|
||||||
ЦветыStripMenuItem.Click += ЦветыStripMenuItem_Click;
|
ЦветыStripMenuItem.Click += ЦветыStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// клиентыToolStripMenuItem
|
|
||||||
//
|
|
||||||
клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
|
|
||||||
клиентыToolStripMenuItem.Size = new Size(224, 26);
|
|
||||||
клиентыToolStripMenuItem.Text = "Клиенты";
|
|
||||||
клиентыToolStripMenuItem.Click += клиентыToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// магазиныToolStripMenuItem
|
// магазиныToolStripMenuItem
|
||||||
//
|
//
|
||||||
магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem";
|
магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem";
|
||||||
магазиныToolStripMenuItem.Size = new Size(182, 26);
|
магазиныToolStripMenuItem.Size = new Size(193, 26);
|
||||||
магазиныToolStripMenuItem.Text = "Магазины";
|
магазиныToolStripMenuItem.Text = "Магазины";
|
||||||
магазиныToolStripMenuItem.Click += магазиныToolStripMenuItem_Click;
|
магазиныToolStripMenuItem.Click += магазиныToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// поставкиToolStripMenuItem
|
// поставкиToolStripMenuItem
|
||||||
//
|
//
|
||||||
поставкиToolStripMenuItem.Name = "поставкиToolStripMenuItem";
|
поставкиToolStripMenuItem.Name = "поставкиToolStripMenuItem";
|
||||||
поставкиToolStripMenuItem.Size = new Size(182, 26);
|
поставкиToolStripMenuItem.Size = new Size(193, 26);
|
||||||
поставкиToolStripMenuItem.Text = "Поставки";
|
поставкиToolStripMenuItem.Text = "Поставки";
|
||||||
поставкиToolStripMenuItem.Click += поставкиToolStripMenuItem_Click;
|
поставкиToolStripMenuItem.Click += поставкиToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// продажиToolStripMenuItem
|
// продажиToolStripMenuItem
|
||||||
//
|
//
|
||||||
продажиToolStripMenuItem.Name = "продажиToolStripMenuItem";
|
продажиToolStripMenuItem.Name = "продажиToolStripMenuItem";
|
||||||
продажиToolStripMenuItem.Size = new Size(182, 26);
|
продажиToolStripMenuItem.Size = new Size(193, 26);
|
||||||
продажиToolStripMenuItem.Text = "Продажи";
|
продажиToolStripMenuItem.Text = "Продажи";
|
||||||
продажиToolStripMenuItem.Click += продажиToolStripMenuItem_Click;
|
продажиToolStripMenuItem.Click += продажиToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
|
// исполнителиToolStripMenuItem
|
||||||
|
//
|
||||||
|
исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem";
|
||||||
|
исполнителиToolStripMenuItem.Size = new Size(193, 26);
|
||||||
|
исполнителиToolStripMenuItem.Text = "Исполнители";
|
||||||
|
исполнителиToolStripMenuItem.Click += исполнителиToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// начатьРаботуToolStripMenuItem
|
||||||
|
//
|
||||||
|
начатьРаботуToolStripMenuItem.Name = "начатьРаботуToolStripMenuItem";
|
||||||
|
начатьРаботуToolStripMenuItem.Size = new Size(193, 26);
|
||||||
|
начатьРаботуToolStripMenuItem.Text = "Начать работу";
|
||||||
|
начатьРаботуToolStripMenuItem.Click += начатьРаботуToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
// отчетыToolStripMenuItem
|
// отчетыToolStripMenuItem
|
||||||
//
|
//
|
||||||
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокКомпонентовToolStripMenuItem, компонентыToolStripMenuItem, списокЗаказовToolStripMenuItem, списокМагазиновToolStripMenuItem, цветыПоМагазинамToolStripMenuItem, заказыПоДатамToolStripMenuItem });
|
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокКомпонентовToolStripMenuItem, компонентыToolStripMenuItem, списокЗаказовToolStripMenuItem, списокМагазиновToolStripMenuItem, цветыПоМагазинамToolStripMenuItem, заказыПоДатамToolStripMenuItem });
|
||||||
@ -141,65 +156,6 @@
|
|||||||
списокЗаказовToolStripMenuItem.Text = "Список заказов";
|
списокЗаказовToolStripMenuItem.Text = "Список заказов";
|
||||||
списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click;
|
списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// DataGridView
|
|
||||||
//
|
|
||||||
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
DataGridView.Location = new Point(12, 31);
|
|
||||||
DataGridView.Name = "DataGridView";
|
|
||||||
DataGridView.RowHeadersWidth = 51;
|
|
||||||
DataGridView.Size = new Size(1007, 407);
|
|
||||||
DataGridView.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// CreateOrderButton
|
|
||||||
//
|
|
||||||
CreateOrderButton.Location = new Point(1025, 31);
|
|
||||||
CreateOrderButton.Name = "CreateOrderButton";
|
|
||||||
CreateOrderButton.Size = new Size(259, 29);
|
|
||||||
CreateOrderButton.TabIndex = 2;
|
|
||||||
CreateOrderButton.Text = "Создать заказ";
|
|
||||||
CreateOrderButton.UseVisualStyleBackColor = true;
|
|
||||||
CreateOrderButton.Click += CreateOrderButton_Click;
|
|
||||||
//
|
|
||||||
// TakeInWorkButton
|
|
||||||
//
|
|
||||||
TakeInWorkButton.Location = new Point(1025, 66);
|
|
||||||
TakeInWorkButton.Name = "TakeInWorkButton";
|
|
||||||
TakeInWorkButton.Size = new Size(259, 29);
|
|
||||||
TakeInWorkButton.TabIndex = 3;
|
|
||||||
TakeInWorkButton.Text = "Отдать заказ в работу";
|
|
||||||
TakeInWorkButton.UseVisualStyleBackColor = true;
|
|
||||||
TakeInWorkButton.Click += TakeInWorkButton_Click;
|
|
||||||
//
|
|
||||||
// ReadyButton
|
|
||||||
//
|
|
||||||
ReadyButton.Location = new Point(1025, 101);
|
|
||||||
ReadyButton.Name = "ReadyButton";
|
|
||||||
ReadyButton.Size = new Size(259, 29);
|
|
||||||
ReadyButton.TabIndex = 4;
|
|
||||||
ReadyButton.Text = "Заказ готов";
|
|
||||||
ReadyButton.UseVisualStyleBackColor = true;
|
|
||||||
ReadyButton.Click += ReadyButton_Click;
|
|
||||||
//
|
|
||||||
// IssuedButton
|
|
||||||
//
|
|
||||||
IssuedButton.Location = new Point(1025, 136);
|
|
||||||
IssuedButton.Name = "IssuedButton";
|
|
||||||
IssuedButton.Size = new Size(259, 29);
|
|
||||||
IssuedButton.TabIndex = 5;
|
|
||||||
IssuedButton.Text = "Заказ выдан";
|
|
||||||
IssuedButton.UseVisualStyleBackColor = true;
|
|
||||||
IssuedButton.Click += IssuedButton_Click;
|
|
||||||
//
|
|
||||||
// RefreshButton
|
|
||||||
//
|
|
||||||
RefreshButton.Location = new Point(1025, 171);
|
|
||||||
RefreshButton.Name = "RefreshButton";
|
|
||||||
RefreshButton.Size = new Size(259, 29);
|
|
||||||
RefreshButton.TabIndex = 6;
|
|
||||||
RefreshButton.Text = "Обновить";
|
|
||||||
RefreshButton.UseVisualStyleBackColor = true;
|
|
||||||
RefreshButton.Click += RefreshButton_Click;
|
|
||||||
//
|
|
||||||
// списокМагазиновToolStripMenuItem
|
// списокМагазиновToolStripMenuItem
|
||||||
//
|
//
|
||||||
списокМагазиновToolStripMenuItem.Name = "списокМагазиновToolStripMenuItem";
|
списокМагазиновToolStripMenuItem.Name = "списокМагазиновToolStripMenuItem";
|
||||||
@ -221,11 +177,70 @@
|
|||||||
заказыПоДатамToolStripMenuItem.Text = "Заказы по датам";
|
заказыПоДатамToolStripMenuItem.Text = "Заказы по датам";
|
||||||
заказыПоДатамToolStripMenuItem.Click += заказыПоДатамToolStripMenuItem_Click;
|
заказыПоДатамToolStripMenuItem.Click += заказыПоДатамToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
|
// DataGridView
|
||||||
|
//
|
||||||
|
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
DataGridView.Location = new Point(12, 31);
|
||||||
|
DataGridView.Name = "DataGridView";
|
||||||
|
DataGridView.RowHeadersWidth = 51;
|
||||||
|
DataGridView.Size = new Size(1125, 407);
|
||||||
|
DataGridView.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// CreateOrderButton
|
||||||
|
//
|
||||||
|
CreateOrderButton.Location = new Point(1143, 31);
|
||||||
|
CreateOrderButton.Name = "CreateOrderButton";
|
||||||
|
CreateOrderButton.Size = new Size(259, 29);
|
||||||
|
CreateOrderButton.TabIndex = 2;
|
||||||
|
CreateOrderButton.Text = "Создать заказ";
|
||||||
|
CreateOrderButton.UseVisualStyleBackColor = true;
|
||||||
|
CreateOrderButton.Click += CreateOrderButton_Click;
|
||||||
|
//
|
||||||
|
// TakeInWorkButton
|
||||||
|
//
|
||||||
|
TakeInWorkButton.Location = new Point(1143, 66);
|
||||||
|
TakeInWorkButton.Name = "TakeInWorkButton";
|
||||||
|
TakeInWorkButton.Size = new Size(259, 29);
|
||||||
|
TakeInWorkButton.TabIndex = 3;
|
||||||
|
TakeInWorkButton.Text = "Отдать заказ в работу";
|
||||||
|
TakeInWorkButton.UseVisualStyleBackColor = true;
|
||||||
|
TakeInWorkButton.Click += TakeInWorkButton_Click;
|
||||||
|
//
|
||||||
|
// ReadyButton
|
||||||
|
//
|
||||||
|
ReadyButton.Location = new Point(1143, 101);
|
||||||
|
ReadyButton.Name = "ReadyButton";
|
||||||
|
ReadyButton.Size = new Size(259, 29);
|
||||||
|
ReadyButton.TabIndex = 4;
|
||||||
|
ReadyButton.Text = "Заказ готов";
|
||||||
|
ReadyButton.UseVisualStyleBackColor = true;
|
||||||
|
ReadyButton.Click += ReadyButton_Click;
|
||||||
|
//
|
||||||
|
// IssuedButton
|
||||||
|
//
|
||||||
|
IssuedButton.Location = new Point(1143, 136);
|
||||||
|
IssuedButton.Name = "IssuedButton";
|
||||||
|
IssuedButton.Size = new Size(259, 29);
|
||||||
|
IssuedButton.TabIndex = 5;
|
||||||
|
IssuedButton.Text = "Заказ выдан";
|
||||||
|
IssuedButton.UseVisualStyleBackColor = true;
|
||||||
|
IssuedButton.Click += IssuedButton_Click;
|
||||||
|
//
|
||||||
|
// RefreshButton
|
||||||
|
//
|
||||||
|
RefreshButton.Location = new Point(1143, 171);
|
||||||
|
RefreshButton.Name = "RefreshButton";
|
||||||
|
RefreshButton.Size = new Size(259, 29);
|
||||||
|
RefreshButton.TabIndex = 6;
|
||||||
|
RefreshButton.Text = "Обновить";
|
||||||
|
RefreshButton.UseVisualStyleBackColor = true;
|
||||||
|
RefreshButton.Click += RefreshButton_Click;
|
||||||
|
//
|
||||||
// MainForm
|
// MainForm
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(1296, 450);
|
ClientSize = new Size(1414, 450);
|
||||||
Controls.Add(RefreshButton);
|
Controls.Add(RefreshButton);
|
||||||
Controls.Add(IssuedButton);
|
Controls.Add(IssuedButton);
|
||||||
Controls.Add(ReadyButton);
|
Controls.Add(ReadyButton);
|
||||||
@ -267,5 +282,7 @@
|
|||||||
private ToolStripMenuItem списокМагазиновToolStripMenuItem;
|
private ToolStripMenuItem списокМагазиновToolStripMenuItem;
|
||||||
private ToolStripMenuItem цветыПоМагазинамToolStripMenuItem;
|
private ToolStripMenuItem цветыПоМагазинамToolStripMenuItem;
|
||||||
private ToolStripMenuItem заказыПоДатамToolStripMenuItem;
|
private ToolStripMenuItem заказыПоДатамToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem начатьРаботуToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,12 +22,15 @@ namespace ProjectFlowerShop
|
|||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IOrderLogic _orderLogic;
|
private readonly IOrderLogic _orderLogic;
|
||||||
private readonly IReportLogic _reportLogic;
|
private readonly IReportLogic _reportLogic;
|
||||||
public MainForm(ILogger<MainForm> logger, IOrderLogic orderLogic, IReportLogic reportLogic)
|
private readonly IWorkProcess _workProcess;
|
||||||
|
|
||||||
|
public MainForm(ILogger<MainForm> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_orderLogic = orderLogic;
|
_orderLogic = orderLogic;
|
||||||
_reportLogic = reportLogic;
|
_reportLogic = reportLogic;
|
||||||
|
_workProcess = workProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void КомпонентыStripMenuItem_Click(object sender, EventArgs e)
|
private void КомпонентыStripMenuItem_Click(object sender, EventArgs e)
|
||||||
@ -54,6 +57,7 @@ namespace ProjectFlowerShop
|
|||||||
DataGridView.DataSource = list;
|
DataGridView.DataSource = list;
|
||||||
DataGridView.Columns["FlowerId"].Visible = false;
|
DataGridView.Columns["FlowerId"].Visible = false;
|
||||||
DataGridView.Columns["ClientId"].Visible = false;
|
DataGridView.Columns["ClientId"].Visible = false;
|
||||||
|
DataGridView.Columns["ImplementerId"].Visible = false;
|
||||||
DataGridView.Columns["FlowerName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
DataGridView.Columns["FlowerName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Загрузка заказов");
|
_logger.LogInformation("Загрузка заказов");
|
||||||
@ -283,5 +287,21 @@ namespace ProjectFlowerShop
|
|||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(ImplementersForm));
|
||||||
|
if (service is ImplementersForm form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void начатьРаботуToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic);
|
||||||
|
MessageBox.Show("Процесс обработки запущен", "Сообщение",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,10 @@ namespace ProjectFlowerShop
|
|||||||
services.AddTransient<IShopStorage, ShopStorage>();
|
services.AddTransient<IShopStorage, ShopStorage>();
|
||||||
services.AddTransient<IShopLogic, ShopLogic>();
|
services.AddTransient<IShopLogic, ShopLogic>();
|
||||||
services.AddTransient<IReportLogic, ReportLogic>();
|
services.AddTransient<IReportLogic, ReportLogic>();
|
||||||
|
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||||
|
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||||
services.AddTransient<IClientLogic, ClientLogic>();
|
services.AddTransient<IClientLogic, ClientLogic>();
|
||||||
|
services.AddTransient<IWorkProcess, WorkProcess>();
|
||||||
services.AddTransient<MainForm>();
|
services.AddTransient<MainForm>();
|
||||||
services.AddTransient<ComponentForm>();
|
services.AddTransient<ComponentForm>();
|
||||||
services.AddTransient<FormComponents>();
|
services.AddTransient<FormComponents>();
|
||||||
@ -64,6 +67,8 @@ namespace ProjectFlowerShop
|
|||||||
services.AddTransient<FormReportShopsFlowers>();
|
services.AddTransient<FormReportShopsFlowers>();
|
||||||
services.AddTransient<FormReportDateOrders>();
|
services.AddTransient<FormReportDateOrders>();
|
||||||
services.AddTransient<FormReportFlowerComponent>();
|
services.AddTransient<FormReportFlowerComponent>();
|
||||||
|
services.AddTransient<ImplementersForm>();
|
||||||
|
services.AddTransient<ImplementerForm>();
|
||||||
services.AddTransient<FormReportOrders>();
|
services.AddTransient<FormReportOrders>();
|
||||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user