private async Task ProcessItemAdjustmentAsync(long itemId, int quantity, AdjustmentType adjustmentType, QuantityType quantityType = QuantityType.Both)
        {
            var item = await context.Items.FindAsync(itemId);

            if (item == null)
            {
                throw new ArgumentException("Item does not exist.");
            }

            switch (quantityType)
            {
            case QuantityType.Quantity:
                AdjustQuantity(item, adjustmentType, quantity);
                break;

            case QuantityType.StockQuantity:
                AdjustStockQuantity(item, adjustmentType, quantity);
                break;

            case QuantityType.Both:
                AdjustQuantity(item, adjustmentType, quantity);
                AdjustStockQuantity(item, adjustmentType, quantity);
                break;
            }

            if (item.Quantity < 0)
            {
                throw new QuantityBelowZeroException("Insufficient quantity.");
            }

            context.Entry(item).State = EntityState.Modified;
        }
 /// <inheritdoc />
 public void CheckItemsForDeletion <T, T1>(IEnumerable <T> originalList, IEnumerable <T1> updatedList)
     where T : ModelBase
     where T1 : DTOBase
 {
     foreach (var item in originalList)
     {
         if (!updatedList.Any(a => a.Id == item.Id))
         {
             logger.LogInformation($"Marking {item.GetType()} with id # {item.Id} for deletion.");
             context.Entry(item).State = EntityState.Deleted;
         }
     }
 }