public void Execute(CreateInventorySerialsCommand command)
        {
            _log.InfoFormat("Execute {1} - Command Id {0} ", command.CommandId, command.GetType().ToString());

            try
            {
                List<string> fromToList = command.CSVFromToList.Split(',').ToList();

                foreach (var item in fromToList)
                {
                    string[] fromTo = item.Split('-');
                    InventorySerials invSerials = new InventorySerials(command.EntityId)
                                                      {
                                                          CostCentreRef = new CostCentreRef {Id = command.RecipientCostCentreId},
                                                          DocumentId = command.DocumentId,
                                                          ProductRef = new ProductRef {ProductId = command.ProductId},
                                                          From = fromTo[0].Trim(),
                                                          To = fromTo[1].Trim()
                                                      };

                    _inventorySerialsRepository.AddInventorySerial(invSerials);
                }
            }
            catch(Exception ex)
            {
                _log.ErrorFormat("Error Execute {1} - Command Id {0} ", command.CommandId, command.GetType().ToString());
                _log.Error("CreateInventorySerialsCommandHandler exception",ex);
                throw ;
            }
        }
Esempio n. 2
0
        private void SaveInventorySerials(MasterBaseDTO masterbaseDTO)
        {
            InventorySerialsDTO inventorySerialsDTO = masterbaseDTO as InventorySerialsDTO;
            List<string> fromToList = inventorySerialsDTO.CSVFromToSerials.Split(',').ToList();

            foreach (var item in fromToList.Where(n => n.Trim() != ""))
            {
                string[] fromTo = item.Split('-');
                InventorySerials invSerials = new InventorySerials(Guid.NewGuid())
                {
                    CostCentreRef = new CostCentreRef { Id = inventorySerialsDTO.CostCentreMasterId },
                    ProductRef = new ProductRef { ProductId = inventorySerialsDTO.ProductMasterId },
                    DocumentId = inventorySerialsDTO.DocumentId,
                    From = fromTo[0].Trim(),
                    To = fromTo[1].Trim()
                };

                _inventorySerialsRepository.AddInventorySerial(invSerials);
            }
        }