private void addNewBatch(Entities.Transaction transaction, Entities.MaterialType materialType, Entities.LoadingPosition loadingPosition, string username)
        {
            string transactionId  = transaction.Id;
            int    materialTypeId = materialType.Id;
            var    batch          = new Entities.Batch
            {
                Id              = new Random().Next(1, 100000),
                MaterialTypeId  = materialTypeId,
                MaterialType    = materialType,
                LoadingPosition = loadingPosition,
                StartedAt       = DateTime.Now,
                StartedBy       = username,
                StoppedAt       = null,
                StoppedBy       = null,
                TransactionId   = transactionId,
                Transaction     = transaction
            };

            transaction.Batches.Add(batch);
        }
Beispiel #2
0
        public void AddNewBatch(BatchNew model)
        {
            // TODO: Refactor - Create enum for reason ids
            // TODO: Add in foreign keys so items can be added by id instead of having to be looked up in services
            var batchUpdateReason = _unitOfWork.BatchUpdateReasonRepository.Get(1).Result;
            var product           = _unitOfWork.ProductRepository.Get(model.ProductId).Result;

            // idealy use an auto-mapper
            var batch = new Entities.Batch
            {
                ExpirationDate = model.ExpirationDate,
                ExpiringTime   = model.ExpiringTime,
                CheckedInDate  = model.CheckedInDate,
                Product        = product
            };

            batch.BatchItems.Add(new Entities.BatchItem
            {
                BatchUpdateReason = batchUpdateReason,
                Quantity          = model.Quantity
            });

            _unitOfWork.BatchRepository.Add(batch);
        }