예제 #1
0
        public IList <BusinessModels.Order> GetAll()
        {
            _logger.LogInformation($"{typeof(InMemoryOrderRepositoryAdapter).FullName}.GetAll()");

            try
            {
                var result = new List <BusinessModels.Order>();

                IList <EntityModels.InMemory.Order> orderEntities = _orderRepository.GetAll();


                foreach (var orderEntity in orderEntities)
                {
                    EntityModels.InMemory.Inventory inventoryEntity = _inventoryRepository.GetById(orderEntity.InventoryId);
                    EntityModels.InMemory.Article   articleEntity   = _articleRepository.GetById(inventoryEntity.ArticleId);
                    EntityModels.InMemory.Buyer     buyerEntity     = _buyerRepository.GetById(orderEntity.BuyerId);

                    BusinessModels.Order order = CreateBusinessModel(orderEntity, articleEntity, inventoryEntity, buyerEntity);

                    result.Add(order);
                }

                return(result);
            }
            catch (LoggedException)
            {
                throw;
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                throw new LoggedException("Logged exception", ex);
            }
        }
예제 #2
0
        public void DecreaseArticleQuantity(long inventoryId)
        {
            _logger.LogInformation($"{typeof(InMemorySupplierRepositoryAdapter).FullName}.DecreaseArticleQuantity(inventoryId={inventoryId})");

            try
            {
                EntityModels.InMemory.Inventory inventoryEntity = _inventoryRepository.GetById(inventoryId);

                inventoryEntity.Quantity--;

                _inventoryRepository.Update(inventoryEntity);
            }
            catch (LoggedException)
            {
                throw;
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                throw new LoggedException("Logged exception", ex);
            }
        }