создание статей затрат
This commit is contained in:
parent
e0e54cf872
commit
40faac2b71
@ -10,16 +10,16 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
public class ItemForRepairLogic : IItemForRepairLogic
|
public class ItemForRepairLogic : IItemForRepairLogic
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IItemForRepairStorage _customerStorage;
|
private readonly IItemForRepairStorage _itemForRepairStorage;
|
||||||
public ItemForRepairLogic(ILogger<ItemForRepairLogic> logger, IItemForRepairStorage customerStorage)
|
public ItemForRepairLogic(ILogger<ItemForRepairLogic> logger, IItemForRepairStorage itemForRepairStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_customerStorage = customerStorage;
|
_itemForRepairStorage = itemForRepairStorage;
|
||||||
}
|
}
|
||||||
public List<ItemForRepairViewModel>? ReadList(ItemForRepairSearchModel? model)
|
public List<ItemForRepairViewModel>? ReadList(ItemForRepairSearchModel? model)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||||
var list = model == null ? _customerStorage.GetFullList() : _customerStorage.GetFilteredList(model);
|
var list = model == null ? _itemForRepairStorage.GetFullList() : _itemForRepairStorage.GetFilteredList(model);
|
||||||
if (list == null)
|
if (list == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadList return null list");
|
_logger.LogWarning("ReadList return null list");
|
||||||
@ -35,7 +35,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
}
|
}
|
||||||
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
||||||
var element = _customerStorage.GetElement(model);
|
var element = _itemForRepairStorage.GetElement(model);
|
||||||
if (element == null)
|
if (element == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadElement element not found");
|
_logger.LogWarning("ReadElement element not found");
|
||||||
@ -47,7 +47,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
public bool Create(ItemForRepairBindingModel model)
|
public bool Create(ItemForRepairBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_customerStorage.Insert(model) == null)
|
if (_itemForRepairStorage.Insert(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Insert operation failed");
|
_logger.LogWarning("Insert operation failed");
|
||||||
return false;
|
return false;
|
||||||
@ -57,7 +57,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
public bool Update(ItemForRepairBindingModel model)
|
public bool Update(ItemForRepairBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_customerStorage.Update(model) == null)
|
if (_itemForRepairStorage.Update(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Update operation failed");
|
_logger.LogWarning("Update operation failed");
|
||||||
return false;
|
return false;
|
||||||
@ -68,7 +68,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
CheckModel(model, false);
|
CheckModel(model, false);
|
||||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||||
if (_customerStorage.Delete(model) == null)
|
if (_itemForRepairStorage.Delete(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Delete operation failed");
|
_logger.LogWarning("Delete operation failed");
|
||||||
return false;
|
return false;
|
||||||
|
@ -10,16 +10,16 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
public class ItemLogic : IItemLogic
|
public class ItemLogic : IItemLogic
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IItemStorage _customerStorage;
|
private readonly IItemStorage _itemStorage;
|
||||||
public ItemLogic(ILogger<ItemLogic> logger, IItemStorage customerStorage)
|
public ItemLogic(ILogger<ItemLogic> logger, IItemStorage itemStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_customerStorage = customerStorage;
|
_itemStorage = itemStorage;
|
||||||
}
|
}
|
||||||
public List<ItemViewModel>? ReadList(ItemSearchModel? model)
|
public List<ItemViewModel>? ReadList(ItemSearchModel? model)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||||
var list = model == null ? _customerStorage.GetFullList() : _customerStorage.GetFilteredList(model);
|
var list = model == null ? _itemStorage.GetFullList() : _itemStorage.GetFilteredList(model);
|
||||||
if (list == null)
|
if (list == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadList return null list");
|
_logger.LogWarning("ReadList return null list");
|
||||||
@ -35,7 +35,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
}
|
}
|
||||||
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
||||||
var element = _customerStorage.GetElement(model);
|
var element = _itemStorage.GetElement(model);
|
||||||
if (element == null)
|
if (element == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadElement element not found");
|
_logger.LogWarning("ReadElement element not found");
|
||||||
@ -47,7 +47,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
public bool Create(ItemBindingModel model)
|
public bool Create(ItemBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_customerStorage.Insert(model) == null)
|
if (_itemStorage.Insert(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Insert operation failed");
|
_logger.LogWarning("Insert operation failed");
|
||||||
return false;
|
return false;
|
||||||
@ -57,7 +57,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
public bool Update(ItemBindingModel model)
|
public bool Update(ItemBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_customerStorage.Update(model) == null)
|
if (_itemStorage.Update(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Update operation failed");
|
_logger.LogWarning("Update operation failed");
|
||||||
return false;
|
return false;
|
||||||
@ -68,7 +68,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
CheckModel(model, false);
|
CheckModel(model, false);
|
||||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||||
if (_customerStorage.Delete(model) == null)
|
if (_itemStorage.Delete(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Delete operation failed");
|
_logger.LogWarning("Delete operation failed");
|
||||||
return false;
|
return false;
|
||||||
@ -85,6 +85,25 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
//Заполнено ли название?
|
||||||
|
if (string.IsNullOrEmpty(model.Name))
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Item name is empty");
|
||||||
|
throw new ArgumentException("Не введено название");
|
||||||
|
}
|
||||||
|
//Название уникально?
|
||||||
|
var existingItem = _itemStorage.GetElement(new() { Name = model.Name });
|
||||||
|
if (existingItem != null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Item name is not unique");
|
||||||
|
throw new ArgumentException("Работа с таким названием уже есть");
|
||||||
|
}
|
||||||
|
//Цена больше 0?
|
||||||
|
if (model.Price <= 0)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Work Price is <= 0");
|
||||||
|
throw new ArgumentException("Цена должна быть больше 0");
|
||||||
|
}
|
||||||
_logger.LogInformation("Item. Id: {Id}", model.Id);
|
_logger.LogInformation("Item. Id: {Id}", model.Id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,16 +10,16 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
public class RepairRequestLogic : IRepairRequestLogic
|
public class RepairRequestLogic : IRepairRequestLogic
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IRepairRequestStorage _customerStorage;
|
private readonly IRepairRequestStorage _repairRequestStorage;
|
||||||
public RepairRequestLogic(ILogger<RepairRequestLogic> logger, IRepairRequestStorage customerStorage)
|
public RepairRequestLogic(ILogger<RepairRequestLogic> logger, IRepairRequestStorage repairRequestStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_customerStorage = customerStorage;
|
_repairRequestStorage = repairRequestStorage;
|
||||||
}
|
}
|
||||||
public List<RepairRequestViewModel>? ReadList(RepairRequestSearchModel? model)
|
public List<RepairRequestViewModel>? ReadList(RepairRequestSearchModel? model)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||||
var list = model == null ? _customerStorage.GetFullList() : _customerStorage.GetFilteredList(model);
|
var list = model == null ? _repairRequestStorage.GetFullList() : _repairRequestStorage.GetFilteredList(model);
|
||||||
if (list == null)
|
if (list == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadList return null list");
|
_logger.LogWarning("ReadList return null list");
|
||||||
@ -35,7 +35,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
}
|
}
|
||||||
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
||||||
var element = _customerStorage.GetElement(model);
|
var element = _repairRequestStorage.GetElement(model);
|
||||||
if (element == null)
|
if (element == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadElement element not found");
|
_logger.LogWarning("ReadElement element not found");
|
||||||
@ -47,7 +47,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
public bool Create(RepairRequestBindingModel model)
|
public bool Create(RepairRequestBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_customerStorage.Insert(model) == null)
|
if (_repairRequestStorage.Insert(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Insert operation failed");
|
_logger.LogWarning("Insert operation failed");
|
||||||
return false;
|
return false;
|
||||||
@ -57,7 +57,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
public bool Update(RepairRequestBindingModel model)
|
public bool Update(RepairRequestBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_customerStorage.Update(model) == null)
|
if (_repairRequestStorage.Update(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Update operation failed");
|
_logger.LogWarning("Update operation failed");
|
||||||
return false;
|
return false;
|
||||||
@ -68,7 +68,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
CheckModel(model, false);
|
CheckModel(model, false);
|
||||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||||
if (_customerStorage.Delete(model) == null)
|
if (_repairRequestStorage.Delete(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Delete operation failed");
|
_logger.LogWarning("Delete operation failed");
|
||||||
return false;
|
return false;
|
||||||
|
@ -10,16 +10,16 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
public class VehicleLogic : IVehicleLogic
|
public class VehicleLogic : IVehicleLogic
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IVehicleStorage _customerStorage;
|
private readonly IVehicleStorage _vehicleStorage;
|
||||||
public VehicleLogic(ILogger<VehicleLogic> logger, IVehicleStorage customerStorage)
|
public VehicleLogic(ILogger<VehicleLogic> logger, IVehicleStorage vehicleStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_customerStorage = customerStorage;
|
_vehicleStorage = vehicleStorage;
|
||||||
}
|
}
|
||||||
public List<VehicleViewModel>? ReadList(VehicleSearchModel? model)
|
public List<VehicleViewModel>? ReadList(VehicleSearchModel? model)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||||
var list = model == null ? _customerStorage.GetFullList() : _customerStorage.GetFilteredList(model);
|
var list = model == null ? _vehicleStorage.GetFullList() : _vehicleStorage.GetFilteredList(model);
|
||||||
if (list == null)
|
if (list == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadList return null list");
|
_logger.LogWarning("ReadList return null list");
|
||||||
@ -35,7 +35,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
}
|
}
|
||||||
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
||||||
var element = _customerStorage.GetElement(model);
|
var element = _vehicleStorage.GetElement(model);
|
||||||
if (element == null)
|
if (element == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadElement element not found");
|
_logger.LogWarning("ReadElement element not found");
|
||||||
@ -47,7 +47,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
public bool Create(VehicleBindingModel model)
|
public bool Create(VehicleBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_customerStorage.Insert(model) == null)
|
if (_vehicleStorage.Insert(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Insert operation failed");
|
_logger.LogWarning("Insert operation failed");
|
||||||
return false;
|
return false;
|
||||||
@ -57,7 +57,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
public bool Update(VehicleBindingModel model)
|
public bool Update(VehicleBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_customerStorage.Update(model) == null)
|
if (_vehicleStorage.Update(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Update operation failed");
|
_logger.LogWarning("Update operation failed");
|
||||||
return false;
|
return false;
|
||||||
@ -68,7 +68,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
CheckModel(model, false);
|
CheckModel(model, false);
|
||||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||||
if (_customerStorage.Delete(model) == null)
|
if (_vehicleStorage.Delete(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Delete operation failed");
|
_logger.LogWarning("Delete operation failed");
|
||||||
return false;
|
return false;
|
||||||
|
@ -10,16 +10,16 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
public class WorkInRequestLogic : IWorkInRequestLogic
|
public class WorkInRequestLogic : IWorkInRequestLogic
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IWorkInRequestStorage _customerStorage;
|
private readonly IWorkInRequestStorage _workInRequestStorage;
|
||||||
public WorkInRequestLogic(ILogger<WorkInRequestLogic> logger, IWorkInRequestStorage customerStorage)
|
public WorkInRequestLogic(ILogger<WorkInRequestLogic> logger, IWorkInRequestStorage workInRequestStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_customerStorage = customerStorage;
|
_workInRequestStorage = workInRequestStorage;
|
||||||
}
|
}
|
||||||
public List<WorkInRequestViewModel>? ReadList(WorkInRequestSearchModel? model)
|
public List<WorkInRequestViewModel>? ReadList(WorkInRequestSearchModel? model)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||||
var list = model == null ? _customerStorage.GetFullList() : _customerStorage.GetFilteredList(model);
|
var list = model == null ? _workInRequestStorage.GetFullList() : _workInRequestStorage.GetFilteredList(model);
|
||||||
if (list == null)
|
if (list == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadList return null list");
|
_logger.LogWarning("ReadList return null list");
|
||||||
@ -35,7 +35,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
}
|
}
|
||||||
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
||||||
var element = _customerStorage.GetElement(model);
|
var element = _workInRequestStorage.GetElement(model);
|
||||||
if (element == null)
|
if (element == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadElement element not found");
|
_logger.LogWarning("ReadElement element not found");
|
||||||
@ -47,7 +47,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
public bool Create(WorkInRequestBindingModel model)
|
public bool Create(WorkInRequestBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_customerStorage.Insert(model) == null)
|
if (_workInRequestStorage.Insert(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Insert operation failed");
|
_logger.LogWarning("Insert operation failed");
|
||||||
return false;
|
return false;
|
||||||
@ -57,7 +57,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
public bool Update(WorkInRequestBindingModel model)
|
public bool Update(WorkInRequestBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_customerStorage.Update(model) == null)
|
if (_workInRequestStorage.Update(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Update operation failed");
|
_logger.LogWarning("Update operation failed");
|
||||||
return false;
|
return false;
|
||||||
@ -68,7 +68,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
CheckModel(model, false);
|
CheckModel(model, false);
|
||||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||||
if (_customerStorage.Delete(model) == null)
|
if (_workInRequestStorage.Delete(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Delete operation failed");
|
_logger.LogWarning("Delete operation failed");
|
||||||
return false;
|
return false;
|
||||||
|
@ -11,10 +11,10 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IWorkStorage _workStorage;
|
private readonly IWorkStorage _workStorage;
|
||||||
public WorkLogic(ILogger<WorkLogic> logger, IWorkStorage customerStorage)
|
public WorkLogic(ILogger<WorkLogic> logger, IWorkStorage workStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_workStorage = customerStorage;
|
_workStorage = workStorage;
|
||||||
}
|
}
|
||||||
public List<WorkViewModel>? ReadList(WorkSearchModel? model)
|
public List<WorkViewModel>? ReadList(WorkSearchModel? model)
|
||||||
{
|
{
|
||||||
|
@ -10,16 +10,16 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
public class WorkPaymentLogic : IWorkPaymentLogic
|
public class WorkPaymentLogic : IWorkPaymentLogic
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IWorkPaymentStorage _customerStorage;
|
private readonly IWorkPaymentStorage _workPaymentStorage;
|
||||||
public WorkPaymentLogic(ILogger<WorkPaymentLogic> logger, IWorkPaymentStorage customerStorage)
|
public WorkPaymentLogic(ILogger<WorkPaymentLogic> logger, IWorkPaymentStorage workPaymentStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_customerStorage = customerStorage;
|
_workPaymentStorage = workPaymentStorage;
|
||||||
}
|
}
|
||||||
public List<WorkPaymentViewModel>? ReadList(WorkPaymentSearchModel? model)
|
public List<WorkPaymentViewModel>? ReadList(WorkPaymentSearchModel? model)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||||
var list = model == null ? _customerStorage.GetFullList() : _customerStorage.GetFilteredList(model);
|
var list = model == null ? _workPaymentStorage.GetFullList() : _workPaymentStorage.GetFilteredList(model);
|
||||||
if (list == null)
|
if (list == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadList return null list");
|
_logger.LogWarning("ReadList return null list");
|
||||||
@ -35,7 +35,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
}
|
}
|
||||||
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
||||||
var element = _customerStorage.GetElement(model);
|
var element = _workPaymentStorage.GetElement(model);
|
||||||
if (element == null)
|
if (element == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadElement element not found");
|
_logger.LogWarning("ReadElement element not found");
|
||||||
@ -47,7 +47,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
public bool Create(WorkPaymentBindingModel model)
|
public bool Create(WorkPaymentBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_customerStorage.Insert(model) == null)
|
if (_workPaymentStorage.Insert(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Insert operation failed");
|
_logger.LogWarning("Insert operation failed");
|
||||||
return false;
|
return false;
|
||||||
@ -57,7 +57,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
public bool Update(WorkPaymentBindingModel model)
|
public bool Update(WorkPaymentBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_customerStorage.Update(model) == null)
|
if (_workPaymentStorage.Update(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Update operation failed");
|
_logger.LogWarning("Update operation failed");
|
||||||
return false;
|
return false;
|
||||||
@ -68,7 +68,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
CheckModel(model, false);
|
CheckModel(model, false);
|
||||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||||
if (_customerStorage.Delete(model) == null)
|
if (_workPaymentStorage.Delete(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Delete operation failed");
|
_logger.LogWarning("Delete operation failed");
|
||||||
return false;
|
return false;
|
||||||
|
@ -3,5 +3,6 @@
|
|||||||
public class ItemSearchModel
|
public class ItemSearchModel
|
||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
|
public string? Name { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,5 +13,7 @@ namespace CarServiceContracts.ViewModels
|
|||||||
[DisplayName("Количество")]
|
[DisplayName("Количество")]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
public int WorkerId { get; set; }
|
public int WorkerId { get; set; }
|
||||||
|
[DisplayName("Сотрудник")]
|
||||||
|
public string WorkerName { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
87
CarService/CarServiceDatabase/Implements/ItemStorage.cs
Normal file
87
CarService/CarServiceDatabase/Implements/ItemStorage.cs
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
using CarServiceContracts.BindingModels;
|
||||||
|
using CarServiceContracts.SearchModels;
|
||||||
|
using CarServiceContracts.StorageContracts;
|
||||||
|
using CarServiceContracts.ViewModels;
|
||||||
|
using CarServiceDatabase.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace CarServiceDatabase.Implements
|
||||||
|
{
|
||||||
|
public class ItemStorage : IItemStorage
|
||||||
|
{
|
||||||
|
public List<ItemViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new CarServiceDbContext();
|
||||||
|
return context.Items
|
||||||
|
.Include(x => x.Worker)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
public List<ItemViewModel> GetFilteredList(ItemSearchModel model)
|
||||||
|
{
|
||||||
|
using var context = new CarServiceDbContext();
|
||||||
|
return context.Items
|
||||||
|
.Where(x => x.Id == model.Id)
|
||||||
|
.Include(x => x.Worker)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
public ItemViewModel? GetElement(ItemSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new CarServiceDbContext();
|
||||||
|
if (model.Id.HasValue)//сначала ищем по Id
|
||||||
|
{
|
||||||
|
return context.Items
|
||||||
|
.Include(x => x.Worker)
|
||||||
|
.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(model.Name))//затем по названию
|
||||||
|
{
|
||||||
|
return context.Items
|
||||||
|
.Include(x => x.Worker)
|
||||||
|
.FirstOrDefault(x => x.Name == model.Name)?.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public ItemViewModel? Insert(ItemBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new CarServiceDbContext();
|
||||||
|
var newItem = Item.Create(context, model);
|
||||||
|
if (newItem != null)
|
||||||
|
{
|
||||||
|
context.Items.Add(newItem);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newItem.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public ItemViewModel? Update(ItemBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new CarServiceDbContext();
|
||||||
|
var item = context.Items.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (item == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
item.Update(context, model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return item.GetViewModel;
|
||||||
|
}
|
||||||
|
public ItemViewModel? Delete(ItemBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new CarServiceDbContext();
|
||||||
|
var item = context.Items.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (item == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
context.Items.Remove(item);
|
||||||
|
context.SaveChanges();
|
||||||
|
return item.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -23,7 +23,7 @@ namespace CarServiceDatabase.Models
|
|||||||
[ForeignKey("ItemId")]
|
[ForeignKey("ItemId")]
|
||||||
public virtual List<ItemForRepair> ItemsForRepair { get; set; } = new();
|
public virtual List<ItemForRepair> ItemsForRepair { get; set; } = new();
|
||||||
public virtual Worker Worker { get; set; } = new();
|
public virtual Worker Worker { get; set; } = new();
|
||||||
public static Item? Create(ItemBindingModel? model)
|
public static Item? Create(CarServiceDbContext context, ItemBindingModel? model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
@ -35,10 +35,10 @@ namespace CarServiceDatabase.Models
|
|||||||
Name = model.Name,
|
Name = model.Name,
|
||||||
Price = model.Price,
|
Price = model.Price,
|
||||||
Count = model.Count,
|
Count = model.Count,
|
||||||
WorkerId = model.WorkerId
|
Worker = context.Workers.First(x => x.Id == model.WorkerId)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public static Item Create(ItemViewModel model)
|
public static Item Create(CarServiceDbContext context, ItemViewModel model)
|
||||||
{
|
{
|
||||||
return new()
|
return new()
|
||||||
{
|
{
|
||||||
@ -46,10 +46,10 @@ namespace CarServiceDatabase.Models
|
|||||||
Name = model.Name,
|
Name = model.Name,
|
||||||
Price = model.Price,
|
Price = model.Price,
|
||||||
Count = model.Count,
|
Count = model.Count,
|
||||||
WorkerId = model.WorkerId
|
Worker = context.Workers.First(x => x.Id == model.WorkerId)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public void Update(ItemBindingModel? model)
|
public void Update(CarServiceDbContext context, ItemBindingModel? model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
@ -59,7 +59,7 @@ namespace CarServiceDatabase.Models
|
|||||||
Name = model.Name;
|
Name = model.Name;
|
||||||
Price = model.Price;
|
Price = model.Price;
|
||||||
Count = model.Count;
|
Count = model.Count;
|
||||||
WorkerId = model.WorkerId;
|
Worker = context.Workers.First(x => x.Id == model.WorkerId);
|
||||||
}
|
}
|
||||||
public ItemViewModel GetViewModel => new()
|
public ItemViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
@ -67,7 +67,8 @@ namespace CarServiceDatabase.Models
|
|||||||
Name = Name,
|
Name = Name,
|
||||||
Price = Price,
|
Price = Price,
|
||||||
Count = Count,
|
Count = Count,
|
||||||
WorkerId = WorkerId
|
WorkerId = WorkerId,
|
||||||
|
WorkerName = Worker.Name + " " + Worker.Surname
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
127
CarService/CarServiceView/FormAddItemTest.Designer.cs
generated
Normal file
127
CarService/CarServiceView/FormAddItemTest.Designer.cs
generated
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
namespace CarServiceView
|
||||||
|
{
|
||||||
|
partial class FormAddItemTest
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
this.buttonAdd = new System.Windows.Forms.Button();
|
||||||
|
this.label3 = new System.Windows.Forms.Label();
|
||||||
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||||
|
this.textBoxPrice = new System.Windows.Forms.TextBox();
|
||||||
|
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
this.buttonAdd.Location = new System.Drawing.Point(36, 125);
|
||||||
|
this.buttonAdd.Name = "buttonAdd";
|
||||||
|
this.buttonAdd.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonAdd.TabIndex = 9;
|
||||||
|
this.buttonAdd.Text = "Добавить";
|
||||||
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
this.label3.AutoSize = true;
|
||||||
|
this.label3.Location = new System.Drawing.Point(12, 67);
|
||||||
|
this.label3.Name = "label3";
|
||||||
|
this.label3.Size = new System.Drawing.Size(72, 15);
|
||||||
|
this.label3.TabIndex = 6;
|
||||||
|
this.label3.Text = "Количество";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
this.label2.AutoSize = true;
|
||||||
|
this.label2.Location = new System.Drawing.Point(12, 38);
|
||||||
|
this.label2.Name = "label2";
|
||||||
|
this.label2.Size = new System.Drawing.Size(35, 15);
|
||||||
|
this.label2.TabIndex = 7;
|
||||||
|
this.label2.Text = "Цена";
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.AutoSize = true;
|
||||||
|
this.label1.Location = new System.Drawing.Point(12, 9);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(90, 15);
|
||||||
|
this.label1.TabIndex = 8;
|
||||||
|
this.label1.Text = "Наименование";
|
||||||
|
//
|
||||||
|
// textBoxCount
|
||||||
|
//
|
||||||
|
this.textBoxCount.Location = new System.Drawing.Point(108, 64);
|
||||||
|
this.textBoxCount.Name = "textBoxCount";
|
||||||
|
this.textBoxCount.Size = new System.Drawing.Size(100, 23);
|
||||||
|
this.textBoxCount.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// textBoxPrice
|
||||||
|
//
|
||||||
|
this.textBoxPrice.Location = new System.Drawing.Point(108, 35);
|
||||||
|
this.textBoxPrice.Name = "textBoxPrice";
|
||||||
|
this.textBoxPrice.Size = new System.Drawing.Size(100, 23);
|
||||||
|
this.textBoxPrice.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// textBoxName
|
||||||
|
//
|
||||||
|
this.textBoxName.Location = new System.Drawing.Point(108, 6);
|
||||||
|
this.textBoxName.Name = "textBoxName";
|
||||||
|
this.textBoxName.Size = new System.Drawing.Size(100, 23);
|
||||||
|
this.textBoxName.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// FormAddItemTest
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Controls.Add(this.buttonAdd);
|
||||||
|
this.Controls.Add(this.label3);
|
||||||
|
this.Controls.Add(this.label2);
|
||||||
|
this.Controls.Add(this.label1);
|
||||||
|
this.Controls.Add(this.textBoxCount);
|
||||||
|
this.Controls.Add(this.textBoxPrice);
|
||||||
|
this.Controls.Add(this.textBoxName);
|
||||||
|
this.Name = "FormAddItemTest";
|
||||||
|
this.Text = "FormAddItemTest";
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Label label3;
|
||||||
|
private Label label2;
|
||||||
|
private Label label1;
|
||||||
|
private TextBox textBoxCount;
|
||||||
|
private TextBox textBoxPrice;
|
||||||
|
private TextBox textBoxName;
|
||||||
|
}
|
||||||
|
}
|
25
CarService/CarServiceView/FormAddItemTest.cs
Normal file
25
CarService/CarServiceView/FormAddItemTest.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using CarServiceContracts.BusinessLogicsContracts;
|
||||||
|
|
||||||
|
namespace CarServiceView
|
||||||
|
{
|
||||||
|
public partial class FormAddItemTest : Form
|
||||||
|
{
|
||||||
|
IItemLogic _itemLogic;
|
||||||
|
public FormAddItemTest(IItemLogic itemLogic)
|
||||||
|
{
|
||||||
|
_itemLogic = itemLogic;
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_itemLogic.Create(new()
|
||||||
|
{
|
||||||
|
Name = textBoxName.Text,
|
||||||
|
Price = Convert.ToDecimal(textBoxPrice.Text),
|
||||||
|
Count = Convert.ToInt32(textBoxCount.Text),
|
||||||
|
WorkerId = 1
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
CarService/CarServiceView/FormAddItemTest.resx
Normal file
60
CarService/CarServiceView/FormAddItemTest.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<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>
|
107
CarService/CarServiceView/FormItemTest.Designer.cs
generated
Normal file
107
CarService/CarServiceView/FormItemTest.Designer.cs
generated
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
namespace CarServiceView
|
||||||
|
{
|
||||||
|
partial class FormItemTest
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
this.menuStrip = new System.Windows.Forms.MenuStrip();
|
||||||
|
this.addToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.updateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
this.menuStrip.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// menuStrip
|
||||||
|
//
|
||||||
|
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.addToolStripMenuItem,
|
||||||
|
this.updateToolStripMenuItem,
|
||||||
|
this.deleteToolStripMenuItem});
|
||||||
|
this.menuStrip.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.menuStrip.Name = "menuStrip";
|
||||||
|
this.menuStrip.Size = new System.Drawing.Size(800, 24);
|
||||||
|
this.menuStrip.TabIndex = 5;
|
||||||
|
this.menuStrip.Text = "menuStrip1";
|
||||||
|
//
|
||||||
|
// addToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.addToolStripMenuItem.Name = "addToolStripMenuItem";
|
||||||
|
this.addToolStripMenuItem.Size = new System.Drawing.Size(71, 20);
|
||||||
|
this.addToolStripMenuItem.Text = "Добавить";
|
||||||
|
this.addToolStripMenuItem.Click += new System.EventHandler(this.addToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// updateToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.updateToolStripMenuItem.Name = "updateToolStripMenuItem";
|
||||||
|
this.updateToolStripMenuItem.Size = new System.Drawing.Size(73, 20);
|
||||||
|
this.updateToolStripMenuItem.Text = "Изменить";
|
||||||
|
//
|
||||||
|
// deleteToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
|
||||||
|
this.deleteToolStripMenuItem.Size = new System.Drawing.Size(63, 20);
|
||||||
|
this.deleteToolStripMenuItem.Text = "Удалить";
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
|
||||||
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView.Location = new System.Drawing.Point(0, 27);
|
||||||
|
this.dataGridView.Name = "dataGridView";
|
||||||
|
this.dataGridView.RowTemplate.Height = 25;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(798, 421);
|
||||||
|
this.dataGridView.TabIndex = 6;
|
||||||
|
//
|
||||||
|
// FormItemTest
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Controls.Add(this.dataGridView);
|
||||||
|
this.Controls.Add(this.menuStrip);
|
||||||
|
this.Name = "FormItemTest";
|
||||||
|
this.Text = "FormItemTest";
|
||||||
|
this.Load += new System.EventHandler(this.FormItemTest_Load);
|
||||||
|
this.menuStrip.ResumeLayout(false);
|
||||||
|
this.menuStrip.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private MenuStrip menuStrip;
|
||||||
|
private ToolStripMenuItem addToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem updateToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem deleteToolStripMenuItem;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
33
CarService/CarServiceView/FormItemTest.cs
Normal file
33
CarService/CarServiceView/FormItemTest.cs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
using CarServiceBusinessLogic.BusinessLogics;
|
||||||
|
using CarServiceContracts.BusinessLogicsContracts;
|
||||||
|
|
||||||
|
namespace CarServiceView
|
||||||
|
{
|
||||||
|
public partial class FormItemTest : Form
|
||||||
|
{
|
||||||
|
IItemLogic _itemLogic;
|
||||||
|
public FormItemTest(IItemLogic itemLogic)
|
||||||
|
{
|
||||||
|
_itemLogic = itemLogic;
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
private void addToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormAddItemTest));
|
||||||
|
if (service is FormAddItemTest form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
var list = _itemLogic.ReadList(null);
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
}
|
||||||
|
private void FormItemTest_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
63
CarService/CarServiceView/FormItemTest.resx
Normal file
63
CarService/CarServiceView/FormItemTest.resx
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<root>
|
||||||
|
<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>
|
||||||
|
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
@ -87,7 +87,7 @@
|
|||||||
this.Controls.Add(this.menuStrip);
|
this.Controls.Add(this.menuStrip);
|
||||||
this.Controls.Add(this.dataGridView);
|
this.Controls.Add(this.dataGridView);
|
||||||
this.Name = "FormWorkTest";
|
this.Name = "FormWorkTest";
|
||||||
this.Text = "FormGridViewTest";
|
this.Text = "FormWorkTest";
|
||||||
this.Load += new System.EventHandler(this.FormWorkTest_Load);
|
this.Load += new System.EventHandler(this.FormWorkTest_Load);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
this.menuStrip.ResumeLayout(false);
|
this.menuStrip.ResumeLayout(false);
|
||||||
|
@ -19,7 +19,7 @@ namespace CarServiceView
|
|||||||
var services = new ServiceCollection();
|
var services = new ServiceCollection();
|
||||||
ConfigureServices(services);
|
ConfigureServices(services);
|
||||||
_serviceProvider = services.BuildServiceProvider();
|
_serviceProvider = services.BuildServiceProvider();
|
||||||
Application.Run(_serviceProvider.GetRequiredService<FormWorkTest>());
|
Application.Run(_serviceProvider.GetRequiredService<FormItemTest>());
|
||||||
}
|
}
|
||||||
private static void ConfigureServices(ServiceCollection services)
|
private static void ConfigureServices(ServiceCollection services)
|
||||||
{
|
{
|
||||||
@ -28,10 +28,6 @@ namespace CarServiceView
|
|||||||
option.SetMinimumLevel(LogLevel.Information);
|
option.SetMinimumLevel(LogLevel.Information);
|
||||||
option.AddNLog("nlog.config");
|
option.AddNLog("nlog.config");
|
||||||
});
|
});
|
||||||
//services.AddTransient<IComponentStorage, ComponentStorage>();
|
|
||||||
//services.AddTransient<IOrderStorage, OrderStorage>();
|
|
||||||
//services.AddTransient<IManufactureStorage, ManufactureStorage>();
|
|
||||||
//services.AddTransient<IClientStorage, ClientStorage>();
|
|
||||||
services.AddTransient<ICustomerLogic, CustomerLogic>();
|
services.AddTransient<ICustomerLogic, CustomerLogic>();
|
||||||
services.AddTransient<IItemForRepairLogic, ItemForRepairLogic>();
|
services.AddTransient<IItemForRepairLogic, ItemForRepairLogic>();
|
||||||
services.AddTransient<IItemLogic, ItemLogic>();
|
services.AddTransient<IItemLogic, ItemLogic>();
|
||||||
@ -44,10 +40,13 @@ namespace CarServiceView
|
|||||||
|
|
||||||
services.AddTransient<IWorkerStorage, WorkerStorage>();
|
services.AddTransient<IWorkerStorage, WorkerStorage>();
|
||||||
services.AddTransient<IWorkStorage, WorkStorage>();
|
services.AddTransient<IWorkStorage, WorkStorage>();
|
||||||
|
services.AddTransient<IItemStorage, ItemStorage>();
|
||||||
|
|
||||||
services.AddTransient<FormRegistrationWorker>();
|
services.AddTransient<FormRegistrationWorker>();
|
||||||
services.AddTransient<FormWorkTest>();
|
services.AddTransient<FormWorkTest>();
|
||||||
services.AddTransient<FormAddWorkTest>();
|
services.AddTransient<FormAddWorkTest>();
|
||||||
|
services.AddTransient<FormItemTest>();
|
||||||
|
services.AddTransient<FormAddItemTest>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user