Example #1
0
 public InventoryOperation(InventoryOperationType type, Item item, short oldSlot, short currentSlot)
 {
     this.Type        = type;
     this.Item        = item;
     this.OldSlot     = oldSlot;
     this.CurrentSlot = currentSlot;
 }
 private TransactionActionType mapOperationTypeToTransactionActionType(InventoryOperationType operationType)
 {
     switch (operationType)
     {
         case InventoryOperationType.Receipt:
             return TransactionActionType.Receipt;
         case InventoryOperationType.Issue:
             return TransactionActionType.Issue;
         default:
             throw new ArgumentOutOfRangeException("operationType");
     }
 }
        //================================================================================
        private OperationReference findInventoryOperationReference(InventoryDbContext dbContext, InventoryOperationType transactionType, string referenceType, string referenceNumber)
        {
            var foundOperationReference = dbContext.OperationReferences.Where(
                tr =>
                    tr.OperationType == (int)transactionType &&
                    tr.ReferenceType == referenceType &&
                    tr.ReferenceNumber == referenceNumber).ToList().OrderBy(tr => tr.RegistrationDate).LastOrDefault();

            return foundOperationReference;

            if (foundOperationReference != null)
            {
                return foundOperationReference;
            }

            return new OperationReference()
            {
                ReferenceNumber = referenceNumber,
                ReferenceType = referenceType,
                OperationId = INVALID_ID,
                OperationType = (int)transactionType
            };
        }
        //================================================================================
        public Transaction GetTransaction(long transactionId, InventoryOperationType operationType)
        {
            TransactionActionType transactionType = mapOperationTypeToTransactionActionType(operationType);

            using (var dbContext = new InventoryDbContext())
            {
                var foundTransaction = dbContext.Transactions.First(t => t.Id == transactionId && t.Action == (byte)transactionType);

                if (foundTransaction == null)
                    throw new ObjectNotFound("InventoryTransaction", transactionId);

                return foundTransaction;
            }
        }
Example #5
0
 public InventoryOperation(InventoryOperationType type, ItemInventoryType inventory, short slot)
 {
     Type      = type;
     Inventory = inventory;
     Slot      = slot;
 }
Example #6
0
 public AbstractInventoryOperation(InventoryOperationType type, InventoryType inventory, short slot)
 {
     nOperation = type;
     nTI        = inventory;
     nPOS       = slot;
 }