Eliseev E.E. LabWork01 #1
@ -8,6 +8,12 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BlacksmithWorkshopBusinessLogic\BlacksmithWorkshopBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\BlacksmithWorkshopContracts\BlacksmithWorkshopContracts.csproj" />
|
||||
|
@ -46,7 +46,7 @@ namespace BlacksmithWorkshop
|
||||
{
|
||||
int id = Convert.ToInt32(comboBoxManufacture.SelectedValue);
|
||||
|
||||
var manufacture = _logicA.ReadManufacture(new ManufactureSearchModel
|
||||
var manufacture = _logicA.ReadElement(new ManufactureSearchModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
|
@ -44,7 +44,7 @@ namespace BlacksmithWorkshop
|
||||
|
||||
try
|
||||
{
|
||||
var view = _logic.ReadManufacture(new ManufactureSearchModel { Id = _id.Value });
|
||||
var view = _logic.ReadElement(new ManufactureSearchModel { Id = _id.Value });
|
||||
|
||||
if(view != null)
|
||||
{
|
||||
|
@ -49,6 +49,7 @@ namespace BlacksmithWorkshop
|
||||
services.AddTransient<FormWorkPieces>();
|
||||
services.AddTransient<FormCreateOrder>();
|
||||
services.AddTransient<FormManufacture>();
|
||||
services.AddTransient<FormManufactures>();
|
||||
services.AddTransient<FormManufactureWorkPiece>();
|
||||
}
|
||||
|
||||
|
@ -19,10 +19,10 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
private readonly IManufactureStorage _manufactureStorage;
|
||||
|
||||
//конструктор
|
||||
public ManufactureLogic(ILogger<ManufactureLogic> logger, IManufactureStorage productStorage)
|
||||
public ManufactureLogic(ILogger<ManufactureLogic> logger, IManufactureStorage manufactureStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_manufactureStorage = productStorage;
|
||||
_manufactureStorage = manufactureStorage;
|
||||
}
|
||||
|
||||
//вывод отфильтрованного списка
|
||||
@ -36,6 +36,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
if(list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -45,24 +46,25 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
}
|
||||
|
||||
//вывод конкретного изделия
|
||||
public ManufactureViewModel? ReadManufacture(ManufactureSearchModel model)
|
||||
public ManufactureViewModel? ReadElement(ManufactureSearchModel model)
|
||||
{
|
||||
if(model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadManufacture. ManufactureName:{ManufactureName}. Id:{Id}", model.ManufactureName, model.Id);
|
||||
_logger.LogInformation("ReadElement. ManufactureName:{ManufactureName}. Id:{Id}", model.ManufactureName, model.Id);
|
||||
|
||||
var element = _manufactureStorage.GetElement(model);
|
||||
|
||||
if(element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadManufacture element not found");
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadManufacture find. Id:{Id}", model.Id);
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", model.Id);
|
||||
|
||||
return element;
|
||||
}
|
||||
@ -75,6 +77,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
if(_manufactureStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Create operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -98,11 +101,14 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
//удаление изделия
|
||||
public bool Delete(ManufactureBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
CheckModel(model, false);
|
||||
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
|
||||
if(_manufactureStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -117,7 +123,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
//если без параметров?
|
||||
//так как при удалении параметром withParams передаём false
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
@ -144,6 +150,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
ManufactureName = model.ManufactureName,
|
||||
});
|
||||
|
||||
//если элемент найден и его Id не совпадает с Id объекта, переданного на вход
|
||||
if(element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Изделие с таким названием уже есть");
|
||||
|
@ -37,6 +37,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
if(list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -91,8 +92,8 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
//если без параметров?
|
||||
if(!withParams)
|
||||
//так как при удалении параметром withParams передаём false
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
{
|
||||
//класс, реализующий логику для компонентов
|
||||
//класс, реализующий логику для заготовок
|
||||
public class WorkPieceLogic : IWorkPieceLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
@ -60,6 +60,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
if(element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -76,6 +77,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
if(_workPieceStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -90,6 +92,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
if(_workPieceStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -99,11 +102,14 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
//удаление заготовки
|
||||
public bool Delete(WorkPieceBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
CheckModel(model, false);
|
||||
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
|
||||
if (_workPieceStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -118,7 +124,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
//если без параметров?
|
||||
//так как при удалении передаём как параметр false
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
@ -144,6 +150,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
WorkPieceName = model.WorkPieceName,
|
||||
});
|
||||
|
||||
//если элемент найден и его Id не совпадает с Id переданного объекта
|
||||
if(element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Заготовка с таким названием уже есть");
|
||||
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.BindingModels
|
||||
{
|
||||
//реализация сущности "Продукт"
|
||||
//реализация сущности "Изделие"
|
||||
public class ManufactureBindingModel : IManufactureModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
@ -12,8 +12,8 @@ namespace BlacksmithWorkshopContracts.BindingModels
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public double Cost { get; set; }
|
||||
|
||||
public string WorkPieceName { get; set; } = string.Empty;
|
||||
|
||||
public double Cost { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ namespace BlacksmithWorkshopContracts.BusinessLogicsContracts
|
||||
{
|
||||
List<ManufactureViewModel>? ReadList(ManufactureSearchModel? model);
|
||||
|
||||
ManufactureViewModel? ReadManufacture(ManufactureSearchModel model);
|
||||
ManufactureViewModel? ReadElement(ManufactureSearchModel model);
|
||||
|
||||
bool Create(ManufactureBindingModel model);
|
||||
|
||||
|
@ -27,10 +27,10 @@ namespace BlacksmithWorkshopContracts.ViewModels
|
||||
public double Sum { get; set; }
|
||||
|
||||
[DisplayName("Статус")]
|
||||
public OrderStatus Status { get; set; }
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
|
||||
[DisplayName("Дата создания")]
|
||||
public DateTime DateCreate { get; set; }
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
|
||||
[DisplayName("Дата выполнения")]
|
||||
public DateTime? DateImplement { get; set; }
|
||||
|
Loading…
Reference in New Issue
Block a user