ПИбд-21 Кувшинов Тимур сложная лаба 6 #23
@ -0,0 +1,121 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
||||
using AutomobilePlantContracts.SearchModels;
|
||||
using AutomobilePlantContracts.StoragesContracts;
|
||||
using AutomobilePlantContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace AutomobilePlantBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ImplementerLogic : IImplementerLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IImplementerStorage _implementerStorage;
|
||||
public ImplementerLogic(ILogger<ImplementerLogic> logger, IImplementerStorage implementerStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_implementerStorage = implementerStorage;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public ImplementerViewModel? ReadElement(ImplementerSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. FIO:{FIO}.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 List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. FIO:{FIO}.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;
|
||||
}
|
||||
|
||||
private void CheckModel(ImplementerBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (model.WorkExperience < 0)
|
||||
{
|
||||
throw new ArgumentException("Стаж работы не может быть меньше нуля", nameof(model.WorkExperience));
|
||||
}
|
||||
if (model.Qualification < 0)
|
||||
{
|
||||
throw new ArgumentException("Квалификация не должна быть меньше нуля", nameof(model.Qualification));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
throw new ArgumentNullException("Нет пароля исполнителя", nameof(model.ImplementerFIO));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.ImplementerFIO))
|
||||
{
|
||||
throw new ArgumentNullException("Нет ФИО исполнителя", nameof(model.ImplementerFIO));
|
||||
}
|
||||
_logger.LogInformation("Implementer. Id: {Id}, FIO: {FIO}", model.Id, model.ImplementerFIO);
|
||||
var element = _implementerStorage.GetElement(new ImplementerSearchModel
|
||||
{
|
||||
ImplementerFIO = model.ImplementerFIO,
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Исполнитель с таким ФИО уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -21,6 +21,7 @@ namespace AutomobilePlantBusinessLogic.BusinessLogics
|
||||
private readonly IShopStorage _shopStorage;
|
||||
private readonly IShopLogic _shopLogic;
|
||||
private readonly ICarStorage _carStorage;
|
||||
static readonly object locker = new object();
|
||||
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IShopLogic shopLogic, ICarStorage carStorage, IShopStorage shopStorage)
|
||||
{
|
||||
@ -44,6 +45,23 @@ namespace AutomobilePlantBusinessLogic.BusinessLogics
|
||||
return list;
|
||||
}
|
||||
|
||||
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 bool CreateOrder(OrderBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
@ -130,12 +148,19 @@ namespace AutomobilePlantBusinessLogic.BusinessLogics
|
||||
_logger.LogWarning("Read operation failed");
|
||||
return false;
|
||||
}
|
||||
if (element.Status != status - 1)
|
||||
if (element.Status != status - 1 && element.Status != OrderStatus.Ожидание)
|
||||
{
|
||||
_logger.LogWarning("Status change operation failed");
|
||||
throw new InvalidOperationException("Текущий статус заказа не может быть переведен в выбранный");
|
||||
}
|
||||
|
||||
if (element.ImplementerId.HasValue)
|
||||
model.ImplementerId = element.ImplementerId;
|
||||
if (model.CarId == 0)
|
||||
model.CarId = element.CarId;
|
||||
if (model.Count == 0)
|
||||
model.Count = element.Count;
|
||||
|
||||
if (status == OrderStatus.Выдан)
|
||||
{
|
||||
var car = _carStorage.GetElement(new CarSearchModel() { Id = model.CarId });
|
||||
@ -148,17 +173,19 @@ namespace AutomobilePlantBusinessLogic.BusinessLogics
|
||||
if (!CheckThenSupplyMany(car, model.Count))
|
||||
{
|
||||
_logger.LogWarning("Status change operation failed. Shop supply error.");
|
||||
model.Status = OrderStatus.Ожидание;
|
||||
if (_orderStorage.Update(model) == null)
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
OrderStatus oldStatus = model.Status;
|
||||
model.Status = status;
|
||||
if (model.Status == OrderStatus.Выдан)
|
||||
model.DateImplement = DateTime.Now;
|
||||
if (_orderStorage.Update(model) == null)
|
||||
{
|
||||
model.Status = oldStatus;
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
@ -167,7 +194,10 @@ namespace AutomobilePlantBusinessLogic.BusinessLogics
|
||||
|
||||
public bool TakeOrderInWork(OrderBindingModel model)
|
||||
{
|
||||
return ChangeStatus(model, OrderStatus.Выполняется);
|
||||
lock (locker)
|
||||
{
|
||||
return ChangeStatus(model, OrderStatus.Выполняется);
|
||||
}
|
||||
}
|
||||
|
||||
public bool FinishOrder(OrderBindingModel model)
|
||||
|
@ -0,0 +1,216 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
||||
using AutomobilePlantContracts.SearchModels;
|
||||
using AutomobilePlantContracts.ViewModels;
|
||||
using AutomobilePlantDataModels.Enums;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace AutomobilePlantBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class WorkModeling : IWorkProcess
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly Random _rnd;
|
||||
|
||||
private IOrderLogic? _orderLogic;
|
||||
|
||||
public WorkModeling(ILogger<WorkModeling> 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 orders = _orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Принят });
|
||||
if (orders == null)
|
||||
{
|
||||
_logger.LogWarning("DoWork. Orders is null");
|
||||
return;
|
||||
}
|
||||
orders.AddRange(_orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Выполняется }) ?? new());
|
||||
orders.AddRange(_orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Ожидание }) ?? new());
|
||||
if (orders.Count == 0)
|
||||
{
|
||||
_logger.LogWarning("DoWork. Orders is empty");
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogDebug("DoWork for {Count} orders", orders.Count);
|
||||
|
||||
foreach (var implementer in implementers)
|
||||
{
|
||||
Task.Run(() => WorkerWorkAsync(implementer, orders));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Иммитация работы исполнителя
|
||||
/// </summary>
|
||||
/// <param name="implementer"></param>
|
||||
/// <param name="orders"></param>
|
||||
private async Task WorkerWorkAsync(ImplementerViewModel implementer, List<OrderViewModel> orders)
|
||||
{
|
||||
if (_orderLogic == null || implementer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await RunWaitingOrder(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
|
||||
});
|
||||
// доставляем
|
||||
_logger.LogDebug("DoWork. Worker {Id} delivery order {Order}", implementer.Id, order.Id);
|
||||
_orderLogic.DeliveryOrder(new OrderBindingModel
|
||||
{
|
||||
Id = order.Id
|
||||
});
|
||||
}
|
||||
// кто-то мог уже перехватить заказ, игнорируем ошибку
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Error try get work");
|
||||
}
|
||||
// заканчиваем выполнение имитации в случае иной ошибки
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error while do work");
|
||||
throw;
|
||||
}
|
||||
// отдыхаем
|
||||
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищем заказ, которые уже в работе (вдруг исполнителя прервали)
|
||||
/// </summary>
|
||||
/// <param name="implementer"></param>
|
||||
/// <returns></returns>
|
||||
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
|
||||
});
|
||||
|
||||
// доставляем
|
||||
_logger.LogDebug("DoWork. Worker {Id} delivery order {Order}", implementer.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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищем заказ, которые ждут выдачи (вдруг место освободилось)
|
||||
/// </summary>
|
||||
/// <param name="implementer"></param>
|
||||
/// <returns></returns>
|
||||
private async Task RunWaitingOrder(ImplementerViewModel implementer)
|
||||
{
|
||||
if (_orderLogic == null || implementer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var order = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel
|
||||
{
|
||||
ImplementerId = implementer.Id,
|
||||
Status = OrderStatus.Ожидание
|
||||
}));
|
||||
if (order == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// доставляем
|
||||
_logger.LogDebug("DoWork. Worker {Id} delivery order {Order}", implementer.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using AutomobilePlantDataModels.Models;
|
||||
|
||||
namespace AutomobilePlantContracts.BindingModels
|
||||
{
|
||||
public class ImplementerBindingModel : IImplementerModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
public int WorkExperience { get; set; }
|
||||
|
||||
public int Qualification { get; set; }
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@ namespace AutomobilePlantContracts.BindingModels
|
||||
public int Id { get; set; }
|
||||
public int CarId { get; set; }
|
||||
public int ClientId { get; set; }
|
||||
public int? ImplementerId { get; set; }
|
||||
public int Count { get; set; }
|
||||
public double Sum { get; set; }
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
|
@ -0,0 +1,19 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.SearchModels;
|
||||
using AutomobilePlantContracts.ViewModels;
|
||||
|
||||
namespace AutomobilePlantContracts.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);
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@ namespace AutomobilePlantContracts.BusinessLogicsContracts
|
||||
public interface IOrderLogic
|
||||
{
|
||||
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
||||
OrderViewModel? ReadElement(OrderSearchModel model);
|
||||
bool CreateOrder(OrderBindingModel model);
|
||||
bool TakeOrderInWork(OrderBindingModel model);
|
||||
bool FinishOrder(OrderBindingModel model);
|
||||
|
@ -0,0 +1,10 @@
|
||||
namespace AutomobilePlantContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IWorkProcess
|
||||
{
|
||||
/// <summary>
|
||||
/// Запуск работ
|
||||
/// </summary>
|
||||
void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic);
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
namespace AutomobilePlantContracts.SearchModels
|
||||
{
|
||||
public class ImplementerSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? ImplementerFIO { get; set; }
|
||||
public string? Password { get; set; }
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using AutomobilePlantDataModels.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -12,5 +13,7 @@ namespace AutomobilePlantContracts.SearchModels
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
public int? ClientId { get; set; }
|
||||
public int? ImplementerId { get; set; }
|
||||
public OrderStatus? Status { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.SearchModels;
|
||||
using AutomobilePlantContracts.ViewModels;
|
||||
|
||||
namespace AutomobilePlantContracts.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);
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using AutomobilePlantDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace AutomobilePlantContracts.ViewModels
|
||||
{
|
||||
public class ImplementerViewModel : IImplementerModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("FIO")]
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Password")]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Work expirience")]
|
||||
public int WorkExperience { get; set; }
|
||||
|
||||
[DisplayName("Qualification")]
|
||||
public int Qualification { get; set; }
|
||||
}
|
||||
}
|
@ -19,6 +19,9 @@ namespace AutomobilePlantContracts.ViewModels
|
||||
public int ClientId { get; set; }
|
||||
[DisplayName("Client's FIO")]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
public int? ImplementerId { get; set; }
|
||||
[DisplayName("Implementer's FIO")]
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
[DisplayName("Count")]
|
||||
public int Count { get; set; }
|
||||
[DisplayName("Sum")]
|
||||
|
@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutomobilePlantDataModels.Enums
|
||||
namespace AutomobilePlantDataModels.Enums
|
||||
{
|
||||
public enum OrderStatus
|
||||
{
|
||||
@ -12,6 +6,7 @@ namespace AutomobilePlantDataModels.Enums
|
||||
Принят = 0,
|
||||
Выполняется = 1,
|
||||
Готов = 2,
|
||||
Выдан = 3
|
||||
Выдан = 3,
|
||||
Ожидание = 4
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
namespace AutomobilePlantDataModels.Models
|
||||
{
|
||||
public interface IImplementerModel : IId
|
||||
{
|
||||
string ImplementerFIO { get; }
|
||||
string Password { get; }
|
||||
int WorkExperience { get; }
|
||||
int Qualification { get; }
|
||||
}
|
||||
}
|
@ -10,6 +10,8 @@ namespace AutomobilePlantDataModels.Models
|
||||
public interface IOrderModel : IId
|
||||
{
|
||||
int CarId { get; }
|
||||
int ClientId { get; }
|
||||
int? ImplementerId { get; }
|
||||
int Count { get; }
|
||||
double Sum { get; }
|
||||
OrderStatus Status { get; }
|
||||
|
@ -20,5 +20,6 @@ namespace AutomobilePlantDatabaseImplement
|
||||
public virtual DbSet<Shop> Shops { set; get; }
|
||||
public virtual DbSet<ShopCar> ShopCars { set; get; }
|
||||
public virtual DbSet<Client> Clients { set; get; }
|
||||
public virtual DbSet<Implementer> Implementers { set; get; }
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,79 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.SearchModels;
|
||||
using AutomobilePlantContracts.StoragesContracts;
|
||||
using AutomobilePlantContracts.ViewModels;
|
||||
using AutomobilePlantDatabaseImplement.Models;
|
||||
|
||||
namespace AutomobilePlantDatabaseImplement.Implements
|
||||
{
|
||||
public class ImplementerStorage : IImplementerStorage
|
||||
{
|
||||
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
||||
{
|
||||
using var context = new AutomobilePlantDatabase();
|
||||
if (model.Id.HasValue) return context.Implementers.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
if (model.ImplementerFIO != null && model.Password != null) return context.Implementers.FirstOrDefault(x => x.ImplementerFIO.Equals(model.ImplementerFIO) && x.Password.Equals(model.Password))?.GetViewModel;
|
||||
if (model.ImplementerFIO != null) return context.Implementers.FirstOrDefault(x => x.ImplementerFIO.Equals(model.ImplementerFIO))?.GetViewModel;
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
if (model.ImplementerFIO != null)
|
||||
{
|
||||
using var context = new AutomobilePlantDatabase();
|
||||
return context.Implementers
|
||||
.Where(x => x.ImplementerFIO.Contains(model.ImplementerFIO))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return new();
|
||||
}
|
||||
|
||||
public List<ImplementerViewModel> GetFullList()
|
||||
{
|
||||
using var context = new AutomobilePlantDatabase();
|
||||
return context.Implementers.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public ImplementerViewModel? Insert(ImplementerBindingModel model)
|
||||
{
|
||||
using var context = new AutomobilePlantDatabase();
|
||||
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 AutomobilePlantDatabase();
|
||||
var res = context.Implementers.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (res != null)
|
||||
{
|
||||
res.Update(model);
|
||||
context.SaveChanges();
|
||||
}
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
|
||||
public ImplementerViewModel? Delete(ImplementerBindingModel model)
|
||||
{
|
||||
using var context = new AutomobilePlantDatabase();
|
||||
var res = context.Implementers.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (res != null)
|
||||
{
|
||||
context.Implementers.Remove(res);
|
||||
context.SaveChanges();
|
||||
}
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -16,25 +16,34 @@ namespace AutomobilePlantDatabaseImplement.Implements
|
||||
{
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new AutomobilePlantDatabase();
|
||||
return context.Orders.Include(x => x.Car).Include(x => x.Client).FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
return context.Orders
|
||||
.Include(x => x.Car)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.FirstOrDefault(x =>
|
||||
(model.Status == null || model.Status != null && model.Status.Equals(x.Status)) &&
|
||||
(model.ImplementerId.HasValue && x.ImplementerId == model.ImplementerId) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))?
|
||||
.GetViewModel;
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue)
|
||||
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue && model.Status == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new AutomobilePlantDatabase();
|
||||
return context.Orders
|
||||
.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo || x.ClientId == model.ClientId)
|
||||
.Where(x =>
|
||||
x.Id == model.Id ||
|
||||
model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo ||
|
||||
x.ClientId == model.ClientId ||
|
||||
model.Status.Equals(x.Status))
|
||||
.Include(x => x.Car)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@ -42,7 +51,11 @@ namespace AutomobilePlantDatabaseImplement.Implements
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
using var context = new AutomobilePlantDatabase();
|
||||
return context.Orders.Include(x => x.Car).Include(x => x.Client).Select(x => x.GetViewModel).ToList();
|
||||
return context.Orders
|
||||
.Include(x => x.Car)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
@ -55,7 +68,11 @@ namespace AutomobilePlantDatabaseImplement.Implements
|
||||
using var context = new AutomobilePlantDatabase();
|
||||
context.Orders.Add(newOrder);
|
||||
context.SaveChanges();
|
||||
return context.Orders.Include(x => x.Car).Include(x => x.Client).FirstOrDefault(x => x.Id == newOrder.Id)?.GetViewModel;
|
||||
return context.Orders
|
||||
.Include(x => x.Car)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.FirstOrDefault(x => x.Id == newOrder.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
@ -68,12 +85,20 @@ namespace AutomobilePlantDatabaseImplement.Implements
|
||||
}
|
||||
order.Update(model);
|
||||
context.SaveChanges();
|
||||
return context.Orders.Include(x => x.Car).Include(x => x.Client).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
return context.Orders
|
||||
.Include(x => x.Car)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
using var context = new AutomobilePlantDatabase();
|
||||
var element = context.Orders.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
var element = context.Orders
|
||||
.Include(x => x.Car)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Orders.Remove(element);
|
||||
|
257
AutomobilePlant/AutomobilePlantDatabaseImplement/Migrations/20240419183903_MbINeedItLaba6.Designer.cs
generated
Normal file
257
AutomobilePlant/AutomobilePlantDatabaseImplement/Migrations/20240419183903_MbINeedItLaba6.Designer.cs
generated
Normal file
@ -0,0 +1,257 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using AutomobilePlantDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AutomobilePlantDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(AutomobilePlantDatabase))]
|
||||
[Migration("20240419183903_MbINeedItLaba6")]
|
||||
partial class MbINeedItLaba6
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.16")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDatabaseImplement.Models.Car", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("CarName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Cars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDatabaseImplement.Models.CarComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CarId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CarId");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.ToTable("CarComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ClientFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDatabaseImplement.Models.Implementer", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
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("AutomobilePlantDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CarId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int?>("ImplementerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CarId");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("ImplementerId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDatabaseImplement.Models.CarComponent", b =>
|
||||
{
|
||||
b.HasOne("AutomobilePlantDatabaseImplement.Models.Car", "Car")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("CarId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AutomobilePlantDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("CarComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Car");
|
||||
|
||||
b.Navigation("Component");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("AutomobilePlantDatabaseImplement.Models.Car", "Car")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("CarId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AutomobilePlantDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AutomobilePlantDatabaseImplement.Models.Implementer", "Implementer")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ImplementerId");
|
||||
|
||||
b.Navigation("Car");
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Implementer");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDatabaseImplement.Models.Car", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("CarComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDatabaseImplement.Models.Implementer", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AutomobilePlantDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class MbINeedItLaba6 : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ImplementerId",
|
||||
table: "Orders",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
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),
|
||||
WorkExperience = table.Column<int>(type: "int", nullable: false),
|
||||
Qualification = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Implementers", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_ImplementerId",
|
||||
table: "Orders",
|
||||
column: "ImplementerId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Orders_Implementers_ImplementerId",
|
||||
table: "Orders",
|
||||
column: "ImplementerId",
|
||||
principalTable: "Implementers",
|
||||
principalColumn: "Id");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Orders_Implementers_ImplementerId",
|
||||
table: "Orders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Implementers");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Orders_ImplementerId",
|
||||
table: "Orders");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ImplementerId",
|
||||
table: "Orders");
|
||||
}
|
||||
}
|
||||
}
|
@ -113,6 +113,33 @@ namespace AutomobilePlantDatabaseImplement.Migrations
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDatabaseImplement.Models.Implementer", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
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("AutomobilePlantDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -136,6 +163,9 @@ namespace AutomobilePlantDatabaseImplement.Migrations
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int?>("ImplementerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
@ -148,6 +178,8 @@ namespace AutomobilePlantDatabaseImplement.Migrations
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("ImplementerId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
@ -237,9 +269,15 @@ namespace AutomobilePlantDatabaseImplement.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AutomobilePlantDatabaseImplement.Models.Implementer", "Implementer")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ImplementerId");
|
||||
|
||||
b.Navigation("Car");
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Implementer");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDatabaseImplement.Models.ShopCar", b =>
|
||||
@ -282,6 +320,11 @@ namespace AutomobilePlantDatabaseImplement.Migrations
|
||||
{
|
||||
b.Navigation("Cars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutomobilePlantDatabaseImplement.Models.Implementer", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,60 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.ViewModels;
|
||||
using AutomobilePlantDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace AutomobilePlantDatabaseImplement.Models
|
||||
{
|
||||
public class Implementer : IImplementerModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||
|
||||
public string Password { get; private set; } = string.Empty;
|
||||
|
||||
public int WorkExperience { get; private set; }
|
||||
|
||||
public int Qualification { get; private set; }
|
||||
|
||||
[ForeignKey("ImplementerId")]
|
||||
public virtual List<Order> Orders { get; private set; } = new();
|
||||
|
||||
public static Implementer? Create(ImplementerBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new()
|
||||
{
|
||||
Id = model.Id,
|
||||
ImplementerFIO = model.ImplementerFIO,
|
||||
Password = model.Password,
|
||||
Qualification = model.Qualification,
|
||||
WorkExperience = model.WorkExperience,
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ImplementerBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ImplementerFIO = model.ImplementerFIO;
|
||||
Password = model.Password;
|
||||
Qualification = model.Qualification;
|
||||
WorkExperience = model.WorkExperience;
|
||||
}
|
||||
|
||||
public ImplementerViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ImplementerFIO = ImplementerFIO,
|
||||
Password = Password,
|
||||
Qualification = Qualification,
|
||||
WorkExperience = WorkExperience,
|
||||
};
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@ namespace AutomobilePlantDatabaseImplement.Models
|
||||
public int CarId { get; private set; }
|
||||
[Required]
|
||||
public int ClientId { get; private set; }
|
||||
public int? ImplementerId { get; private set; }
|
||||
[Required]
|
||||
public int Count { get; private set; }
|
||||
[Required]
|
||||
@ -31,6 +32,7 @@ namespace AutomobilePlantDatabaseImplement.Models
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
public virtual Car Car { get; private set; }
|
||||
public virtual Client Client { get; set; }
|
||||
public Implementer? Implementer { get; private set; }
|
||||
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
{
|
||||
@ -42,6 +44,7 @@ namespace AutomobilePlantDatabaseImplement.Models
|
||||
{
|
||||
CarId = model.CarId,
|
||||
ClientId = model.ClientId,
|
||||
ImplementerId = model.ImplementerId,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
@ -59,6 +62,7 @@ namespace AutomobilePlantDatabaseImplement.Models
|
||||
}
|
||||
Status = model.Status;
|
||||
DateImplement = model.DateImplement;
|
||||
ImplementerId = model.ImplementerId;
|
||||
}
|
||||
|
||||
public OrderViewModel GetViewModel => new()
|
||||
@ -66,13 +70,15 @@ namespace AutomobilePlantDatabaseImplement.Models
|
||||
Id = Id,
|
||||
CarId = CarId,
|
||||
ClientId = ClientId,
|
||||
ImplementerId = ImplementerId,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement,
|
||||
Status = Status,
|
||||
CarName = Car.CarName,
|
||||
ClientFIO = Client.ClientFIO
|
||||
CarName = Car.CarName ?? string.Empty,
|
||||
ClientFIO = Client.ClientFIO ?? string.Empty,
|
||||
ImplementerFIO = Implementer?.ImplementerFIO ?? string.Empty,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -16,11 +16,13 @@ namespace AutomobilePlantFileImplement
|
||||
private readonly string CarFileName = "Car.xml";
|
||||
private readonly string ShopFileName = "Shop.xml";
|
||||
private readonly string ClientFileName = "Client.xml";
|
||||
private readonly string ImplementerFileName = "Implementer.xml";
|
||||
public List<Component> Components { get; private set; }
|
||||
public List<Order> Orders { get; private set; }
|
||||
public List<Car> Cars { get; private set; }
|
||||
public List<Shop> Shops { get; private set; }
|
||||
public List<Client> Clients { get; private set; }
|
||||
public List<Implementer> Implementers { get; private set; }
|
||||
public static DataFileSingleton GetInstance()
|
||||
{
|
||||
if (instance == null)
|
||||
@ -34,6 +36,7 @@ namespace AutomobilePlantFileImplement
|
||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
||||
public void SaveShops() => SaveData(Shops, ShopFileName, "Shops", x => x.GetXElement);
|
||||
public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement);
|
||||
public void SaveImplementers() => SaveData(Orders, ImplementerFileName, "Implementers", x => x.GetXElement);
|
||||
private DataFileSingleton()
|
||||
{
|
||||
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
||||
@ -41,6 +44,7 @@ namespace AutomobilePlantFileImplement
|
||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||
Shops = LoadData(ShopFileName, "Shop", x => Shop.Create(x)!)!;
|
||||
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
|
||||
Implementers = LoadData(ImplementerFileName, "Impleneter", x => Implementer.Create(x)!)!;
|
||||
}
|
||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
||||
{
|
||||
|
@ -0,0 +1,79 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.SearchModels;
|
||||
using AutomobilePlantContracts.StoragesContracts;
|
||||
using AutomobilePlantContracts.ViewModels;
|
||||
using AutomobilePlantFileImplement.Models;
|
||||
|
||||
namespace AutomobilePlantFileImplement.Implements
|
||||
{
|
||||
public class ImplementerStorage : IImplementerStorage
|
||||
{
|
||||
private readonly DataFileSingleton _source;
|
||||
public ImplementerStorage()
|
||||
{
|
||||
_source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
||||
{
|
||||
if (model.Id.HasValue) return _source.Implementers.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
if (model.ImplementerFIO != null && model.Password != null) return _source.Implementers.FirstOrDefault(x => x.ImplementerFIO.Equals(model.ImplementerFIO) && x.Password.Equals(model.Password))?.GetViewModel;
|
||||
if (model.ImplementerFIO != null) return _source.Implementers.FirstOrDefault(x => x.ImplementerFIO.Equals(model.ImplementerFIO))?.GetViewModel;
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
if (model.ImplementerFIO != null)
|
||||
{
|
||||
return _source.Implementers
|
||||
.Where(x => x.ImplementerFIO.Contains(model.ImplementerFIO))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return new();
|
||||
}
|
||||
|
||||
public List<ImplementerViewModel> GetFullList()
|
||||
{
|
||||
return _source.Implementers.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public ImplementerViewModel? Insert(ImplementerBindingModel model)
|
||||
{
|
||||
model.Id = _source.Implementers.Count > 0 ? _source.Implementers.Max(x => x.Id) + 1 : 1;
|
||||
var res = Implementer.Create(model);
|
||||
if (res != null)
|
||||
{
|
||||
_source.Implementers.Add(res);
|
||||
_source.SaveImplementers();
|
||||
}
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
|
||||
public ImplementerViewModel? Update(ImplementerBindingModel model)
|
||||
{
|
||||
var res = _source.Implementers.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (res != null)
|
||||
{
|
||||
res.Update(model);
|
||||
_source.SaveImplementers();
|
||||
}
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
|
||||
public ImplementerViewModel? Delete(ImplementerBindingModel model)
|
||||
{
|
||||
var res = _source.Implementers.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (res != null)
|
||||
{
|
||||
_source.Implementers.Remove(res);
|
||||
_source.SaveImplementers();
|
||||
}
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +1,8 @@
|
||||
using System;
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.SearchModels;
|
||||
using AutomobilePlantContracts.StoragesContracts;
|
||||
using AutomobilePlantContracts.ViewModels;
|
||||
using AutomobilePlantFileImplement.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutomobilePlantFileImplement.Implements
|
||||
{
|
||||
@ -26,18 +21,24 @@ namespace AutomobilePlantFileImplement.Implements
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return GetViewModel(source.Orders
|
||||
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id)));
|
||||
|
||||
if (model.ImplementerId.HasValue && model.Status != null)
|
||||
return source.Orders.FirstOrDefault(x => x.ImplementerId == model.ImplementerId && model.Status.Equals(x.Status))?.GetViewModel;
|
||||
|
||||
return GetViewModel(source.Orders.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id)));
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue)
|
||||
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue && model.Status == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return source.Orders
|
||||
.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo || x.ClientId == model.ClientId)
|
||||
.Where(x => x.Id == model.Id ||
|
||||
model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo ||
|
||||
x.ClientId == model.ClientId ||
|
||||
model.Status.Equals(x.Status))
|
||||
.Select(x => GetViewModel(x))
|
||||
.ToList();
|
||||
}
|
||||
|
@ -0,0 +1,80 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.ViewModels;
|
||||
using AutomobilePlantDataModels.Models;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace AutomobilePlantFileImplement.Models
|
||||
{
|
||||
public class Implementer : IImplementerModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||
|
||||
public string Password { get; private set; } = string.Empty;
|
||||
|
||||
public int WorkExperience { get; private set; }
|
||||
|
||||
public int Qualification { get; private set; }
|
||||
|
||||
public static Implementer? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
ImplementerFIO = element.Element("FIO")!.Value,
|
||||
Password = element.Element("Password")!.Value,
|
||||
Qualification = Convert.ToInt32(element.Element("Qualification")!.Value),
|
||||
WorkExperience = Convert.ToInt32(element.Element("WorkExperience")!.Value),
|
||||
};
|
||||
}
|
||||
|
||||
public static Implementer? Create(ImplementerBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new()
|
||||
{
|
||||
Id = model.Id,
|
||||
ImplementerFIO = model.ImplementerFIO,
|
||||
Password = model.Password,
|
||||
Qualification = model.Qualification,
|
||||
WorkExperience = model.WorkExperience,
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ImplementerBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ImplementerFIO = model.ImplementerFIO;
|
||||
Password = model.Password;
|
||||
Qualification = model.Qualification;
|
||||
WorkExperience = model.WorkExperience;
|
||||
}
|
||||
|
||||
public ImplementerViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ImplementerFIO = ImplementerFIO,
|
||||
Password = Password,
|
||||
Qualification = Qualification,
|
||||
};
|
||||
|
||||
public XElement GetXElement => new("Client",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("FIO", ImplementerFIO),
|
||||
new XElement("Password", Password),
|
||||
new XElement("Qualification", Qualification),
|
||||
new XElement("WorkExperience", WorkExperience)
|
||||
);
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ namespace AutomobilePlantFileImplement.Models
|
||||
public int Id { get; private set; }
|
||||
public int CarId { get; private set; }
|
||||
public int ClientId { get; set; }
|
||||
public int? ImplementerId { get; set; }
|
||||
public int Count { get; private set; }
|
||||
public double Sum { get; private set; }
|
||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
||||
@ -33,6 +34,7 @@ namespace AutomobilePlantFileImplement.Models
|
||||
Id = model.Id,
|
||||
CarId = model.CarId,
|
||||
ClientId = model.ClientId,
|
||||
ImplementerId = model.ImplementerId,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
@ -52,6 +54,7 @@ namespace AutomobilePlantFileImplement.Models
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
CarId = Convert.ToInt32(element.Element("CarId")!.Value),
|
||||
ClientId = Convert.ToInt32(element.Element("ClientId")!.Value),
|
||||
ImplementerId = Convert.ToInt32(element.Element("ImplementerId")!.Value),
|
||||
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
||||
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
||||
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
|
||||
@ -68,6 +71,7 @@ namespace AutomobilePlantFileImplement.Models
|
||||
}
|
||||
Status = model.Status;
|
||||
DateImplement = model.DateImplement;
|
||||
ImplementerId = model.ImplementerId;
|
||||
}
|
||||
|
||||
public OrderViewModel GetViewModel => new()
|
||||
@ -75,6 +79,8 @@ namespace AutomobilePlantFileImplement.Models
|
||||
Id = Id,
|
||||
CarId = CarId,
|
||||
ClientId = ClientId,
|
||||
ImplementerId = ImplementerId,
|
||||
ImplementerFIO = DataFileSingleton.GetInstance().Implementers.FirstOrDefault(x => x.Id == ImplementerId)?.ImplementerFIO ?? string.Empty,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
DateCreate = DateCreate,
|
||||
@ -87,6 +93,7 @@ namespace AutomobilePlantFileImplement.Models
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("CarId", CarId.ToString()),
|
||||
new XElement("ClientId", ClientId),
|
||||
new XElement("ImplementerId", ImplementerId),
|
||||
new XElement("Count", Count.ToString()),
|
||||
new XElement("Sum", Sum.ToString()),
|
||||
new XElement("Status", Status.ToString()),
|
||||
|
@ -15,6 +15,7 @@ namespace AutomobilePlantListImplement
|
||||
public List<Car> Cars { get; set; }
|
||||
public List<Shop> Shops { get; set; }
|
||||
public List<Client> Clients { get; set; }
|
||||
public List<Implementer> Implementers { get; set; }
|
||||
private DataListSingleton()
|
||||
{
|
||||
Components = new List<Component>();
|
||||
@ -22,6 +23,7 @@ namespace AutomobilePlantListImplement
|
||||
Cars = new List<Car>();
|
||||
Shops = new List<Shop>();
|
||||
Clients = new List<Client>();
|
||||
Implementers = new List<Implementer>();
|
||||
}
|
||||
public static DataListSingleton GetInstance()
|
||||
{
|
||||
|
@ -0,0 +1,106 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.SearchModels;
|
||||
using AutomobilePlantContracts.StoragesContracts;
|
||||
using AutomobilePlantContracts.ViewModels;
|
||||
using AutomobilePlantListImplement.Models;
|
||||
|
||||
namespace AutomobilePlantListImplement.Implements
|
||||
{
|
||||
public class ImplementerStorage : IImplementerStorage
|
||||
{
|
||||
private readonly DataListSingleton _source;
|
||||
public ImplementerStorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
||||
{
|
||||
foreach (var x in _source.Implementers)
|
||||
{
|
||||
if (model.Id.HasValue && x.Id == model.Id)
|
||||
return x.GetViewModel;
|
||||
if (model.ImplementerFIO != null && model.Password != null &&
|
||||
x.ImplementerFIO.Equals(model.ImplementerFIO) && x.Password.Equals(model.Password))
|
||||
return x.GetViewModel;
|
||||
if (model.ImplementerFIO != null && x.ImplementerFIO.Equals(model.ImplementerFIO))
|
||||
return x.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
List<ImplementerViewModel> list = new();
|
||||
if (model.ImplementerFIO != null)
|
||||
{
|
||||
foreach (var implementer in _source.Implementers)
|
||||
{
|
||||
if (implementer.ImplementerFIO.Contains(model.ImplementerFIO))
|
||||
{
|
||||
list.Add(implementer.GetViewModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<ImplementerViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<ImplementerViewModel>();
|
||||
foreach (var implementer in _source.Implementers)
|
||||
{
|
||||
result.Add(implementer.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
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 res = Implementer.Create(model);
|
||||
if (res != null)
|
||||
{
|
||||
_source.Implementers.Add(res);
|
||||
}
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
|
||||
public ImplementerViewModel? Update(ImplementerBindingModel model)
|
||||
{
|
||||
foreach (var implementer in _source.Implementers)
|
||||
{
|
||||
if (implementer.Id == model.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;
|
||||
}
|
||||
}
|
||||
}
|
@ -49,6 +49,26 @@ namespace AutomobilePlantListImplement.Implements
|
||||
}
|
||||
}
|
||||
}
|
||||
if (model.ImplementerId.HasValue)
|
||||
{
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if (order.ImplementerId == model.ImplementerId)
|
||||
{
|
||||
result.Add(GetViewModel(order));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (model.Status != null)
|
||||
{
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if (model.Status.Equals(order.Status))
|
||||
{
|
||||
result.Add(GetViewModel(order));
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
@ -59,9 +79,15 @@ namespace AutomobilePlantListImplement.Implements
|
||||
}
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if (
|
||||
(model.Id.HasValue && order.Id == model.Id)
|
||||
)
|
||||
if (model.Id.HasValue && order.Id == model.Id)
|
||||
{
|
||||
return GetViewModel(order);
|
||||
}
|
||||
else if (model.ImplementerId.HasValue && model.Status != null && order.ImplementerId == model.ImplementerId && model.Status.Equals(order.Status))
|
||||
{
|
||||
return GetViewModel(order);
|
||||
}
|
||||
else if (model.ImplementerId.HasValue && model.ImplementerId == order.ImplementerId)
|
||||
{
|
||||
return order.GetViewModel;
|
||||
}
|
||||
|
@ -0,0 +1,55 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.ViewModels;
|
||||
using AutomobilePlantDataModels.Models;
|
||||
|
||||
namespace AutomobilePlantListImplement.Models
|
||||
{
|
||||
public class Implementer : IImplementerModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||
|
||||
public string Password { get; private set; } = string.Empty;
|
||||
|
||||
public int WorkExperience { get; private set; }
|
||||
|
||||
public int Qualification { get; private set; }
|
||||
|
||||
public 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,
|
||||
};
|
||||
}
|
||||
}
|
@ -14,6 +14,7 @@ namespace AutomobilePlantListImplement.Models
|
||||
{
|
||||
public int CarId { get; private set; }
|
||||
public int ClientId { get; private set; }
|
||||
public int? ImplementerId { get; private set; }
|
||||
|
||||
public int Count { get; private set; }
|
||||
|
||||
@ -38,6 +39,7 @@ namespace AutomobilePlantListImplement.Models
|
||||
Id = model.Id,
|
||||
CarId = model.CarId,
|
||||
ClientId = model.ClientId,
|
||||
ImplementerId = model.ImplementerId,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
@ -54,12 +56,15 @@ namespace AutomobilePlantListImplement.Models
|
||||
}
|
||||
Status = model.Status;
|
||||
DateImplement = model.DateImplement;
|
||||
ImplementerId = model.ImplementerId;
|
||||
}
|
||||
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
CarId = CarId,
|
||||
ClientId = ClientId,
|
||||
ImplementerId = ImplementerId,
|
||||
ImplementerFIO = DataListSingleton.GetInstance().Implementers.FirstOrDefault(x => x.Id == ImplementerId)?.ImplementerFIO ?? string.Empty,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
DateCreate = DateCreate,
|
||||
|
@ -0,0 +1,106 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
||||
using AutomobilePlantContracts.SearchModels;
|
||||
using AutomobilePlantContracts.ViewModels;
|
||||
using AutomobilePlantDataModels.Enums;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace AutomobilePlantRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class ImplementerController : Controller
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -13,10 +13,12 @@ builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
||||
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
builder.Services.AddTransient<ICarStorage, CarStorage>();
|
||||
builder.Services.AddTransient<IShopStorage, ShopStorage>();
|
||||
builder.Services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
||||
builder.Services.AddTransient<ICarLogic, CarLogic>();
|
||||
builder.Services.AddTransient<IShopLogic, ShopLogic>();
|
||||
builder.Services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
|
169
AutomobilePlant/AutomobilePlantView/FormImplementer.Designer.cs
generated
Normal file
169
AutomobilePlant/AutomobilePlantView/FormImplementer.Designer.cs
generated
Normal file
@ -0,0 +1,169 @@
|
||||
namespace AutomobilePlantView
|
||||
{
|
||||
partial class FormImplementer
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
textBoxFIO = new TextBox();
|
||||
labelFIO = new Label();
|
||||
textBoxPassword = new TextBox();
|
||||
numericUpDownQualification = new NumericUpDown();
|
||||
numericUpDownWorkExpirience = new NumericUpDown();
|
||||
labelPassword = new Label();
|
||||
labelQualification = new Label();
|
||||
labelExpirience = new Label();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownQualification).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWorkExpirience).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(343, 125);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(75, 23);
|
||||
buttonCancel.TabIndex = 11;
|
||||
buttonCancel.Text = "Cancel";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(262, 125);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(75, 23);
|
||||
buttonSave.TabIndex = 10;
|
||||
buttonSave.Text = "Save";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// textBoxFIO
|
||||
//
|
||||
textBoxFIO.Location = new Point(96, 9);
|
||||
textBoxFIO.Name = "textBoxFIO";
|
||||
textBoxFIO.Size = new Size(322, 23);
|
||||
textBoxFIO.TabIndex = 8;
|
||||
//
|
||||
// labelFIO
|
||||
//
|
||||
labelFIO.AutoSize = true;
|
||||
labelFIO.Location = new Point(12, 12);
|
||||
labelFIO.Name = "labelFIO";
|
||||
labelFIO.Size = new Size(42, 15);
|
||||
labelFIO.TabIndex = 6;
|
||||
labelFIO.Text = "Name:";
|
||||
//
|
||||
// textBoxPassword
|
||||
//
|
||||
textBoxPassword.Location = new Point(96, 38);
|
||||
textBoxPassword.Name = "textBoxPassword";
|
||||
textBoxPassword.Size = new Size(322, 23);
|
||||
textBoxPassword.TabIndex = 12;
|
||||
//
|
||||
// numericUpDownQualification
|
||||
//
|
||||
numericUpDownQualification.Location = new Point(96, 67);
|
||||
numericUpDownQualification.Name = "numericUpDownQualification";
|
||||
numericUpDownQualification.Size = new Size(322, 23);
|
||||
numericUpDownQualification.TabIndex = 13;
|
||||
//
|
||||
// numericUpDownWorkExpirience
|
||||
//
|
||||
numericUpDownWorkExpirience.Location = new Point(96, 96);
|
||||
numericUpDownWorkExpirience.Name = "numericUpDownWorkExpirience";
|
||||
numericUpDownWorkExpirience.Size = new Size(322, 23);
|
||||
numericUpDownWorkExpirience.TabIndex = 14;
|
||||
//
|
||||
// labelPassword
|
||||
//
|
||||
labelPassword.AutoSize = true;
|
||||
labelPassword.Location = new Point(12, 41);
|
||||
labelPassword.Name = "labelPassword";
|
||||
labelPassword.Size = new Size(60, 15);
|
||||
labelPassword.TabIndex = 15;
|
||||
labelPassword.Text = "Password:";
|
||||
//
|
||||
// labelQualification
|
||||
//
|
||||
labelQualification.AutoSize = true;
|
||||
labelQualification.Location = new Point(12, 69);
|
||||
labelQualification.Name = "labelQualification";
|
||||
labelQualification.Size = new Size(78, 15);
|
||||
labelQualification.TabIndex = 16;
|
||||
labelQualification.Text = "Qualification:";
|
||||
labelQualification.TextAlign = ContentAlignment.TopRight;
|
||||
//
|
||||
// labelExpirience
|
||||
//
|
||||
labelExpirience.AutoSize = true;
|
||||
labelExpirience.Location = new Point(12, 98);
|
||||
labelExpirience.Name = "labelExpirience";
|
||||
labelExpirience.Size = new Size(64, 15);
|
||||
labelExpirience.TabIndex = 17;
|
||||
labelExpirience.Text = "Expirience:";
|
||||
//
|
||||
// FormImplementer
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(425, 156);
|
||||
Controls.Add(labelExpirience);
|
||||
Controls.Add(labelQualification);
|
||||
Controls.Add(labelPassword);
|
||||
Controls.Add(numericUpDownWorkExpirience);
|
||||
Controls.Add(numericUpDownQualification);
|
||||
Controls.Add(textBoxPassword);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(textBoxFIO);
|
||||
Controls.Add(labelFIO);
|
||||
Name = "FormImplementer";
|
||||
Text = "Implementer";
|
||||
Load += FormImplementer_Load;
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownQualification).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWorkExpirience).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
private TextBox textBoxCost;
|
||||
private TextBox textBoxFIO;
|
||||
private Label labelCost;
|
||||
private Label labelFIO;
|
||||
private TextBox textBoxPassword;
|
||||
private NumericUpDown numericUpDownQualification;
|
||||
private NumericUpDown numericUpDownWorkExpirience;
|
||||
private Label labelPassword;
|
||||
private Label labelQualification;
|
||||
private Label labelExpirience;
|
||||
}
|
||||
}
|
101
AutomobilePlant/AutomobilePlantView/FormImplementer.cs
Normal file
101
AutomobilePlant/AutomobilePlantView/FormImplementer.cs
Normal file
@ -0,0 +1,101 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
||||
using AutomobilePlantContracts.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 AutomobilePlantView
|
||||
{
|
||||
public partial class FormImplementer : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IImplementerLogic _logic;
|
||||
private int? _id;
|
||||
public int Id { set { _id = value; } }
|
||||
public FormImplementer(ILogger<FormImplementer> logger, IImplementerLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
private void FormImplementer_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Получение информации исполнителя");
|
||||
var view = _logic.ReadElement(new ImplementerSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
});
|
||||
if (view != null)
|
||||
{
|
||||
textBoxFIO.Text = view.ImplementerFIO;
|
||||
textBoxPassword.Text = view.Password;
|
||||
numericUpDownQualification.Value = view.Qualification;
|
||||
numericUpDownWorkExpirience.Value = view.WorkExperience;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения исполнителя");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxPassword.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните пароль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxFIO.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните ФИО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Сохранение исполнителя");
|
||||
try
|
||||
{
|
||||
var model = new ImplementerBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
ImplementerFIO = textBoxFIO.Text,
|
||||
Password = textBoxPassword.Text,
|
||||
Qualification = (int)numericUpDownQualification.Value,
|
||||
WorkExperience = (int)numericUpDownWorkExpirience.Value,
|
||||
};
|
||||
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 buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
AutomobilePlant/AutomobilePlantView/FormImplementer.resx
Normal file
120
AutomobilePlant/AutomobilePlantView/FormImplementer.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>
|
113
AutomobilePlant/AutomobilePlantView/FormImplementers.Designer.cs
generated
Normal file
113
AutomobilePlant/AutomobilePlantView/FormImplementers.Designer.cs
generated
Normal file
@ -0,0 +1,113 @@
|
||||
namespace AutomobilePlantView
|
||||
{
|
||||
partial class FormImplementers
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
buttonRefresh = new Button();
|
||||
buttonDelete = new Button();
|
||||
buttonUpdate = new Button();
|
||||
buttonAdd = new Button();
|
||||
dataGridView = new DataGridView();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonRefresh
|
||||
//
|
||||
buttonRefresh.Location = new Point(678, 105);
|
||||
buttonRefresh.Name = "buttonRefresh";
|
||||
buttonRefresh.Size = new Size(116, 23);
|
||||
buttonRefresh.TabIndex = 9;
|
||||
buttonRefresh.Text = "Refresh";
|
||||
buttonRefresh.UseVisualStyleBackColor = true;
|
||||
buttonRefresh.Click += buttonRefresh_Click;
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
buttonDelete.Location = new Point(678, 76);
|
||||
buttonDelete.Name = "buttonDelete";
|
||||
buttonDelete.Size = new Size(116, 23);
|
||||
buttonDelete.TabIndex = 8;
|
||||
buttonDelete.Text = "Delete";
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += buttonDelete_Click;
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
buttonUpdate.Location = new Point(678, 47);
|
||||
buttonUpdate.Name = "buttonUpdate";
|
||||
buttonUpdate.Size = new Size(116, 23);
|
||||
buttonUpdate.TabIndex = 7;
|
||||
buttonUpdate.Text = "Update";
|
||||
buttonUpdate.UseVisualStyleBackColor = true;
|
||||
buttonUpdate.Click += buttonUpdate_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(678, 18);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(116, 23);
|
||||
buttonAdd.TabIndex = 6;
|
||||
buttonAdd.Text = "Add";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonCreate_Click;
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(6, 6);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowTemplate.Height = 25;
|
||||
dataGridView.Size = new Size(666, 438);
|
||||
dataGridView.TabIndex = 5;
|
||||
//
|
||||
// FormImplementers
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(buttonRefresh);
|
||||
Controls.Add(buttonDelete);
|
||||
Controls.Add(buttonUpdate);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormImplementers";
|
||||
Text = "Implementers";
|
||||
Load += FormImplementers_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonRefresh;
|
||||
private Button buttonDelete;
|
||||
private Button buttonUpdate;
|
||||
private Button buttonAdd;
|
||||
private DataGridView dataGridView;
|
||||
}
|
||||
}
|
114
AutomobilePlant/AutomobilePlantView/FormImplementers.cs
Normal file
114
AutomobilePlant/AutomobilePlantView/FormImplementers.cs
Normal file
@ -0,0 +1,114 @@
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.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 AutomobilePlantView
|
||||
{
|
||||
public partial class FormImplementers : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IImplementerLogic _logic;
|
||||
public FormImplementers(ILogger<FormImplementers> logger, IImplementerLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormImplementers_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка исполнителей");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки исполнителей");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
||||
if (service is FormImplementer form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
||||
if (service is FormImplementer form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id =
|
||||
Convert.ToInt32(dataGridView.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 buttonRefresh_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
120
AutomobilePlant/AutomobilePlantView/FormImplementers.resx
Normal file
120
AutomobilePlant/AutomobilePlantView/FormImplementers.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>
|
@ -35,27 +35,28 @@
|
||||
shopsToolStripMenuItem = new ToolStripMenuItem();
|
||||
shopsSupplyToolStripMenuItem = new ToolStripMenuItem();
|
||||
sellCarsToolStripMenuItem = new ToolStripMenuItem();
|
||||
clientsToolStripMenuItem = new ToolStripMenuItem();
|
||||
implementersToolStripMenuItem = new ToolStripMenuItem();
|
||||
reportsToolStripMenuItem = new ToolStripMenuItem();
|
||||
carsListToolStripMenuItem = new ToolStripMenuItem();
|
||||
componentsByCarsToolStripMenuItem = new ToolStripMenuItem();
|
||||
ordersListToolStripMenuItem = new ToolStripMenuItem();
|
||||
dataGridView = new DataGridView();
|
||||
buttonCreateOrder = new Button();
|
||||
buttonTakeOrderInWork = new Button();
|
||||
buttonOrderReady = new Button();
|
||||
buttonIssuedOrder = new Button();
|
||||
buttonRefresh = new Button();
|
||||
shopsListToolStripMenuItem = new ToolStripMenuItem();
|
||||
storeCongestionToolStripMenuItem = new ToolStripMenuItem();
|
||||
listOdOrdersByDatesToolStripMenuItem = new ToolStripMenuItem();
|
||||
clientsToolStripMenuItem = new ToolStripMenuItem();
|
||||
startWorkingsToolStripMenuItem = new ToolStripMenuItem();
|
||||
menuStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { toolStripMenuItemCatalogs, reportsToolStripMenuItem });
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { toolStripMenuItemCatalogs, reportsToolStripMenuItem, startWorkingsToolStripMenuItem });
|
||||
menuStrip1.Location = new Point(0, 0);
|
||||
menuStrip1.Name = "menuStrip1";
|
||||
menuStrip1.Size = new Size(800, 24);
|
||||
@ -64,7 +65,7 @@
|
||||
//
|
||||
// toolStripMenuItemCatalogs
|
||||
//
|
||||
toolStripMenuItemCatalogs.DropDownItems.AddRange(new ToolStripItem[] { toolStripMenuItemComponents, toolStripMenuItemCars, shopsToolStripMenuItem, clientsToolStripMenuItem, shopsSupplyToolStripMenuItem, sellCarsToolStripMenuItem });
|
||||
toolStripMenuItemCatalogs.DropDownItems.AddRange(new ToolStripItem[] { toolStripMenuItemComponents, toolStripMenuItemCars, clientsToolStripMenuItem, shopsToolStripMenuItem, shopsSupplyToolStripMenuItem, sellCarsToolStripMenuItem, implementersToolStripMenuItem });
|
||||
toolStripMenuItemCatalogs.Name = "toolStripMenuItemCatalogs";
|
||||
toolStripMenuItemCatalogs.Size = new Size(65, 20);
|
||||
toolStripMenuItemCatalogs.Text = "Catalogs";
|
||||
@ -105,6 +106,20 @@
|
||||
sellCarsToolStripMenuItem.Text = "Sell Cars";
|
||||
sellCarsToolStripMenuItem.Click += sellCarsToolStripMenuItem_Click;
|
||||
//
|
||||
// clientsToolStripMenuItem
|
||||
//
|
||||
clientsToolStripMenuItem.Name = "clientsToolStripMenuItem";
|
||||
clientsToolStripMenuItem.Size = new Size(180, 22);
|
||||
clientsToolStripMenuItem.Text = "Clients";
|
||||
clientsToolStripMenuItem.Click += clientsToolStripMenuItem_Click;
|
||||
//
|
||||
// implementersToolStripMenuItem
|
||||
//
|
||||
implementersToolStripMenuItem.Name = "implementersToolStripMenuItem";
|
||||
implementersToolStripMenuItem.Size = new Size(180, 22);
|
||||
implementersToolStripMenuItem.Text = "Implementers";
|
||||
implementersToolStripMenuItem.Click += implementersToolStripMenuItem_Click;
|
||||
//
|
||||
// reportsToolStripMenuItem
|
||||
//
|
||||
reportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { carsListToolStripMenuItem, componentsByCarsToolStripMenuItem, ordersListToolStripMenuItem, shopsListToolStripMenuItem, storeCongestionToolStripMenuItem, listOdOrdersByDatesToolStripMenuItem });
|
||||
@ -152,29 +167,9 @@
|
||||
buttonCreateOrder.UseVisualStyleBackColor = true;
|
||||
buttonCreateOrder.Click += ButtonCreateOrder_Click;
|
||||
//
|
||||
// buttonTakeOrderInWork
|
||||
//
|
||||
buttonTakeOrderInWork.Location = new Point(677, 56);
|
||||
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
|
||||
buttonTakeOrderInWork.Size = new Size(111, 23);
|
||||
buttonTakeOrderInWork.TabIndex = 3;
|
||||
buttonTakeOrderInWork.Text = "Take order in work";
|
||||
buttonTakeOrderInWork.UseVisualStyleBackColor = true;
|
||||
buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click;
|
||||
//
|
||||
// buttonOrderReady
|
||||
//
|
||||
buttonOrderReady.Location = new Point(677, 85);
|
||||
buttonOrderReady.Name = "buttonOrderReady";
|
||||
buttonOrderReady.Size = new Size(111, 23);
|
||||
buttonOrderReady.TabIndex = 4;
|
||||
buttonOrderReady.Text = "Order is ready";
|
||||
buttonOrderReady.UseVisualStyleBackColor = true;
|
||||
buttonOrderReady.Click += ButtonOrderReady_Click;
|
||||
//
|
||||
// buttonIssuedOrder
|
||||
//
|
||||
buttonIssuedOrder.Location = new Point(677, 114);
|
||||
buttonIssuedOrder.Location = new Point(677, 56);
|
||||
buttonIssuedOrder.Name = "buttonIssuedOrder";
|
||||
buttonIssuedOrder.Size = new Size(111, 23);
|
||||
buttonIssuedOrder.TabIndex = 5;
|
||||
@ -184,7 +179,7 @@
|
||||
//
|
||||
// buttonRefresh
|
||||
//
|
||||
buttonRefresh.Location = new Point(677, 143);
|
||||
buttonRefresh.Location = new Point(677, 85);
|
||||
buttonRefresh.Name = "buttonRefresh";
|
||||
buttonRefresh.Size = new Size(111, 23);
|
||||
buttonRefresh.TabIndex = 6;
|
||||
@ -214,11 +209,12 @@
|
||||
listOdOrdersByDatesToolStripMenuItem.Click += listOdOrdersByDatesToolStripMenuItem_Click;
|
||||
//
|
||||
// clientsToolStripMenuItem
|
||||
// startWorkingsToolStripMenuItem
|
||||
//
|
||||
clientsToolStripMenuItem.Name = "clientsToolStripMenuItem";
|
||||
clientsToolStripMenuItem.Size = new Size(180, 22);
|
||||
clientsToolStripMenuItem.Text = "Clients";
|
||||
clientsToolStripMenuItem.Click += clientsToolStripMenuItem_Click;
|
||||
startWorkingsToolStripMenuItem.Name = "startWorkingsToolStripMenuItem";
|
||||
startWorkingsToolStripMenuItem.Size = new Size(94, 20);
|
||||
startWorkingsToolStripMenuItem.Text = "Start workings";
|
||||
startWorkingsToolStripMenuItem.Click += startWorkingsToolStripMenuItem_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
@ -227,8 +223,6 @@
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(buttonRefresh);
|
||||
Controls.Add(buttonIssuedOrder);
|
||||
Controls.Add(buttonOrderReady);
|
||||
Controls.Add(buttonTakeOrderInWork);
|
||||
Controls.Add(buttonCreateOrder);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(menuStrip1);
|
||||
@ -250,8 +244,6 @@
|
||||
private ToolStripMenuItem toolStripMenuItemCars;
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonCreateOrder;
|
||||
private Button buttonTakeOrderInWork;
|
||||
private Button buttonOrderReady;
|
||||
private Button buttonIssuedOrder;
|
||||
private Button buttonRefresh;
|
||||
private ToolStripMenuItem reportsToolStripMenuItem;
|
||||
@ -265,5 +257,7 @@
|
||||
private ToolStripMenuItem storeCongestionToolStripMenuItem;
|
||||
private ToolStripMenuItem listOdOrdersByDatesToolStripMenuItem;
|
||||
private ToolStripMenuItem clientsToolStripMenuItem;
|
||||
private ToolStripMenuItem implementersToolStripMenuItem;
|
||||
private ToolStripMenuItem startWorkingsToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -1,17 +1,7 @@
|
||||
using AutomobilePlantBusinessLogic.BusinessLogics;
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.BindingModels;
|
||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
||||
using AutomobilePlantDataModels.Enums;
|
||||
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 AutomobilePlantView
|
||||
{
|
||||
@ -20,12 +10,14 @@ namespace AutomobilePlantView
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderLogic _orderLogic;
|
||||
private readonly IReportLogic _reportLogic;
|
||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic)
|
||||
private readonly IWorkProcess _workProcess;
|
||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_orderLogic = orderLogic;
|
||||
_reportLogic = reportLogic;
|
||||
_workProcess = workProcess;
|
||||
}
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
@ -42,6 +34,7 @@ namespace AutomobilePlantView
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["CarId"].Visible = false;
|
||||
dataGridView.Columns["ClientId"].Visible = false;
|
||||
dataGridView.Columns["ImplementerId"].Visible = false;
|
||||
|
||||
}
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
@ -96,6 +89,15 @@ namespace AutomobilePlantView
|
||||
}
|
||||
}
|
||||
|
||||
private void implementersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementers));
|
||||
if (service is FormImplementers form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void carsListToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
||||
@ -158,6 +160,12 @@ namespace AutomobilePlantView
|
||||
}
|
||||
}
|
||||
|
||||
private void startWorkingsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
_workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic);
|
||||
MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
|
||||
private void listOdOrdersByDatesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportDateOrders));
|
||||
|
@ -39,16 +39,19 @@ namespace AutomobilePlantView
|
||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
services.AddTransient<ICarStorage, CarStorage>();
|
||||
services.AddTransient<IClientStorage, ClientStorage>();
|
||||
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
services.AddTransient<ICarLogic, CarLogic>();
|
||||
services.AddTransient<IReportLogic, ReportLogic>();
|
||||
services.AddTransient<IClientLogic, ClientLogic>();
|
||||
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||
services.AddTransient<IShopStorage, ShopStorage>();
|
||||
services.AddTransient<IShopLogic, ShopLogic>();
|
||||
services.AddTransient<IWorkProcess, WorkModeling>();
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormComponent>();
|
||||
services.AddTransient<FormComponents>();
|
||||
@ -65,6 +68,8 @@ namespace AutomobilePlantView
|
||||
services.AddTransient<FormShopSupply>();
|
||||
services.AddTransient<FormShopSell>();
|
||||
services.AddTransient<FormClients>();
|
||||
services.AddTransient<FormImplementers>();
|
||||
services.AddTransient<FormImplementer>();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user