12
This commit is contained in:
parent
d2cc3ef5d5
commit
2cefd91025
@ -13,18 +13,18 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
||||
{
|
||||
public class AdLogic : IOrderLogic
|
||||
public class AdLogic : IAdLogic
|
||||
{
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
private readonly IAdStorage _orderStorage;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public AdLogic(ILogger<AdLogic> logger, IOrderStorage orderStorage)
|
||||
public AdLogic(ILogger<AdLogic> logger, IAdStorage orderStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_orderStorage = orderStorage;
|
||||
}
|
||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||
public List<AdViewModel>? ReadList(AdSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id:{Id}", model?.Id);
|
||||
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
||||
@ -40,21 +40,21 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
||||
|
||||
return list;
|
||||
}
|
||||
public bool CreateOrder(OrderBindingModel model)
|
||||
public bool CreateOrder(AdBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if(model.Status != OrderStatus.Неизвестен)
|
||||
if(model.Status != AdStatus.Неизвестен)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed, incorrect order status");
|
||||
return false;
|
||||
}
|
||||
|
||||
model.Status = OrderStatus.Принят;
|
||||
model.Status = AdStatus.Принят;
|
||||
|
||||
if(_orderStorage.Insert(model) == null)
|
||||
{
|
||||
model.Status = OrderStatus.Неизвестен;
|
||||
model.Status = AdStatus.Неизвестен;
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
@ -62,21 +62,21 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool TakeOrderInWork(OrderBindingModel model)
|
||||
public bool TakeOrderInWork(AdBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, OrderStatus.Выполняется);
|
||||
return StatusUpdate(model, AdStatus.Выполняется);
|
||||
}
|
||||
|
||||
public bool FinishOrder(OrderBindingModel model)
|
||||
public bool FinishOrder(AdBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, OrderStatus.Готов);
|
||||
return StatusUpdate(model, AdStatus.Готов);
|
||||
}
|
||||
|
||||
public bool DeliveryOrder(OrderBindingModel model)
|
||||
public bool DeliveryOrder(AdBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, OrderStatus.Выдан);
|
||||
return StatusUpdate(model, AdStatus.Выдан);
|
||||
}
|
||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
||||
private void CheckModel(AdBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -114,9 +114,9 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
||||
_logger.LogInformation("Order. OrderId:{Id}, Sum:{Sum}. FurnitureId:{Id}", model.Id, model.Sum, model.FurnitureId);
|
||||
}
|
||||
|
||||
public bool StatusUpdate(OrderBindingModel model, OrderStatus newOrderStatus)
|
||||
public bool StatusUpdate(AdBindingModel model, AdStatus newOrderStatus)
|
||||
{
|
||||
var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||
var viewModel = _orderStorage.GetElement(new AdSearchModel { Id = model.Id });
|
||||
|
||||
if(viewModel == null)
|
||||
{
|
||||
@ -131,7 +131,7 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
||||
|
||||
model.Status = newOrderStatus;
|
||||
|
||||
if(model.Status == OrderStatus.Выдан)
|
||||
if(model.Status == AdStatus.Выдан)
|
||||
{
|
||||
model.DateImplement = DateTime.Now;
|
||||
}
|
||||
|
@ -13,21 +13,21 @@ using System.Threading.Tasks;
|
||||
namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
||||
{
|
||||
// Класс, реализующий логику для заготовок
|
||||
public class WorkPieceLogic : IWorkPieceLogic
|
||||
public class KommentLogic : IKommentLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IWorkPieceStorage _workPieceStorage;
|
||||
private readonly IKommentStorage _workPieceStorage;
|
||||
|
||||
// Конструктор
|
||||
public WorkPieceLogic(ILogger<WorkPieceLogic> logger, IWorkPieceStorage workPieceStorage)
|
||||
public KommentLogic(ILogger<KommentLogic> logger, IKommentStorage workPieceStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_workPieceStorage = workPieceStorage;
|
||||
}
|
||||
|
||||
// Вывод отфильтрованного списка компонентов
|
||||
public List<WorkPieceViewModel>? ReadList(WorkPieceSearchModel? model)
|
||||
public List<KommentViewModel>? ReadList(KommentSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. WorkPieceName:{WorkPieceName}. Id:{Id}", model?.WorkPieceName, model?.Id);
|
||||
|
||||
@ -46,7 +46,7 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
||||
}
|
||||
|
||||
// Вывод конкретной заготовки
|
||||
public WorkPieceViewModel? ReadElement(WorkPieceSearchModel model)
|
||||
public KommentViewModel? ReadElement(KommentSearchModel model)
|
||||
{
|
||||
if(model == null)
|
||||
{
|
||||
@ -70,7 +70,7 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
||||
}
|
||||
|
||||
// Создание заготовки
|
||||
public bool Create(WorkPieceBindingModel model)
|
||||
public bool Create(KommentBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
@ -85,7 +85,7 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
||||
}
|
||||
|
||||
// Обновление заготовки
|
||||
public bool Update(WorkPieceBindingModel model)
|
||||
public bool Update(KommentBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
@ -100,7 +100,7 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
||||
}
|
||||
|
||||
// Удаление заготовки
|
||||
public bool Delete(WorkPieceBindingModel model)
|
||||
public bool Delete(KommentBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
|
||||
@ -117,7 +117,7 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
||||
}
|
||||
|
||||
// Проверка входного аргумента для методов Insert, Update и Delete
|
||||
private void CheckModel(WorkPieceBindingModel model, bool withParams = true)
|
||||
private void CheckModel(KommentBindingModel model, bool withParams = true)
|
||||
{
|
||||
if(model == null)
|
||||
{
|
||||
@ -146,7 +146,7 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
||||
model.WorkPieceName, model.Cost, model.Id);
|
||||
|
||||
// Проверка на наличие такой же заготовки в списке
|
||||
var element = _workPieceStorage.GetElement(new WorkPieceSearchModel
|
||||
var element = _workPieceStorage.GetElement(new KommentSearchModel
|
||||
{
|
||||
WorkPieceName = model.WorkPieceName,
|
||||
});
|
@ -13,23 +13,23 @@ using System.Threading.Tasks;
|
||||
namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
||||
{
|
||||
// Класс, реализующий логику для изделий
|
||||
public class FurnitureLogic : IFurnitureLogic
|
||||
public class UsersLogic : IUsersLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IFurnitureStorage _furnitureStorage;
|
||||
private readonly IUsersStorage _furnitureStorage;
|
||||
|
||||
// Конструктор
|
||||
public FurnitureLogic(ILogger<FurnitureLogic> logger, IFurnitureStorage furnitureStorage)
|
||||
public UsersLogic(ILogger<UsersLogic> logger, IUsersStorage furnitureStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_furnitureStorage = furnitureStorage;
|
||||
}
|
||||
|
||||
// Вывод отфильтрованного списка
|
||||
public List<FurnitureViewModel>? ReadList(FurnitureSearchModel? model)
|
||||
public List<FurnitureViewModel>? ReadList(UsersSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. FurnitureName: {FurnitureName}. Id:{Id}", model?.FurnitureName, model?.Id);
|
||||
_logger.LogInformation("ReadList. UsersName: {UsersName}. Id:{Id}", model?.UsersName, model?.Id);
|
||||
|
||||
// list хранит весь список в случае, если model пришло со значением null на вход метода
|
||||
var list = model == null ? _furnitureStorage.GetFullList() : _furnitureStorage.GetFilteredList(model);
|
||||
@ -47,14 +47,14 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
||||
}
|
||||
|
||||
// Вывод конкретного изделия
|
||||
public FurnitureViewModel? ReadElement(FurnitureSearchModel model)
|
||||
public FurnitureViewModel? ReadElement(UsersSearchModel model)
|
||||
{
|
||||
if(model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. FurnitureName: {FurnitureName}. Id:{Id}", model.FurnitureName, model.Id);
|
||||
_logger.LogInformation("ReadElement. UsersName: {UsersName}. Id:{Id}", model.UsersName, model.Id);
|
||||
|
||||
var element = _furnitureStorage.GetElement(model);
|
||||
|
||||
@ -71,7 +71,7 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
||||
}
|
||||
|
||||
// Создание изделия
|
||||
public bool Create(FurnitureBindingModel model)
|
||||
public bool Create(UsersBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
@ -86,7 +86,7 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
||||
}
|
||||
|
||||
// Обновление изделия
|
||||
public bool Update(FurnitureBindingModel model)
|
||||
public bool Update(UsersBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
@ -100,7 +100,7 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
||||
}
|
||||
|
||||
// Удаление изделия
|
||||
public bool Delete(FurnitureBindingModel model)
|
||||
public bool Delete(UsersBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
|
||||
@ -117,7 +117,7 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
||||
}
|
||||
|
||||
// Проверка входного аргумента для методов Insert, Update и Delete
|
||||
private void CheckModel(FurnitureBindingModel model, bool withParams = true)
|
||||
private void CheckModel(UsersBindingModel model, bool withParams = true)
|
||||
{
|
||||
if(model == null)
|
||||
{
|
||||
@ -131,9 +131,9 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
||||
}
|
||||
|
||||
// Проверка на наличие названия изделия
|
||||
if(string.IsNullOrEmpty(model.FurnitureName))
|
||||
if(string.IsNullOrEmpty(model.UsersName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия изделия", nameof(model.FurnitureName));
|
||||
throw new ArgumentNullException("Нет названия изделия", nameof(model.UsersName));
|
||||
}
|
||||
|
||||
// Проверка на наличие нормальной цены у изделия
|
||||
@ -142,13 +142,13 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
||||
throw new ArgumentNullException("Цена изделия должна быть больше 0", nameof(model.Price));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Furniture. FurnitureName:{FurnitureName}. Price:{Price}. Id:{Id}",
|
||||
model.FurnitureName, model.Price, model.Id);
|
||||
_logger.LogInformation("Furniture. UsersName:{UsersName}. Price:{Price}. Id:{Id}",
|
||||
model.UsersName, model.Price, model.Id);
|
||||
|
||||
// Проверка на наличие такого же изделия в списке
|
||||
var element = _furnitureStorage.GetElement(new FurnitureSearchModel
|
||||
var element = _furnitureStorage.GetElement(new UsersSearchModel
|
||||
{
|
||||
FurnitureName = model.FurnitureName,
|
||||
UsersName = model.UsersName,
|
||||
});
|
||||
|
||||
// Если элемент найден и его Id не совпадает с Id объекта, переданного на вход
|
@ -8,7 +8,7 @@ using System.Threading.Tasks;
|
||||
namespace FurnitureAssemblyContracts.BindingModels
|
||||
{
|
||||
// Реализация сущности "Заказ"
|
||||
public class OrderBindingModel
|
||||
public class AdBindingModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
@ -18,7 +18,7 @@ namespace FurnitureAssemblyContracts.BindingModels
|
||||
|
||||
public double Sum { get; set; }
|
||||
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
public AdStatus Status { get; set; } = AdStatus.Неизвестен;
|
||||
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
namespace FurnitureAssemblyContracts.BindingModels
|
||||
{
|
||||
// Реализация сущности "Компонент"
|
||||
public class WorkPieceBindingModel
|
||||
public class KommentBindingModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
@ -8,14 +8,14 @@ using System.Threading.Tasks;
|
||||
namespace FurnitureAssemblyContracts.BindingModels
|
||||
{
|
||||
// Реализация сущности "Изделие"
|
||||
public class FurnitureBindingModel : IFurnitureModel
|
||||
public class UsersBindingModel : IUsersModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string FurnitureName { get; set; } = string.Empty;
|
||||
public string UsersName { get; set; } = string.Empty;
|
||||
|
||||
public double Price { get; set; }
|
||||
|
||||
public Dictionary<int, (IWorkPieceModel, int)> FurnitureWorkPieces { get; set; } = new();
|
||||
public Dictionary<int, (IKommentModel, int)> FurnitureWorkPieces { get; set; } = new();
|
||||
}
|
||||
}
|
@ -10,16 +10,16 @@ using System.Threading.Tasks;
|
||||
namespace FurnitureAssemblyContracts.BusinessLogicsContracts
|
||||
{
|
||||
// Бизнес-логика заказов
|
||||
public interface IOrderLogic
|
||||
public interface IAdLogic
|
||||
{
|
||||
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
||||
List<AdViewModel>? ReadList(AdSearchModel? model);
|
||||
|
||||
bool CreateOrder(OrderBindingModel model);
|
||||
bool CreateOrder(AdBindingModel model);
|
||||
|
||||
bool TakeOrderInWork(OrderBindingModel model);
|
||||
bool TakeOrderInWork(AdBindingModel model);
|
||||
|
||||
bool FinishOrder(OrderBindingModel model);
|
||||
bool FinishOrder(AdBindingModel model);
|
||||
|
||||
bool DeliveryOrder(OrderBindingModel model);
|
||||
bool DeliveryOrder(AdBindingModel model);
|
||||
}
|
||||
}
|
@ -10,16 +10,16 @@ using System.Threading.Tasks;
|
||||
namespace FurnitureAssemblyContracts.BusinessLogicsContracts
|
||||
{
|
||||
// Бизнес-логика для компонентов
|
||||
public interface IWorkPieceLogic
|
||||
public interface IKommentLogic
|
||||
{
|
||||
List<WorkPieceViewModel>? ReadList(WorkPieceSearchModel? model);
|
||||
List<KommentViewModel>? ReadList(KommentSearchModel? model);
|
||||
|
||||
WorkPieceViewModel? ReadElement(WorkPieceSearchModel model);
|
||||
KommentViewModel? ReadElement(KommentSearchModel model);
|
||||
|
||||
bool Create(WorkPieceBindingModel model);
|
||||
bool Create(KommentBindingModel model);
|
||||
|
||||
bool Update(WorkPieceBindingModel model);
|
||||
bool Update(KommentBindingModel model);
|
||||
|
||||
bool Delete(WorkPieceBindingModel model);
|
||||
bool Delete(KommentBindingModel model);
|
||||
}
|
||||
}
|
@ -10,16 +10,16 @@ using System.Threading.Tasks;
|
||||
namespace FurnitureAssemblyContracts.BusinessLogicsContracts
|
||||
{
|
||||
// Бизнес-логика для продуктов
|
||||
public interface IFurnitureLogic
|
||||
public interface IUsersLogic
|
||||
{
|
||||
List<FurnitureViewModel>? ReadList(FurnitureSearchModel? model);
|
||||
List<FurnitureViewModel>? ReadList(UsersSearchModel? model);
|
||||
|
||||
FurnitureViewModel? ReadElement(FurnitureSearchModel model);
|
||||
FurnitureViewModel? ReadElement(UsersSearchModel model);
|
||||
|
||||
bool Create(FurnitureBindingModel model);
|
||||
bool Create(UsersBindingModel model);
|
||||
|
||||
bool Update(FurnitureBindingModel model);
|
||||
bool Update(UsersBindingModel model);
|
||||
|
||||
bool Delete(FurnitureBindingModel model);
|
||||
bool Delete(UsersBindingModel model);
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
namespace FurnitureAssemblyContracts.SearchModels
|
||||
{
|
||||
// Для поиска сущности "Заказ"
|
||||
public class OrderSearchModel
|
||||
public class AdSearchModel
|
||||
{
|
||||
// для поиска по идентификатору
|
||||
public int? Id { get; set; }
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
namespace FurnitureAssemblyContracts.SearchModels
|
||||
{
|
||||
// Модель для поиска сущности "Компонент" (она же заготовка)
|
||||
public class WorkPieceSearchModel
|
||||
public class KommentSearchModel
|
||||
{
|
||||
//для поиска по идентификатору
|
||||
public int? Id { get; set; }
|
@ -7,12 +7,12 @@ using System.Threading.Tasks;
|
||||
namespace FurnitureAssemblyContracts.SearchModels
|
||||
{
|
||||
// Модель для поиска заготовки "Продукт" (она же изделие)
|
||||
public class FurnitureSearchModel
|
||||
public class UsersSearchModel
|
||||
{
|
||||
// для поиска по идентификатору
|
||||
public int? Id { get; set; }
|
||||
|
||||
// для поиска по названию
|
||||
public string? FurnitureName { get; set; }
|
||||
public string? UsersName { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.StoragesContracts
|
||||
{
|
||||
public interface IAdStorage
|
||||
{
|
||||
List<AdViewModel> GetFullList();
|
||||
|
||||
List<AdViewModel> GetFilteredList(AdSearchModel model);
|
||||
|
||||
AdViewModel? GetElement(AdSearchModel model);
|
||||
|
||||
AdViewModel? Insert(AdBindingModel model);
|
||||
|
||||
AdViewModel? Update(AdBindingModel model);
|
||||
|
||||
AdViewModel? Delete(AdBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.StoragesContracts
|
||||
{
|
||||
// Класс хранилища компонентов (заготовок)
|
||||
public interface IKommentStorage
|
||||
{
|
||||
List<KommentViewModel> GetFullList();
|
||||
|
||||
List<KommentViewModel> GetFilteredList(KommentSearchModel model);
|
||||
|
||||
KommentViewModel? GetElement(KommentSearchModel model);
|
||||
|
||||
KommentViewModel? Insert(KommentBindingModel model);
|
||||
|
||||
KommentViewModel? Update(KommentBindingModel model);
|
||||
|
||||
KommentViewModel? Delete(KommentBindingModel model);
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.StoragesContracts
|
||||
{
|
||||
public interface IOrderStorage
|
||||
{
|
||||
List<OrderViewModel> GetFullList();
|
||||
|
||||
List<OrderViewModel> GetFilteredList(OrderSearchModel model);
|
||||
|
||||
OrderViewModel? GetElement(OrderSearchModel model);
|
||||
|
||||
OrderViewModel? Insert(OrderBindingModel model);
|
||||
|
||||
OrderViewModel? Update(OrderBindingModel model);
|
||||
|
||||
OrderViewModel? Delete(OrderBindingModel model);
|
||||
}
|
||||
}
|
@ -10,18 +10,18 @@ using System.Threading.Tasks;
|
||||
namespace FurnitureAssemblyContracts.StoragesContracts
|
||||
{
|
||||
// Класс для хранилища продуктов (изделий)
|
||||
public interface IFurnitureStorage
|
||||
public interface IUsersStorage
|
||||
{
|
||||
List<FurnitureViewModel> GetFullList();
|
||||
|
||||
List<FurnitureViewModel> GetFilteredList(FurnitureSearchModel model);
|
||||
List<FurnitureViewModel> GetFilteredList(UsersSearchModel model);
|
||||
|
||||
FurnitureViewModel? GetElement(FurnitureSearchModel model);
|
||||
FurnitureViewModel? GetElement(UsersSearchModel model);
|
||||
|
||||
FurnitureViewModel? Insert(FurnitureBindingModel model);
|
||||
FurnitureViewModel? Insert(UsersBindingModel model);
|
||||
|
||||
FurnitureViewModel? Update(FurnitureBindingModel model);
|
||||
FurnitureViewModel? Update(UsersBindingModel model);
|
||||
|
||||
FurnitureViewModel? Delete(FurnitureBindingModel model);
|
||||
FurnitureViewModel? Delete(UsersBindingModel model);
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.StoragesContracts
|
||||
{
|
||||
// Класс хранилища компонентов (заготовок)
|
||||
public interface IWorkPieceStorage
|
||||
{
|
||||
List<WorkPieceViewModel> GetFullList();
|
||||
|
||||
List<WorkPieceViewModel> GetFilteredList(WorkPieceSearchModel model);
|
||||
|
||||
WorkPieceViewModel? GetElement(WorkPieceSearchModel model);
|
||||
|
||||
WorkPieceViewModel? Insert(WorkPieceBindingModel model);
|
||||
|
||||
WorkPieceViewModel? Update(WorkPieceBindingModel model);
|
||||
|
||||
WorkPieceViewModel? Delete(WorkPieceBindingModel model);
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@ using System.Threading.Tasks;
|
||||
namespace FurnitureAssemblyContracts.ViewModels
|
||||
{
|
||||
// Класс для отображения пользователю информации о заказах
|
||||
public class OrderViewModel : IOrderModel
|
||||
public class AdViewModel : IAdModel
|
||||
{
|
||||
[DisplayName("Номер")]
|
||||
public int Id { get; set; }
|
||||
@ -18,7 +18,7 @@ namespace FurnitureAssemblyContracts.ViewModels
|
||||
public int FurnitureId { get; set; }
|
||||
|
||||
[DisplayName("Изделие")]
|
||||
public string FurnitureName { get; set; } = string.Empty;
|
||||
public string UsersName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Количество")]
|
||||
public int Count { get; set; }
|
||||
@ -27,7 +27,7 @@ namespace FurnitureAssemblyContracts.ViewModels
|
||||
public double Sum { get; set; }
|
||||
|
||||
[DisplayName("Статус")]
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
public AdStatus Status { get; set; } = AdStatus.Неизвестен;
|
||||
|
||||
[DisplayName("Дата создания")]
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
@ -9,7 +9,7 @@ using System.Threading.Tasks;
|
||||
namespace FurnitureAssemblyContracts.ViewModels
|
||||
{
|
||||
// Класс для отображения пользователю данных о заготовке (заготовках)
|
||||
public class WorkPieceViewModel : IWorkPieceModel
|
||||
public class KommentViewModel : IKommentModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
@ -9,16 +9,16 @@ using System.Threading.Tasks;
|
||||
namespace FurnitureAssemblyContracts.ViewModels
|
||||
{
|
||||
// Класс для отображения пользователю информации о продуктах (изделиях)
|
||||
public class FurnitureViewModel : IFurnitureModel
|
||||
public class FurnitureViewModel : IUsersModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Название изделия")]
|
||||
public string FurnitureName { get; set; } = string.Empty;
|
||||
public string UsersName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Цена")]
|
||||
public double Price { get; set; }
|
||||
|
||||
public Dictionary<int, (IWorkPieceModel, int)> FurnitureWorkPieces { get; set; } = new();
|
||||
public Dictionary<int, (IKommentModel, int)> FurnitureWorkPieces { get; set; } = new();
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
namespace FurnitureAssemblyDataModels.Enums
|
||||
{
|
||||
// Статус заказа
|
||||
public enum OrderStatus
|
||||
public enum AdStatus
|
||||
{
|
||||
Неизвестен = -1,
|
||||
|
@ -8,7 +8,7 @@ using System.Threading.Tasks;
|
||||
namespace FurnitureAssemblyDataModels.Models
|
||||
{
|
||||
// Интерфейс, отвечающий за заказ
|
||||
public interface IOrderModel : IId
|
||||
public interface IAdModel : IId
|
||||
{
|
||||
// id продукта
|
||||
int FurnitureId { get; }
|
||||
@ -20,7 +20,7 @@ namespace FurnitureAssemblyDataModels.Models
|
||||
double Sum { get; }
|
||||
|
||||
// статус заказа
|
||||
OrderStatus Status { get; }
|
||||
AdStatus Status { get; }
|
||||
|
||||
//дата создания заказа
|
||||
DateTime DateCreate { get; }
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
namespace FurnitureAssemblyDataModels.Models
|
||||
{
|
||||
// Интерфейс, отвечающий за компоненты
|
||||
public interface IWorkPieceModel : IId
|
||||
public interface IKommentModel : IId
|
||||
{
|
||||
// название составляющей (изделие состоит из составляющих)
|
||||
string WorkPieceName { get; }
|
@ -7,15 +7,15 @@ using System.Threading.Tasks;
|
||||
namespace FurnitureAssemblyDataModels.Models
|
||||
{
|
||||
// Интерфейс, отвечающий за продукт
|
||||
public interface IFurnitureModel : IId
|
||||
public interface IUsersModel : IId
|
||||
{
|
||||
// наименование изделия
|
||||
string FurnitureName { get; }
|
||||
string UsersName { get; }
|
||||
|
||||
// цена изделия
|
||||
double Price { get; }
|
||||
|
||||
// словарь, хранящий пары кол-во + компонент и его цена
|
||||
Dictionary<int, (IWorkPieceModel, int)> FurnitureWorkPieces { get; }
|
||||
Dictionary<int, (IKommentModel, int)> FurnitureWorkPieces { get; }
|
||||
}
|
||||
}
|
@ -20,12 +20,12 @@ namespace FurnitureAssemblyDatabaseImplement
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
||||
public virtual DbSet<WorkPiece> WorkPieces { set; get; }
|
||||
public virtual DbSet<Komment> WorkPieces { set; get; }
|
||||
|
||||
public virtual DbSet<Furniture> Furnitures { set; get; }
|
||||
public virtual DbSet<Users> Furnitures { set; get; }
|
||||
|
||||
public virtual DbSet<FurnitureWorkPiece> FurnitureWorkPieces { set; get; }
|
||||
public virtual DbSet<UsersKomment> FurnitureWorkPieces { set; get; }
|
||||
|
||||
public virtual DbSet<Order> Orders { set; get; }
|
||||
public virtual DbSet<Ad> Orders { set; get; }
|
||||
}
|
||||
}
|
||||
|
@ -12,9 +12,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
{
|
||||
public class OrderStorage : IOrderStorage
|
||||
public class AdStorage : IAdStorage
|
||||
{
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
public AdViewModel? GetElement(AdSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
@ -28,7 +28,7 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
public List<AdViewModel> GetFilteredList(AdSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
@ -44,7 +44,7 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFullList()
|
||||
public List<AdViewModel> GetFullList()
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
|
||||
@ -52,9 +52,9 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
public AdViewModel? Insert(AdBindingModel model)
|
||||
{
|
||||
var newOrder = Order.Create(model);
|
||||
var newOrder = Ad.Create(model);
|
||||
|
||||
if (newOrder == null)
|
||||
{
|
||||
@ -69,7 +69,7 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
.FirstOrDefault(x => x.Id == newOrder.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
public AdViewModel? Update(AdBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
var order = context.Orders.FirstOrDefault(x => x.Id == model.Id);
|
||||
@ -85,7 +85,7 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
return context.Orders.Include(x => x.Furniture).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
public AdViewModel? Delete(AdBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
var element = context.Orders.FirstOrDefault(rec => rec.Id == model.Id);
|
@ -11,9 +11,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
{
|
||||
public class WorkPieceStorage : IWorkPieceStorage
|
||||
public class KommentStorage : IKommentStorage
|
||||
{
|
||||
public List<WorkPieceViewModel> GetFullList()
|
||||
public List<KommentViewModel> GetFullList()
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
|
||||
@ -22,7 +22,7 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<WorkPieceViewModel> GetFilteredList(WorkPieceSearchModel model)
|
||||
public List<KommentViewModel> GetFilteredList(KommentSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.WorkPieceName))
|
||||
{
|
||||
@ -37,7 +37,7 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public WorkPieceViewModel? GetElement(WorkPieceSearchModel model)
|
||||
public KommentViewModel? GetElement(KommentSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.WorkPieceName) && !model.Id.HasValue)
|
||||
{
|
||||
@ -51,9 +51,9 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
(model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public WorkPieceViewModel? Insert(WorkPieceBindingModel model)
|
||||
public KommentViewModel? Insert(KommentBindingModel model)
|
||||
{
|
||||
var newWorkPiece = WorkPiece.Create(model);
|
||||
var newWorkPiece = Komment.Create(model);
|
||||
|
||||
if (newWorkPiece == null)
|
||||
{
|
||||
@ -67,7 +67,7 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
return newWorkPiece.GetViewModel;
|
||||
}
|
||||
|
||||
public WorkPieceViewModel? Update(WorkPieceBindingModel model)
|
||||
public KommentViewModel? Update(KommentBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
var workPiece = context.WorkPieces.FirstOrDefault(x => x.Id == model.Id);
|
||||
@ -83,7 +83,7 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
return workPiece.GetViewModel;
|
||||
}
|
||||
|
||||
public WorkPieceViewModel? Delete(WorkPieceBindingModel model)
|
||||
public KommentViewModel? Delete(KommentBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
var element = context.WorkPieces.FirstOrDefault(rec => rec.Id == model.Id);
|
@ -13,7 +13,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
{
|
||||
public class FurnitureStorage : IFurnitureStorage
|
||||
public class UsersStorage : IUsersStorage
|
||||
{
|
||||
public List<FurnitureViewModel> GetFullList()
|
||||
{
|
||||
@ -27,9 +27,9 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<FurnitureViewModel> GetFilteredList(FurnitureSearchModel model)
|
||||
public List<FurnitureViewModel> GetFilteredList(UsersSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.FurnitureName))
|
||||
if (string.IsNullOrEmpty(model.UsersName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
@ -39,15 +39,15 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
return context.Furnitures
|
||||
.Include(x => x.WorkPieces)
|
||||
.ThenInclude(x => x.WorkPiece)
|
||||
.Where(x => x.FurnitureName.Contains(model.FurnitureName))
|
||||
.Where(x => x.UsersName.Contains(model.UsersName))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public FurnitureViewModel? GetElement(FurnitureSearchModel model)
|
||||
public FurnitureViewModel? GetElement(UsersSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.FurnitureName) && !model.Id.HasValue)
|
||||
if (string.IsNullOrEmpty(model.UsersName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@ -57,14 +57,14 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
return context.Furnitures
|
||||
.Include(x => x.WorkPieces)
|
||||
.ThenInclude(x => x.WorkPiece)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.FurnitureName) && x.FurnitureName == model.FurnitureName) ||
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.UsersName) && x.UsersName == model.UsersName) ||
|
||||
model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public FurnitureViewModel? Insert(FurnitureBindingModel model)
|
||||
public FurnitureViewModel? Insert(UsersBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
var newFurniture = Furniture.Create(context, model);
|
||||
var newFurniture = Users.Create(context, model);
|
||||
|
||||
if (newFurniture == null)
|
||||
{
|
||||
@ -77,7 +77,7 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
return newFurniture.GetViewModel;
|
||||
}
|
||||
|
||||
public FurnitureViewModel? Update(FurnitureBindingModel model)
|
||||
public FurnitureViewModel? Update(UsersBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
@ -105,7 +105,7 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
}
|
||||
}
|
||||
|
||||
public FurnitureViewModel? Delete(FurnitureBindingModel model)
|
||||
public FurnitureViewModel? Delete(UsersBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
var element = context.Furnitures
|
@ -33,7 +33,7 @@ namespace FurnitureAssemblyDatabaseImplement.Migrations
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("FurnitureName")
|
||||
b.Property<string>("UsersName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
|
@ -17,7 +17,7 @@ namespace FurnitureAssemblyDatabaseImplement.Migrations
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
FurnitureName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
UsersName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Price = table.Column<double>(type: "float", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
|
@ -30,7 +30,7 @@ namespace FurnitureAssemblyDatabaseImplement.Migrations
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("FurnitureName")
|
||||
b.Property<string>("UsersName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
|
@ -11,7 +11,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Models
|
||||
{
|
||||
public class Order : IOrderModel
|
||||
public class Ad : IAdModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
@ -25,23 +25,23 @@ namespace FurnitureAssemblyDatabaseImplement.Models
|
||||
public double Sum { get; private set; }
|
||||
|
||||
[Required]
|
||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
||||
public AdStatus Status { get; private set; } = AdStatus.Неизвестен;
|
||||
|
||||
[Required]
|
||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
|
||||
public virtual Furniture Furniture { get; set; }
|
||||
public virtual Users Furniture { get; set; }
|
||||
|
||||
public static Order? Create(OrderBindingModel model)
|
||||
public static Ad? Create(AdBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Order()
|
||||
return new Ad()
|
||||
{
|
||||
Id = model.Id,
|
||||
FurnitureId = model.FurnitureId,
|
||||
@ -53,7 +53,7 @@ namespace FurnitureAssemblyDatabaseImplement.Models
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(OrderBindingModel model)
|
||||
public void Update(AdBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -64,7 +64,7 @@ namespace FurnitureAssemblyDatabaseImplement.Models
|
||||
DateImplement = model.DateImplement;
|
||||
}
|
||||
|
||||
public OrderViewModel GetViewModel => new()
|
||||
public AdViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
FurnitureId = FurnitureId,
|
||||
@ -73,7 +73,7 @@ namespace FurnitureAssemblyDatabaseImplement.Models
|
||||
Status = Status,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement,
|
||||
FurnitureName = Furniture.FurnitureName
|
||||
UsersName = Furniture.UsersName
|
||||
};
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Models
|
||||
{
|
||||
public class WorkPiece : IWorkPieceModel
|
||||
public class Komment : IKommentModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
@ -22,16 +22,16 @@ namespace FurnitureAssemblyDatabaseImplement.Models
|
||||
public double Cost { get; set; }
|
||||
|
||||
[ForeignKey("WorkPieceId")]
|
||||
public virtual List<FurnitureWorkPiece> FurnitureWorkPieces { get; set; } = new();
|
||||
public virtual List<UsersKomment> FurnitureWorkPieces { get; set; } = new();
|
||||
|
||||
public static WorkPiece? Create(WorkPieceBindingModel model)
|
||||
public static Komment? Create(KommentBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new WorkPiece()
|
||||
return new Komment()
|
||||
{
|
||||
Id = model.Id,
|
||||
WorkPieceName = model.WorkPieceName,
|
||||
@ -39,9 +39,9 @@ namespace FurnitureAssemblyDatabaseImplement.Models
|
||||
};
|
||||
}
|
||||
|
||||
public static WorkPiece Create(WorkPieceViewModel model)
|
||||
public static Komment Create(KommentViewModel model)
|
||||
{
|
||||
return new WorkPiece
|
||||
return new Komment
|
||||
{
|
||||
Id = model.Id,
|
||||
WorkPieceName = model.WorkPieceName,
|
||||
@ -49,7 +49,7 @@ namespace FurnitureAssemblyDatabaseImplement.Models
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(WorkPieceBindingModel model)
|
||||
public void Update(KommentBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -60,7 +60,7 @@ namespace FurnitureAssemblyDatabaseImplement.Models
|
||||
Cost = model.Cost;
|
||||
}
|
||||
|
||||
public WorkPieceViewModel GetViewModel => new()
|
||||
public KommentViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
WorkPieceName = WorkPieceName,
|
@ -12,27 +12,27 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Models
|
||||
{
|
||||
public class Furniture : IFurnitureModel
|
||||
public class Users : IUsersModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string FurnitureName { get; set; } = string.Empty;
|
||||
public string UsersName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public double Price { get; set; }
|
||||
|
||||
public Dictionary<int, (IWorkPieceModel, int)>? _furnitureWorkPieces = null;
|
||||
public Dictionary<int, (IKommentModel, int)>? _furnitureWorkPieces = null;
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IWorkPieceModel, int)> FurnitureWorkPieces
|
||||
public Dictionary<int, (IKommentModel, int)> FurnitureWorkPieces
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_furnitureWorkPieces == null)
|
||||
{
|
||||
_furnitureWorkPieces = WorkPieces
|
||||
.ToDictionary(recPC => recPC.WorkPieceId, recPC => (recPC.WorkPiece as IWorkPieceModel, recPC.Count));
|
||||
.ToDictionary(recPC => recPC.WorkPieceId, recPC => (recPC.WorkPiece as IKommentModel, recPC.Count));
|
||||
}
|
||||
|
||||
return _furnitureWorkPieces;
|
||||
@ -40,19 +40,19 @@ namespace FurnitureAssemblyDatabaseImplement.Models
|
||||
}
|
||||
|
||||
[ForeignKey("FurnitureId")]
|
||||
public virtual List<FurnitureWorkPiece> WorkPieces { get; set; } = new();
|
||||
public virtual List<UsersKomment> WorkPieces { get; set; } = new();
|
||||
|
||||
[ForeignKey("FurnitureId")]
|
||||
public virtual List<Order> Orders { get; set; } = new();
|
||||
public virtual List<Ad> Orders { get; set; } = new();
|
||||
|
||||
public static Furniture Create(FurnitureAssemblyDatabase context, FurnitureBindingModel model)
|
||||
public static Users Create(FurnitureAssemblyDatabase context, UsersBindingModel model)
|
||||
{
|
||||
return new Furniture()
|
||||
return new Users()
|
||||
{
|
||||
Id = model.Id,
|
||||
FurnitureName = model.FurnitureName,
|
||||
UsersName = model.UsersName,
|
||||
Price = model.Price,
|
||||
WorkPieces = model.FurnitureWorkPieces.Select(x => new FurnitureWorkPiece
|
||||
WorkPieces = model.FurnitureWorkPieces.Select(x => new UsersKomment
|
||||
{
|
||||
WorkPiece = context.WorkPieces.First(y => y.Id == x.Key),
|
||||
Count = x.Value.Item2
|
||||
@ -60,24 +60,24 @@ namespace FurnitureAssemblyDatabaseImplement.Models
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(FurnitureBindingModel model)
|
||||
public void Update(UsersBindingModel model)
|
||||
{
|
||||
FurnitureName = model.FurnitureName;
|
||||
UsersName = model.UsersName;
|
||||
Price = model.Price;
|
||||
}
|
||||
|
||||
public FurnitureViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
FurnitureName = FurnitureName,
|
||||
UsersName = UsersName,
|
||||
Price = Price,
|
||||
FurnitureWorkPieces = FurnitureWorkPieces
|
||||
};
|
||||
|
||||
Dictionary<int, (IWorkPieceModel, int)> IFurnitureModel.FurnitureWorkPieces => throw new NotImplementedException();
|
||||
Dictionary<int, (IKommentModel, int)> IUsersModel.FurnitureWorkPieces => throw new NotImplementedException();
|
||||
|
||||
|
||||
public void UpdateWorkPieces(FurnitureAssemblyDatabase context, FurnitureBindingModel model)
|
||||
public void UpdateWorkPieces(FurnitureAssemblyDatabase context, UsersBindingModel model)
|
||||
{
|
||||
var furnitureWorkPieces = context.FurnitureWorkPieces.Where(rec => rec.FurnitureId == model.Id).ToList();
|
||||
|
||||
@ -101,7 +101,7 @@ namespace FurnitureAssemblyDatabaseImplement.Models
|
||||
|
||||
foreach (var pc in model.FurnitureWorkPieces)
|
||||
{
|
||||
context.FurnitureWorkPieces.Add(new FurnitureWorkPiece
|
||||
context.FurnitureWorkPieces.Add(new UsersKomment
|
||||
{
|
||||
Furniture = furniture,
|
||||
WorkPiece = context.WorkPieces.First(x => x.Id == pc.Key),
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Models
|
||||
{
|
||||
public class FurnitureWorkPiece
|
||||
public class UsersKomment
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
@ -20,8 +20,8 @@ namespace FurnitureAssemblyDatabaseImplement.Models
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
|
||||
public virtual WorkPiece WorkPiece { get; set; } = new();
|
||||
public virtual Komment WorkPiece { get; set; } = new();
|
||||
|
||||
public virtual Furniture Furniture { get; set; } = new();
|
||||
public virtual Users Furniture { get; set; } = new();
|
||||
}
|
||||
}
|
@ -18,11 +18,11 @@ namespace FurnitureAssemblyFileImplement
|
||||
|
||||
private readonly string FurnitureFileName = "Furniture.xml";
|
||||
|
||||
public List<WorkPiece> WorkPieces { get; private set; }
|
||||
public List<Komment> WorkPieces { get; private set; }
|
||||
|
||||
public List<Order> Orders { get; private set; }
|
||||
public List<Ad> Orders { get; private set; }
|
||||
|
||||
public List<Furniture> Furnitures { get; private set; }
|
||||
public List<Users> Furnitures { get; private set; }
|
||||
|
||||
public static DataFileSingleton GetInstance()
|
||||
{
|
||||
@ -43,9 +43,9 @@ namespace FurnitureAssemblyFileImplement
|
||||
|
||||
private DataFileSingleton()
|
||||
{
|
||||
WorkPieces = LoadData(WorkPieceFileName, "WorkPiece", x => WorkPiece.Create(x)!)!;
|
||||
Furnitures = LoadData(FurnitureFileName, "Furniture", x => Furniture.Create(x)!)!;
|
||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||
WorkPieces = LoadData(WorkPieceFileName, "WorkPiece", x => Komment.Create(x)!)!;
|
||||
Furnitures = LoadData(FurnitureFileName, "Furniture", x => Users.Create(x)!)!;
|
||||
Orders = LoadData(OrderFileName, "Order", x => Ad.Create(x)!)!;
|
||||
}
|
||||
|
||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
||||
|
@ -11,21 +11,21 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyFileImplement.Implements
|
||||
{
|
||||
public class OrderStorage : IOrderStorage
|
||||
public class AdStorage : IAdStorage
|
||||
{
|
||||
private readonly DataFileSingleton source;
|
||||
|
||||
public OrderStorage()
|
||||
public AdStorage()
|
||||
{
|
||||
source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFullList()
|
||||
public List<AdViewModel> GetFullList()
|
||||
{
|
||||
return source.Orders.Select(x => GetViewModel(x)).ToList();
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
public List<AdViewModel> GetFilteredList(AdSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
@ -35,7 +35,7 @@ namespace FurnitureAssemblyFileImplement.Implements
|
||||
return source.Orders.Where(x => x.Id == model.Id).Select(x => GetViewModel(x)).ToList();
|
||||
}
|
||||
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
public AdViewModel? GetElement(AdSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
@ -45,22 +45,22 @@ namespace FurnitureAssemblyFileImplement.Implements
|
||||
return source.Orders.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
private OrderViewModel GetViewModel(Order order)
|
||||
private AdViewModel GetViewModel(Ad order)
|
||||
{
|
||||
var viewModel = order.GetViewModel;
|
||||
|
||||
var furniture = source.Furnitures.FirstOrDefault(x => x.Id == order.FurnitureId);
|
||||
|
||||
viewModel.FurnitureName = furniture?.FurnitureName;
|
||||
viewModel.UsersName = furniture?.UsersName;
|
||||
|
||||
return viewModel;
|
||||
}
|
||||
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
public AdViewModel? Insert(AdBindingModel model)
|
||||
{
|
||||
model.Id = source.Orders.Count > 0 ? source.Orders.Max(x => x.Id) + 1 : 1;
|
||||
|
||||
var newOrder = Order.Create(model);
|
||||
var newOrder = Ad.Create(model);
|
||||
|
||||
if (newOrder == null)
|
||||
{
|
||||
@ -73,7 +73,7 @@ namespace FurnitureAssemblyFileImplement.Implements
|
||||
return GetViewModel(newOrder);
|
||||
}
|
||||
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
public AdViewModel? Update(AdBindingModel model)
|
||||
{
|
||||
var order = source.Orders.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
||||
@ -88,7 +88,7 @@ namespace FurnitureAssemblyFileImplement.Implements
|
||||
return GetViewModel(order);
|
||||
}
|
||||
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
public AdViewModel? Delete(AdBindingModel model)
|
||||
{
|
||||
var element = source.Orders.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
@ -11,21 +11,21 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyFileImplement.Implements
|
||||
{
|
||||
public class WorkPieceStorage : IWorkPieceStorage
|
||||
public class KommentStorage : IKommentStorage
|
||||
{
|
||||
private readonly DataFileSingleton source;
|
||||
|
||||
public WorkPieceStorage()
|
||||
public KommentStorage()
|
||||
{
|
||||
source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
|
||||
public List<WorkPieceViewModel> GetFullList()
|
||||
public List<KommentViewModel> GetFullList()
|
||||
{
|
||||
return source.WorkPieces.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<WorkPieceViewModel> GetFilteredList(WorkPieceSearchModel model)
|
||||
public List<KommentViewModel> GetFilteredList(KommentSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.WorkPieceName))
|
||||
{
|
||||
@ -35,7 +35,7 @@ namespace FurnitureAssemblyFileImplement.Implements
|
||||
return source.WorkPieces.Where(x => x.WorkPieceName.Contains(model.WorkPieceName)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public WorkPieceViewModel? GetElement(WorkPieceSearchModel model)
|
||||
public KommentViewModel? GetElement(KommentSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.WorkPieceName) && !model.Id.HasValue)
|
||||
{
|
||||
@ -46,11 +46,11 @@ namespace FurnitureAssemblyFileImplement.Implements
|
||||
|| (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public WorkPieceViewModel? Insert(WorkPieceBindingModel model)
|
||||
public KommentViewModel? Insert(KommentBindingModel model)
|
||||
{
|
||||
model.Id = source.WorkPieces.Count > 0 ? source.WorkPieces.Max(x => x.Id) + 1 : 1;
|
||||
|
||||
var newWorkPiece = WorkPiece.Create(model);
|
||||
var newWorkPiece = Komment.Create(model);
|
||||
|
||||
if (newWorkPiece == null)
|
||||
{
|
||||
@ -63,7 +63,7 @@ namespace FurnitureAssemblyFileImplement.Implements
|
||||
return newWorkPiece.GetViewModel;
|
||||
}
|
||||
|
||||
public WorkPieceViewModel? Update(WorkPieceBindingModel model)
|
||||
public KommentViewModel? Update(KommentBindingModel model)
|
||||
{
|
||||
var workPiece = source.WorkPieces.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
||||
@ -78,7 +78,7 @@ namespace FurnitureAssemblyFileImplement.Implements
|
||||
return workPiece.GetViewModel;
|
||||
}
|
||||
|
||||
public WorkPieceViewModel? Delete(WorkPieceBindingModel model)
|
||||
public KommentViewModel? Delete(KommentBindingModel model)
|
||||
{
|
||||
var element = source.WorkPieces.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
@ -11,11 +11,11 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyFileImplement.Implements
|
||||
{
|
||||
public class FurnitureStorage : IFurnitureStorage
|
||||
public class UsersStorage : IUsersStorage
|
||||
{
|
||||
private readonly DataFileSingleton source;
|
||||
|
||||
public FurnitureStorage()
|
||||
public UsersStorage()
|
||||
{
|
||||
source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
@ -25,32 +25,32 @@ namespace FurnitureAssemblyFileImplement.Implements
|
||||
return source.Furnitures.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<FurnitureViewModel> GetFilteredList(FurnitureSearchModel model)
|
||||
public List<FurnitureViewModel> GetFilteredList(UsersSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.FurnitureName))
|
||||
if (string.IsNullOrEmpty(model.UsersName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
return source.Furnitures.Where(x => x.FurnitureName.Contains(model.FurnitureName)).Select(x => x.GetViewModel).ToList();
|
||||
return source.Furnitures.Where(x => x.UsersName.Contains(model.UsersName)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public FurnitureViewModel? GetElement(FurnitureSearchModel model)
|
||||
public FurnitureViewModel? GetElement(UsersSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.FurnitureName) && !model.Id.HasValue)
|
||||
if (string.IsNullOrEmpty(model.UsersName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return source.Furnitures.FirstOrDefault(x => (!string.IsNullOrEmpty(model.FurnitureName) && x.FurnitureName == model.FurnitureName)
|
||||
return source.Furnitures.FirstOrDefault(x => (!string.IsNullOrEmpty(model.UsersName) && x.UsersName == model.UsersName)
|
||||
|| (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public FurnitureViewModel? Insert(FurnitureBindingModel model)
|
||||
public FurnitureViewModel? Insert(UsersBindingModel model)
|
||||
{
|
||||
model.Id = source.Furnitures.Count > 0 ? source.Furnitures.Max(x => x.Id) + 1 : 1;
|
||||
|
||||
var newFurniture = Furniture.Create(model);
|
||||
var newFurniture = Users.Create(model);
|
||||
|
||||
if (newFurniture == null)
|
||||
{
|
||||
@ -63,7 +63,7 @@ namespace FurnitureAssemblyFileImplement.Implements
|
||||
return newFurniture.GetViewModel;
|
||||
}
|
||||
|
||||
public FurnitureViewModel? Update(FurnitureBindingModel model)
|
||||
public FurnitureViewModel? Update(UsersBindingModel model)
|
||||
{
|
||||
var furniture = source.Furnitures.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
||||
@ -78,7 +78,7 @@ namespace FurnitureAssemblyFileImplement.Implements
|
||||
return furniture.GetViewModel;
|
||||
}
|
||||
|
||||
public FurnitureViewModel? Delete(FurnitureBindingModel model)
|
||||
public FurnitureViewModel? Delete(UsersBindingModel model)
|
||||
{
|
||||
var element = source.Furnitures.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
@ -11,7 +11,7 @@ using System.Xml.Linq;
|
||||
|
||||
namespace FurnitureAssemblyFileImplement.Models
|
||||
{
|
||||
public class Order : IOrderModel
|
||||
public class Ad : IAdModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
@ -21,20 +21,20 @@ namespace FurnitureAssemblyFileImplement.Models
|
||||
|
||||
public double Sum { get; private set; }
|
||||
|
||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
||||
public AdStatus Status { get; private set; } = AdStatus.Неизвестен;
|
||||
|
||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
|
||||
public static Order? Create(OrderBindingModel model)
|
||||
public static Ad? Create(AdBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Order()
|
||||
return new Ad()
|
||||
{
|
||||
Id = model.Id,
|
||||
FurnitureId = model.FurnitureId,
|
||||
@ -46,27 +46,27 @@ namespace FurnitureAssemblyFileImplement.Models
|
||||
};
|
||||
}
|
||||
|
||||
public static Order? Create(XElement element)
|
||||
public static Ad? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Order()
|
||||
return new Ad()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
FurnitureId = Convert.ToInt32(element.Element("FurnitureId")!.Value),
|
||||
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
||||
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
||||
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
|
||||
Status = (AdStatus)Enum.Parse(typeof(AdStatus), element.Element("Status")!.Value),
|
||||
DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value),
|
||||
DateImplement = string.IsNullOrEmpty(element.Element("DateImplement")!.Value) ? null :
|
||||
Convert.ToDateTime(element.Element("DateImplement")!.Value)
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(OrderBindingModel model)
|
||||
public void Update(AdBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -77,7 +77,7 @@ namespace FurnitureAssemblyFileImplement.Models
|
||||
DateImplement = model.DateImplement;
|
||||
}
|
||||
|
||||
public OrderViewModel GetViewModel => new()
|
||||
public AdViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
FurnitureId = FurnitureId,
|
@ -10,7 +10,7 @@ using System.Xml.Linq;
|
||||
|
||||
namespace FurnitureAssemblyFileImplement.Models
|
||||
{
|
||||
public class WorkPiece : IWorkPieceModel
|
||||
public class Komment : IKommentModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
@ -18,14 +18,14 @@ namespace FurnitureAssemblyFileImplement.Models
|
||||
|
||||
public double Cost { get; set; }
|
||||
|
||||
public static WorkPiece? Create(WorkPieceBindingModel model)
|
||||
public static Komment? Create(KommentBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new WorkPiece()
|
||||
return new Komment()
|
||||
{
|
||||
Id = model.Id,
|
||||
WorkPieceName = model.WorkPieceName,
|
||||
@ -33,14 +33,14 @@ namespace FurnitureAssemblyFileImplement.Models
|
||||
};
|
||||
}
|
||||
|
||||
public static WorkPiece? Create(XElement element)
|
||||
public static Komment? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new WorkPiece()
|
||||
return new Komment()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
WorkPieceName = element.Element("WorkPieceName")!.Value,
|
||||
@ -48,7 +48,7 @@ namespace FurnitureAssemblyFileImplement.Models
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(WorkPieceBindingModel model)
|
||||
public void Update(KommentBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -59,7 +59,7 @@ namespace FurnitureAssemblyFileImplement.Models
|
||||
Cost = model.Cost;
|
||||
}
|
||||
|
||||
public WorkPieceViewModel GetViewModel => new()
|
||||
public KommentViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
WorkPieceName = WorkPieceName,
|
@ -10,19 +10,19 @@ using System.Xml.Linq;
|
||||
|
||||
namespace FurnitureAssemblyFileImplement.Models
|
||||
{
|
||||
public class Furniture : IFurnitureModel
|
||||
public class Users : IUsersModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
public string FurnitureName { get; private set; } = string.Empty;
|
||||
public string UsersName { get; private set; } = string.Empty;
|
||||
|
||||
public double Price { get; private set; }
|
||||
|
||||
public Dictionary<int, int> WorkPieces { get; private set; } = new();
|
||||
|
||||
private Dictionary<int, (IWorkPieceModel, int)>? _furnitureWorkPieces = null;
|
||||
private Dictionary<int, (IKommentModel, int)>? _furnitureWorkPieces = null;
|
||||
|
||||
public Dictionary<int, (IWorkPieceModel, int)> FurnitureWorkPieces
|
||||
public Dictionary<int, (IKommentModel, int)> FurnitureWorkPieces
|
||||
{
|
||||
get
|
||||
{
|
||||
@ -31,40 +31,40 @@ namespace FurnitureAssemblyFileImplement.Models
|
||||
var source = DataFileSingleton.GetInstance();
|
||||
|
||||
_furnitureWorkPieces = WorkPieces.ToDictionary(x => x.Key,
|
||||
y => ((source.WorkPieces.FirstOrDefault(z => z.Id == y.Key) as IWorkPieceModel)!, y.Value));
|
||||
y => ((source.WorkPieces.FirstOrDefault(z => z.Id == y.Key) as IKommentModel)!, y.Value));
|
||||
}
|
||||
|
||||
return _furnitureWorkPieces;
|
||||
}
|
||||
}
|
||||
|
||||
public static Furniture? Create(FurnitureBindingModel model)
|
||||
public static Users? Create(UsersBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Furniture()
|
||||
return new Users()
|
||||
{
|
||||
Id = model.Id,
|
||||
FurnitureName = model.FurnitureName,
|
||||
UsersName = model.UsersName,
|
||||
Price = model.Price,
|
||||
WorkPieces = model.FurnitureWorkPieces.ToDictionary(x => x.Key, x => x.Value.Item2)
|
||||
};
|
||||
}
|
||||
|
||||
public static Furniture? Create(XElement element)
|
||||
public static Users? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Furniture()
|
||||
return new Users()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
FurnitureName = element.Element("FurnitureName")!.Value,
|
||||
UsersName = element.Element("UsersName")!.Value,
|
||||
Price = Convert.ToDouble(element.Element("Price")!.Value),
|
||||
WorkPieces = element.Element("FurnitureWorkPieces")!.Elements("FurnitureWorkPieces").ToDictionary(
|
||||
x => Convert.ToInt32(x.Element("Key")?.Value),
|
||||
@ -72,14 +72,14 @@ namespace FurnitureAssemblyFileImplement.Models
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(FurnitureBindingModel model)
|
||||
public void Update(UsersBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FurnitureName = model.FurnitureName;
|
||||
UsersName = model.UsersName;
|
||||
Price = model.Price;
|
||||
WorkPieces = model.FurnitureWorkPieces.ToDictionary(x => x.Key, x => x.Value.Item2);
|
||||
_furnitureWorkPieces = null;
|
||||
@ -88,14 +88,14 @@ namespace FurnitureAssemblyFileImplement.Models
|
||||
public FurnitureViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
FurnitureName = FurnitureName,
|
||||
UsersName = UsersName,
|
||||
Price = Price,
|
||||
FurnitureWorkPieces = FurnitureWorkPieces
|
||||
};
|
||||
|
||||
public XElement GetXElement => new("Furniture",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("FurnitureName", FurnitureName),
|
||||
new XElement("UsersName", UsersName),
|
||||
new XElement("Price", Price.ToString()),
|
||||
new XElement("FurnitureWorkPieces", WorkPieces.Select(
|
||||
x => new XElement("FurnitureWorkPieces",
|
@ -10,17 +10,17 @@ namespace FurnitureAssemblyListImplement
|
||||
public class DataListSingleton
|
||||
{
|
||||
private static DataListSingleton? _instance;
|
||||
public List<Order> Orders { get; set; }
|
||||
public List<Furniture> Furnitures { get; set; }
|
||||
public List<Ad> Orders { get; set; }
|
||||
public List<Users> Furnitures { get; set; }
|
||||
|
||||
public List<WorkPiece> WorkPiece { get; set; }
|
||||
public List<Komment> WorkPiece { get; set; }
|
||||
|
||||
|
||||
public DataListSingleton()
|
||||
{
|
||||
WorkPiece = new List<WorkPiece>();
|
||||
Furnitures = new List<Furniture>();
|
||||
Orders = new List<Order>();
|
||||
WorkPiece = new List<Komment>();
|
||||
Furnitures = new List<Users>();
|
||||
Orders = new List<Ad>();
|
||||
}
|
||||
|
||||
public static DataListSingleton GetInstance()
|
||||
|
@ -12,18 +12,18 @@ using System.Threading.Tasks;
|
||||
namespace FurnitureAssemblyListImplement.Implements
|
||||
{
|
||||
// Класс, реализующий интерфейс хранилища заказов
|
||||
public class OrderStorage : IOrderStorage
|
||||
public class AdStorage : IAdStorage
|
||||
{
|
||||
private readonly DataListSingleton _source;
|
||||
|
||||
public OrderStorage()
|
||||
public AdStorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFullList()
|
||||
public List<AdViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<OrderViewModel>();
|
||||
var result = new List<AdViewModel>();
|
||||
|
||||
foreach(var order in _source.Orders)
|
||||
{
|
||||
@ -33,9 +33,9 @@ namespace FurnitureAssemblyListImplement.Implements
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
public List<AdViewModel> GetFilteredList(AdSearchModel model)
|
||||
{
|
||||
var result = new List<OrderViewModel>();
|
||||
var result = new List<AdViewModel>();
|
||||
|
||||
if(!model.Id.HasValue)
|
||||
{
|
||||
@ -53,7 +53,7 @@ namespace FurnitureAssemblyListImplement.Implements
|
||||
return result;
|
||||
}
|
||||
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
public AdViewModel? GetElement(AdSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
@ -71,7 +71,7 @@ namespace FurnitureAssemblyListImplement.Implements
|
||||
return null;
|
||||
}
|
||||
|
||||
private OrderViewModel GetViewModel(Order order)
|
||||
private AdViewModel GetViewModel(Ad order)
|
||||
{
|
||||
var viewModel = order.GetViewModel;
|
||||
|
||||
@ -79,7 +79,7 @@ namespace FurnitureAssemblyListImplement.Implements
|
||||
{
|
||||
if (furniture.Id == order.FurnitureId)
|
||||
{
|
||||
viewModel.FurnitureName = furniture.FurnitureName;
|
||||
viewModel.UsersName = furniture.UsersName;
|
||||
|
||||
break;
|
||||
}
|
||||
@ -88,7 +88,7 @@ namespace FurnitureAssemblyListImplement.Implements
|
||||
return viewModel;
|
||||
}
|
||||
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
public AdViewModel? Insert(AdBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
|
||||
@ -100,7 +100,7 @@ namespace FurnitureAssemblyListImplement.Implements
|
||||
}
|
||||
}
|
||||
|
||||
var newOrder = Order.Create(model);
|
||||
var newOrder = Ad.Create(model);
|
||||
|
||||
if(newOrder == null)
|
||||
{
|
||||
@ -111,7 +111,7 @@ namespace FurnitureAssemblyListImplement.Implements
|
||||
|
||||
return GetViewModel(newOrder);
|
||||
}
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
public AdViewModel? Update(AdBindingModel model)
|
||||
{
|
||||
foreach(var order in _source.Orders)
|
||||
{
|
||||
@ -126,7 +126,7 @@ namespace FurnitureAssemblyListImplement.Implements
|
||||
return null;
|
||||
}
|
||||
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
public AdViewModel? Delete(AdBindingModel model)
|
||||
{
|
||||
for(int i = 0; i < _source.Orders.Count; i++)
|
||||
{
|
@ -12,21 +12,21 @@ using System.Threading.Tasks;
|
||||
namespace FurnitureAssemblyListImplement.Implements
|
||||
{
|
||||
// Класс, реализующий интерфейс хранилища заготовок
|
||||
public class WorkPieceStorage : IWorkPieceStorage
|
||||
public class KommentStorage : IKommentStorage
|
||||
{
|
||||
// Поле для работы со списком заготовок
|
||||
private readonly DataListSingleton _source;
|
||||
|
||||
// Получение в конструкторе объекта DataListSingleton
|
||||
public WorkPieceStorage()
|
||||
public KommentStorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
|
||||
// Получение полного списка заготовок
|
||||
public List<WorkPieceViewModel> GetFullList()
|
||||
public List<KommentViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<WorkPieceViewModel>();
|
||||
var result = new List<KommentViewModel>();
|
||||
|
||||
foreach(var workPiece in _source.WorkPiece)
|
||||
{
|
||||
@ -37,9 +37,9 @@ namespace FurnitureAssemblyListImplement.Implements
|
||||
}
|
||||
|
||||
// Получение отфильтрованного списка заготовок
|
||||
public List<WorkPieceViewModel> GetFilteredList(WorkPieceSearchModel model)
|
||||
public List<KommentViewModel> GetFilteredList(KommentSearchModel model)
|
||||
{
|
||||
var result = new List<WorkPieceViewModel>();
|
||||
var result = new List<KommentViewModel>();
|
||||
|
||||
if(string.IsNullOrEmpty(model.WorkPieceName))
|
||||
{
|
||||
@ -58,7 +58,7 @@ namespace FurnitureAssemblyListImplement.Implements
|
||||
}
|
||||
|
||||
// Получение элемента из списка заготовок
|
||||
public WorkPieceViewModel? GetElement(WorkPieceSearchModel model)
|
||||
public KommentViewModel? GetElement(KommentSearchModel model)
|
||||
{
|
||||
if(string.IsNullOrEmpty(model.WorkPieceName) && !model.Id.HasValue)
|
||||
{
|
||||
@ -78,7 +78,7 @@ namespace FurnitureAssemblyListImplement.Implements
|
||||
}
|
||||
|
||||
// При создании заготовки определяем для него новый id: ищем max id и прибавляем к нему 1
|
||||
public WorkPieceViewModel? Insert(WorkPieceBindingModel model)
|
||||
public KommentViewModel? Insert(KommentBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
|
||||
@ -90,7 +90,7 @@ namespace FurnitureAssemblyListImplement.Implements
|
||||
}
|
||||
}
|
||||
|
||||
var newWorkPiece = WorkPiece.Create(model);
|
||||
var newWorkPiece = Komment.Create(model);
|
||||
|
||||
if(newWorkPiece == null)
|
||||
{
|
||||
@ -103,7 +103,7 @@ namespace FurnitureAssemblyListImplement.Implements
|
||||
}
|
||||
|
||||
// Обновление заготовки
|
||||
public WorkPieceViewModel? Update(WorkPieceBindingModel model)
|
||||
public KommentViewModel? Update(KommentBindingModel model)
|
||||
{
|
||||
foreach(var workPiece in _source.WorkPiece)
|
||||
{
|
||||
@ -119,7 +119,7 @@ namespace FurnitureAssemblyListImplement.Implements
|
||||
}
|
||||
|
||||
// Удаление заготовки
|
||||
public WorkPieceViewModel? Delete(WorkPieceBindingModel model)
|
||||
public KommentViewModel? Delete(KommentBindingModel model)
|
||||
{
|
||||
for(int i = 0; i < _source.WorkPiece.Count; i++)
|
||||
{
|
@ -12,13 +12,13 @@ using System.Threading.Tasks;
|
||||
namespace FurnitureAssemblyListImplement.Implements
|
||||
{
|
||||
// Класс, реализующий интерфейс хранилища изделий
|
||||
public class FurnitureStorage : IFurnitureStorage
|
||||
public class UsersStorage : IUsersStorage
|
||||
{
|
||||
// Поле для работы со списком изделий
|
||||
private readonly DataListSingleton _source;
|
||||
|
||||
// Получение в конструкторе объекта DataListSingleton
|
||||
public FurnitureStorage()
|
||||
public UsersStorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
@ -37,18 +37,18 @@ namespace FurnitureAssemblyListImplement.Implements
|
||||
}
|
||||
|
||||
// Получение отфильтрованного списка изделий
|
||||
public List<FurnitureViewModel> GetFilteredList(FurnitureSearchModel model)
|
||||
public List<FurnitureViewModel> GetFilteredList(UsersSearchModel model)
|
||||
{
|
||||
var result = new List<FurnitureViewModel>();
|
||||
|
||||
if(string.IsNullOrEmpty(model.FurnitureName))
|
||||
if(string.IsNullOrEmpty(model.UsersName))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
foreach(var furniture in _source.Furnitures)
|
||||
{
|
||||
if (furniture.FurnitureName.Contains(model.FurnitureName))
|
||||
if (furniture.UsersName.Contains(model.UsersName))
|
||||
{
|
||||
result.Add(furniture.GetViewModel);
|
||||
}
|
||||
@ -58,16 +58,16 @@ namespace FurnitureAssemblyListImplement.Implements
|
||||
}
|
||||
|
||||
// Получение элемента из списка изделий
|
||||
public FurnitureViewModel? GetElement(FurnitureSearchModel model)
|
||||
public FurnitureViewModel? GetElement(UsersSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.FurnitureName) && !model.Id.HasValue)
|
||||
if (string.IsNullOrEmpty(model.UsersName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach(var furniture in _source.Furnitures)
|
||||
{
|
||||
if((!string.IsNullOrEmpty(model.FurnitureName) && furniture.FurnitureName == model.FurnitureName) ||
|
||||
if((!string.IsNullOrEmpty(model.UsersName) && furniture.UsersName == model.UsersName) ||
|
||||
(model.Id.HasValue && furniture.Id == model.Id))
|
||||
{
|
||||
return furniture.GetViewModel;
|
||||
@ -78,7 +78,7 @@ namespace FurnitureAssemblyListImplement.Implements
|
||||
}
|
||||
|
||||
// При создании изделия определяем для него новый id: ищем max id и прибавлляем к нему 1
|
||||
public FurnitureViewModel? Insert(FurnitureBindingModel model)
|
||||
public FurnitureViewModel? Insert(UsersBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
|
||||
@ -90,7 +90,7 @@ namespace FurnitureAssemblyListImplement.Implements
|
||||
}
|
||||
}
|
||||
|
||||
var newFurniture = Furniture.Create(model);
|
||||
var newFurniture = Users.Create(model);
|
||||
|
||||
if(newFurniture == null)
|
||||
{
|
||||
@ -103,7 +103,7 @@ namespace FurnitureAssemblyListImplement.Implements
|
||||
}
|
||||
|
||||
// Обновление изделия
|
||||
public FurnitureViewModel? Update(FurnitureBindingModel model)
|
||||
public FurnitureViewModel? Update(UsersBindingModel model)
|
||||
{
|
||||
foreach(var furniture in _source.Furnitures)
|
||||
{
|
||||
@ -119,7 +119,7 @@ namespace FurnitureAssemblyListImplement.Implements
|
||||
}
|
||||
|
||||
// Удаление изделия
|
||||
public FurnitureViewModel? Delete(FurnitureBindingModel model)
|
||||
public FurnitureViewModel? Delete(UsersBindingModel model)
|
||||
{
|
||||
for(int i = 0; i < _source.Furnitures.Count; ++i)
|
||||
{
|
@ -11,7 +11,7 @@ using System.Threading.Tasks;
|
||||
namespace FurnitureAssemblyListImplement.Models
|
||||
{
|
||||
// Класс, реализующий интерфейс модели заказа
|
||||
public class Order : IOrderModel
|
||||
public class Ad : IAdModel
|
||||
{
|
||||
// Методы set сделали приватными, чтобы исключить неразрешённые манипуляции
|
||||
public int Id { get; private set; }
|
||||
@ -22,20 +22,20 @@ namespace FurnitureAssemblyListImplement.Models
|
||||
|
||||
public double Sum { get; private set; }
|
||||
|
||||
public OrderStatus Status { get; private set; }
|
||||
public AdStatus Status { get; private set; }
|
||||
|
||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
public static Ad? Create(AdBindingModel? model)
|
||||
{
|
||||
if(model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Order()
|
||||
return new Ad()
|
||||
{
|
||||
Id = model.Id,
|
||||
FurnitureId = model.FurnitureId,
|
||||
@ -48,7 +48,7 @@ namespace FurnitureAssemblyListImplement.Models
|
||||
}
|
||||
|
||||
// Метод изменения существующего объекта
|
||||
public void Update(OrderBindingModel? model)
|
||||
public void Update(AdBindingModel? model)
|
||||
{
|
||||
if(model == null)
|
||||
{
|
||||
@ -59,7 +59,7 @@ namespace FurnitureAssemblyListImplement.Models
|
||||
}
|
||||
|
||||
// Метод для создания объекта класса ViewModel на основе данных объекта класса-компонента
|
||||
public OrderViewModel GetViewModel => new()
|
||||
public AdViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
FurnitureId = FurnitureId,
|
@ -10,7 +10,7 @@ using System.Threading.Tasks;
|
||||
namespace FurnitureAssemblyListImplement.Models
|
||||
{
|
||||
// Реализация интерфейса модели заготовки
|
||||
public class WorkPiece : IWorkPieceModel
|
||||
public class Komment : IKommentModel
|
||||
{
|
||||
// Методы set делаем приватным, чтобы исключить неразрешённые манипуляции
|
||||
public int Id { get; private set; }
|
||||
@ -20,14 +20,14 @@ namespace FurnitureAssemblyListImplement.Models
|
||||
public double Cost { get; private set; }
|
||||
|
||||
// Метод для создания объекта от класса-компонента на основе класса-BindingModel
|
||||
public static WorkPiece? Create(WorkPieceBindingModel? model)
|
||||
public static Komment? Create(KommentBindingModel? model)
|
||||
{
|
||||
if(model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new WorkPiece()
|
||||
return new Komment()
|
||||
{
|
||||
Id = model.Id,
|
||||
WorkPieceName = model.WorkPieceName,
|
||||
@ -36,7 +36,7 @@ namespace FurnitureAssemblyListImplement.Models
|
||||
}
|
||||
|
||||
// Метод изменения существующего объекта
|
||||
public void Update(WorkPieceBindingModel? model)
|
||||
public void Update(KommentBindingModel? model)
|
||||
{
|
||||
if(model == null)
|
||||
{
|
||||
@ -48,7 +48,7 @@ namespace FurnitureAssemblyListImplement.Models
|
||||
}
|
||||
|
||||
// Метод для создания объекта класса ViewModel на основе данных объекта класса-компонента
|
||||
public WorkPieceViewModel GetViewModel => new()
|
||||
public KommentViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
WorkPieceName = WorkPieceName,
|
@ -10,43 +10,43 @@ using System.Threading.Tasks;
|
||||
namespace FurnitureAssemblyListImplement.Models
|
||||
{
|
||||
// Класс реализующий интерфейс модели изделия
|
||||
public class Furniture : IFurnitureModel
|
||||
public class Users : IUsersModel
|
||||
{
|
||||
// Методы set делаем приватным, чтобы исключить неразрешённые манипуляции
|
||||
public int Id { get; private set; }
|
||||
|
||||
public string FurnitureName { get; private set; } = string.Empty;
|
||||
public string UsersName { get; private set; } = string.Empty;
|
||||
|
||||
public double Price { get; private set; }
|
||||
|
||||
public Dictionary<int, (IWorkPieceModel, int)> FurnitureWorkPieces { get; private set; } = new Dictionary<int, (IWorkPieceModel, int)>();
|
||||
public Dictionary<int, (IKommentModel, int)> FurnitureWorkPieces { get; private set; } = new Dictionary<int, (IKommentModel, int)>();
|
||||
|
||||
// Метод для создания объекта от класса-компонента на основе класса-BindingModel
|
||||
public static Furniture? Create(FurnitureBindingModel? model)
|
||||
public static Users? Create(UsersBindingModel? model)
|
||||
{
|
||||
if(model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Furniture()
|
||||
return new Users()
|
||||
{
|
||||
Id = model.Id,
|
||||
FurnitureName = model.FurnitureName,
|
||||
UsersName = model.UsersName,
|
||||
Price = model.Price,
|
||||
FurnitureWorkPieces = model.FurnitureWorkPieces
|
||||
};
|
||||
}
|
||||
|
||||
// Метод изменения существующего объекта
|
||||
public void Update(FurnitureBindingModel? model)
|
||||
public void Update(UsersBindingModel? model)
|
||||
{
|
||||
if(model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FurnitureName = model.FurnitureName;
|
||||
UsersName = model.UsersName;
|
||||
Price = model.Price;
|
||||
FurnitureWorkPieces = model.FurnitureWorkPieces;
|
||||
}
|
||||
@ -55,7 +55,7 @@ namespace FurnitureAssemblyListImplement.Models
|
||||
public FurnitureViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
FurnitureName = FurnitureName,
|
||||
UsersName = UsersName,
|
||||
Price = Price,
|
||||
FurnitureWorkPieces = FurnitureWorkPieces
|
||||
};
|
@ -19,11 +19,11 @@ namespace FurnitureAssemblyView
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IFurnitureLogic _logicM;
|
||||
private readonly IUsersLogic _logicM;
|
||||
|
||||
private readonly IOrderLogic _logicO;
|
||||
private readonly IAdLogic _logicO;
|
||||
|
||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, IFurnitureLogic logicM, IOrderLogic logicO)
|
||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, IUsersLogic logicM, IAdLogic logicO)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
@ -42,7 +42,7 @@ namespace FurnitureAssemblyView
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
comboBoxFurniture.DisplayMember = "FurnitureName";
|
||||
comboBoxFurniture.DisplayMember = "UsersName";
|
||||
comboBoxFurniture.ValueMember = "Id";
|
||||
comboBoxFurniture.DataSource = list;
|
||||
comboBoxFurniture.SelectedItem = null;
|
||||
@ -64,7 +64,7 @@ namespace FurnitureAssemblyView
|
||||
{
|
||||
int id = Convert.ToInt32(comboBoxFurniture.SelectedValue);
|
||||
|
||||
var furniture = _logicM.ReadElement(new FurnitureSearchModel
|
||||
var furniture = _logicM.ReadElement(new UsersSearchModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
@ -113,7 +113,7 @@ namespace FurnitureAssemblyView
|
||||
|
||||
try
|
||||
{
|
||||
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
||||
var operationResult = _logicO.CreateOrder(new AdBindingModel
|
||||
{
|
||||
FurnitureId = Convert.ToInt32(comboBoxFurniture.SelectedValue),
|
||||
Count = Convert.ToInt32(textBoxCount.Text),
|
||||
|
@ -19,21 +19,21 @@ namespace FurnitureAssemblyView
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IFurnitureLogic _logic;
|
||||
private readonly IUsersLogic _logic;
|
||||
|
||||
private int? _id;
|
||||
|
||||
private Dictionary<int, (IWorkPieceModel, int)> _furnitureWorkPieces;
|
||||
private Dictionary<int, (IKommentModel, int)> _furnitureWorkPieces;
|
||||
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormFurniture(ILogger<FormFurniture> logger, IFurnitureLogic logic)
|
||||
public FormFurniture(ILogger<FormFurniture> logger, IUsersLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
_furnitureWorkPieces = new Dictionary<int, (IWorkPieceModel, int)>();
|
||||
_furnitureWorkPieces = new Dictionary<int, (IKommentModel, int)>();
|
||||
}
|
||||
|
||||
private void FormFurniture_Load(object sender, EventArgs e)
|
||||
@ -44,13 +44,13 @@ namespace FurnitureAssemblyView
|
||||
|
||||
try
|
||||
{
|
||||
var view = _logic.ReadElement(new FurnitureSearchModel { Id = _id.Value });
|
||||
var view = _logic.ReadElement(new UsersSearchModel { Id = _id.Value });
|
||||
|
||||
if(view != null)
|
||||
{
|
||||
textBoxName.Text = view.FurnitureName;
|
||||
textBoxName.Text = view.UsersName;
|
||||
textBoxPrice.Text = view.Price.ToString();
|
||||
_furnitureWorkPieces = view.FurnitureWorkPieces ?? new Dictionary<int, (IWorkPieceModel, int)>();
|
||||
_furnitureWorkPieces = view.FurnitureWorkPieces ?? new Dictionary<int, (IKommentModel, int)>();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
@ -197,10 +197,10 @@ namespace FurnitureAssemblyView
|
||||
|
||||
try
|
||||
{
|
||||
var model = new FurnitureBindingModel
|
||||
var model = new UsersBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
FurnitureName = textBoxName.Text,
|
||||
UsersName = textBoxName.Text,
|
||||
Price = Convert.ToDouble(textBoxPrice.Text),
|
||||
FurnitureWorkPieces = _furnitureWorkPieces
|
||||
};
|
||||
|
@ -16,7 +16,7 @@ namespace FurnitureAssemblyView
|
||||
{
|
||||
public partial class FormFurnitureWorkPiece : Form
|
||||
{
|
||||
private readonly List<WorkPieceViewModel>? _list;
|
||||
private readonly List<KommentViewModel>? _list;
|
||||
|
||||
public int Id
|
||||
{
|
||||
@ -24,7 +24,7 @@ namespace FurnitureAssemblyView
|
||||
set { comboBoxWorkPiece.SelectedValue = value; }
|
||||
}
|
||||
|
||||
public IWorkPieceModel? WorkPieceModel
|
||||
public IKommentModel? WorkPieceModel
|
||||
{
|
||||
get
|
||||
{
|
||||
@ -54,7 +54,7 @@ namespace FurnitureAssemblyView
|
||||
}
|
||||
}
|
||||
|
||||
public FormFurnitureWorkPiece(IWorkPieceLogic logic)
|
||||
public FormFurnitureWorkPiece(IKommentLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
|
@ -17,9 +17,9 @@ namespace FurnitureAssemblyView
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IFurnitureLogic _logic;
|
||||
private readonly IUsersLogic _logic;
|
||||
|
||||
public FormFurnitures(ILogger<FormFurnitures> logger, IFurnitureLogic logic)
|
||||
public FormFurnitures(ILogger<FormFurnitures> logger, IUsersLogic logic)
|
||||
{
|
||||
|
||||
InitializeComponent();
|
||||
@ -44,7 +44,7 @@ namespace FurnitureAssemblyView
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["FurnitureWorkPieces"].Visible = false;
|
||||
dataGridView.Columns["FurnitureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["UsersName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка изделий");
|
||||
@ -99,7 +99,7 @@ namespace FurnitureAssemblyView
|
||||
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new FurnitureBindingModel
|
||||
if (!_logic.Delete(new UsersBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
|
@ -60,7 +60,7 @@
|
||||
this.buttonCreateOrder.Name = "buttonCreateOrder";
|
||||
this.buttonCreateOrder.Size = new System.Drawing.Size(178, 34);
|
||||
this.buttonCreateOrder.TabIndex = 1;
|
||||
this.buttonCreateOrder.Text = "Создать заказ";
|
||||
this.buttonCreateOrder.Text = "Создать Объявление";
|
||||
this.buttonCreateOrder.UseVisualStyleBackColor = true;
|
||||
this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click);
|
||||
//
|
||||
@ -69,37 +69,37 @@
|
||||
this.buttonTakeOrderInWork.Location = new System.Drawing.Point(820, 65);
|
||||
this.buttonTakeOrderInWork.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
|
||||
this.buttonTakeOrderInWork.Size = new System.Drawing.Size(178, 36);
|
||||
this.buttonTakeOrderInWork.Size = new System.Drawing.Size(178, 56);
|
||||
this.buttonTakeOrderInWork.TabIndex = 2;
|
||||
this.buttonTakeOrderInWork.Text = "Отдать на выполнение";
|
||||
this.buttonTakeOrderInWork.Text = "Доставка (выполнение) объявления";
|
||||
this.buttonTakeOrderInWork.UseVisualStyleBackColor = true;
|
||||
this.buttonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click);
|
||||
//
|
||||
// buttonOrderReady
|
||||
//
|
||||
this.buttonOrderReady.Location = new System.Drawing.Point(820, 105);
|
||||
this.buttonOrderReady.Location = new System.Drawing.Point(820, 125);
|
||||
this.buttonOrderReady.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonOrderReady.Name = "buttonOrderReady";
|
||||
this.buttonOrderReady.Size = new System.Drawing.Size(178, 31);
|
||||
this.buttonOrderReady.TabIndex = 3;
|
||||
this.buttonOrderReady.Text = "Заказ готов";
|
||||
this.buttonOrderReady.Text = "Товар готов";
|
||||
this.buttonOrderReady.UseVisualStyleBackColor = true;
|
||||
this.buttonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click);
|
||||
//
|
||||
// buttonIssuedOrder
|
||||
//
|
||||
this.buttonIssuedOrder.Location = new System.Drawing.Point(820, 140);
|
||||
this.buttonIssuedOrder.Location = new System.Drawing.Point(820, 160);
|
||||
this.buttonIssuedOrder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonIssuedOrder.Name = "buttonIssuedOrder";
|
||||
this.buttonIssuedOrder.Size = new System.Drawing.Size(178, 33);
|
||||
this.buttonIssuedOrder.TabIndex = 4;
|
||||
this.buttonIssuedOrder.Text = "Заказ выдан";
|
||||
this.buttonIssuedOrder.Text = "Товар выдан покупателю";
|
||||
this.buttonIssuedOrder.UseVisualStyleBackColor = true;
|
||||
this.buttonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click);
|
||||
//
|
||||
// buttonRefresh
|
||||
//
|
||||
this.buttonRefresh.Location = new System.Drawing.Point(820, 177);
|
||||
this.buttonRefresh.Location = new System.Drawing.Point(820, 197);
|
||||
this.buttonRefresh.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonRefresh.Name = "buttonRefresh";
|
||||
this.buttonRefresh.Size = new System.Drawing.Size(178, 29);
|
||||
@ -126,21 +126,21 @@
|
||||
this.workPieceToolStripMenuItem,
|
||||
this.furnitureToolStripMenuItem});
|
||||
this.toolStripMenuItem.Name = "toolStripMenuItem";
|
||||
this.toolStripMenuItem.Size = new System.Drawing.Size(94, 20);
|
||||
this.toolStripMenuItem.Text = "Справочники";
|
||||
this.toolStripMenuItem.Size = new System.Drawing.Size(85, 20);
|
||||
this.toolStripMenuItem.Text = "Управление";
|
||||
//
|
||||
// workPieceToolStripMenuItem
|
||||
//
|
||||
this.workPieceToolStripMenuItem.Name = "workPieceToolStripMenuItem";
|
||||
this.workPieceToolStripMenuItem.Size = new System.Drawing.Size(130, 22);
|
||||
this.workPieceToolStripMenuItem.Text = "Заготовки";
|
||||
this.workPieceToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.workPieceToolStripMenuItem.Text = "Комментарии";
|
||||
this.workPieceToolStripMenuItem.Click += new System.EventHandler(this.WorkPieceToolStripMenuItem_Click);
|
||||
//
|
||||
// furnitureToolStripMenuItem
|
||||
//
|
||||
this.furnitureToolStripMenuItem.Name = "furnitureToolStripMenuItem";
|
||||
this.furnitureToolStripMenuItem.Size = new System.Drawing.Size(130, 22);
|
||||
this.furnitureToolStripMenuItem.Text = "Изделия";
|
||||
this.furnitureToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.furnitureToolStripMenuItem.Text = "Пользователи";
|
||||
this.furnitureToolStripMenuItem.Click += new System.EventHandler(this.FurnitureToolStripMenuItem_Click);
|
||||
//
|
||||
// FormMain
|
||||
@ -158,7 +158,7 @@
|
||||
this.MainMenuStrip = this.menuStrip;
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.Name = "FormMain";
|
||||
this.Text = "Сборка мебели";
|
||||
this.Text = "Объявления";
|
||||
this.Load += new System.EventHandler(this.FormMain_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.menuStrip.ResumeLayout(false);
|
||||
|
@ -18,9 +18,9 @@ namespace FurnitureAssemblyView
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IOrderLogic _orderLogic;
|
||||
private readonly IAdLogic _orderLogic;
|
||||
|
||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic)
|
||||
public FormMain(ILogger<FormMain> logger, IAdLogic orderLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
@ -97,7 +97,7 @@ namespace FurnitureAssemblyView
|
||||
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
|
||||
var operationResult = _orderLogic.TakeOrderInWork(new AdBindingModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
@ -126,7 +126,7 @@ namespace FurnitureAssemblyView
|
||||
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
|
||||
var operationResult = _orderLogic.FinishOrder(new AdBindingModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
@ -155,7 +155,7 @@ namespace FurnitureAssemblyView
|
||||
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel
|
||||
var operationResult = _orderLogic.DeliveryOrder(new AdBindingModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
|
@ -10,14 +10,14 @@ namespace FurnitureAssemblyView
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IWorkPieceLogic _logic;
|
||||
private readonly IKommentLogic _logic;
|
||||
|
||||
private int? _id;
|
||||
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
// Êîíñòðóêòîð
|
||||
public FormWorkPiece(ILogger<FormWorkPiece> logger, IWorkPieceLogic logic)
|
||||
public FormWorkPiece(ILogger<FormWorkPiece> logger, IKommentLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
@ -35,7 +35,7 @@ namespace FurnitureAssemblyView
|
||||
{
|
||||
_logger.LogInformation("Ïîëó÷åíèå çàãîòîâêè");
|
||||
|
||||
var view = _logic.ReadElement(new WorkPieceSearchModel { Id = _id.Value });
|
||||
var view = _logic.ReadElement(new KommentSearchModel { Id = _id.Value });
|
||||
|
||||
if(view != null)
|
||||
{
|
||||
@ -67,7 +67,7 @@ namespace FurnitureAssemblyView
|
||||
|
||||
try
|
||||
{
|
||||
var model = new WorkPieceBindingModel
|
||||
var model = new KommentBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
WorkPieceName = textBoxName.Text,
|
||||
|
@ -18,9 +18,9 @@ namespace FurnitureAssemblyView
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IWorkPieceLogic _logic;
|
||||
private readonly IKommentLogic _logic;
|
||||
|
||||
public FormWorkPieces(ILogger<FormWorkPieces> logger, IWorkPieceLogic logic)
|
||||
public FormWorkPieces(ILogger<FormWorkPieces> logger, IKommentLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
@ -101,7 +101,7 @@ namespace FurnitureAssemblyView
|
||||
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new WorkPieceBindingModel
|
||||
if (!_logic.Delete(new KommentBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
|
@ -36,13 +36,13 @@ namespace FurnitureAssemblyView
|
||||
option.AddNLog("nlog.config");
|
||||
});
|
||||
|
||||
services.AddTransient<IWorkPieceStorage, WorkPieceStorage>();
|
||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
services.AddTransient<IFurnitureStorage, FurnitureStorage>();
|
||||
services.AddTransient<IKommentStorage, KommentStorage>();
|
||||
services.AddTransient<IAdStorage, AdStorage>();
|
||||
services.AddTransient<IUsersStorage, UsersStorage>();
|
||||
|
||||
services.AddTransient<IWorkPieceLogic, WorkPieceLogic>();
|
||||
services.AddTransient<IOrderLogic, AdLogic>();
|
||||
services.AddTransient<IFurnitureLogic, FurnitureLogic>();
|
||||
services.AddTransient<IKommentLogic, KommentLogic>();
|
||||
services.AddTransient<IAdLogic, AdLogic>();
|
||||
services.AddTransient<IUsersLogic, UsersLogic>();
|
||||
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormWorkPiece>();
|
||||
|
Loading…
Reference in New Issue
Block a user