diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ProductLogic.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ProductLogic.cs index 27ef70e..f99298b 100644 --- a/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ProductLogic.cs +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ProductLogic.cs @@ -83,17 +83,24 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic private void CheckModel(ProductBindingModel model, bool withParams = true) { - if (model == null) throw new ArgumentNullException(nameof(model)); - if (!withParams) return; - if (string.IsNullOrEmpty(model.ProductName)) + if (model == null) { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) { + return; + } + if (string.IsNullOrEmpty(model.ProductName)) { throw new ArgumentNullException("Нет названия продукта", nameof(model.ProductName)); - if (model.Price <= 0) + } + if (model.Price <= 0) { throw new ArgumentNullException("Цена продукта должна быть больше 0", nameof(model.Price)); - _logger.LogInformation($"Product. ID:{model.ID}.ProductName:{model.ProductName}.Price:{model.Price}.Count:{model.Count}" + + } + _logger.LogInformation($"Product. ID:{model.ID}.ProductName:{model.ProductName}.Price:{model.Price}" + $".CategoryID:{model.CategoryID}"); var element = _storage.GetElement(new ProductSearchModel { ProductName = model.ProductName }); - if (element != null && element.ID != model.ID) + if (element != null && element.ID != model.ID) { throw new InvalidOperationException("Продукт с таким названием уже есть"); + } } } } diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/UserLogic.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/UserLogic.cs index c043001..70eeff3 100644 --- a/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/UserLogic.cs +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/UserLogic.cs @@ -51,7 +51,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic _logger.LogInformation($"Delete.ID:{model.ID}"); if (_storage.Delete(model) == null) { - _logger.LogWarning("Delete operation failes"); + _logger.LogWarning("Delete operation failed"); return false; } return true; @@ -64,28 +64,28 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic { throw new ArgumentNullException(nameof(model)); } - _logger.LogInformation($"ReadElement: logint:{model.Login}.ID:{model.ID}"); + _logger.LogInformation($"ReadElement.Login:{model.Login}.ID:{model.ID}"); var element = _storage.GetElement(model); if (element == null) { - _logger.LogWarning("ReadElement element not fount"); + _logger.LogWarning("ReadElement. element not fount"); return null; } - _logger.LogInformation($"ReadElement: find.ID:{element.ID}"); + _logger.LogInformation($"ReadElement.find.ID:{element.ID}"); return element; } public List? ReadList(UserSearchModel? model) { - _logger.LogInformation($"ReadList: ClientID:{model?.ID}"); + _logger.LogInformation($"ReadList. ClientID:{model?.ID}"); var list = model == null ? _storage.GetFullList() : _storage.GetFilteredList(model); ; if (list == null) { - _logger.LogWarning("ReadList: return null list"); + _logger.LogWarning("ReadList. return null list"); return null; } - _logger.LogInformation($"ReadList:Count:{list.Count}"); + _logger.LogInformation($"ReadList.Count:{list.Count}"); return list; }