public void SubmitChanges(CommodityReleaseNote document)
        {
            var commandsToExecute = document.GetDocumentCommandsToExecute();

            var createCommand = commandsToExecute.OfType<CreateCommand>().FirstOrDefault();

            if (createCommand != null)
            {
                AddToMongoDB(createCommand);
                _busPublisher.WrapAndPublish(createCommand,
                                             (CommandType)
                                             Enum.Parse(typeof(CommandType), createCommand.CommandTypeRef));

            }

            var lineItemCommands = commandsToExecute.OfType<AfterCreateCommand>();
            foreach (var _item in lineItemCommands)
            {
                AddToMongoDB(_item);
                _busPublisher.WrapAndPublish(_item, (CommandType)Enum.Parse(typeof(CommandType), _item.CommandTypeRef));


            }

            var confirmCommodityReleaseCommand = commandsToExecute.OfType<ConfirmCommodityReleaseNoteCommand>().FirstOrDefault();
            if (confirmCommodityReleaseCommand != null)
            {
                AddToMongoDB(confirmCommodityReleaseCommand);
                _busPublisher.WrapAndPublish(confirmCommodityReleaseCommand, (CommandType)Enum.Parse(typeof(CommandType), confirmCommodityReleaseCommand.CommandTypeRef));
            }
        }
        public void SubmitChanges(CommodityReleaseNote document)
        {
            int sequence = 0;
            var envelope = new CommandEnvelope();
            envelope.Initialize(document);
            var commandsToExecute = document.GetDocumentCommandsToExecute();

            var createCommand = commandsToExecute.OfType<CreateCommand>().FirstOrDefault();
            if (createCommand != null)
                envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, createCommand));
               // _commandRouter.RouteDocumentCommand(createCommand);
            var lineItemCommands = commandsToExecute.OfType<AfterCreateCommand>().ToList();
            foreach (var item in lineItemCommands)
            {
                envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, item));
               // _commandRouter.RouteDocumentCommand(item);
            }

            var confirmCommodityReleaseCommand = commandsToExecute.OfType<ConfirmCommodityReleaseNoteCommand>().FirstOrDefault();
            if (confirmCommodityReleaseCommand != null)
               // _commandRouter.RouteDocumentCommand(confirmCommodityReleaseCommand);
                envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, confirmCommodityReleaseCommand));
            _commandEnvelopeRouter.RouteCommandEnvelope(envelope);

        }
        public void LoadReleaseDocument(CommodityReleaseNote commodityReleaseNote)
        {
            if (commodityReleaseNote != null)
            {
                Reset();
                ReleaseLineItemList.Clear();
                #region Initialize

                using (IContainer cont = NestedContainer)
                {
                    var _costCentreRepo = Using<ICostCentreRepository>(cont);
                    var costCentre = _costCentreRepo.GetById(commodityReleaseNote.DocumentIssuerCostCentre.ParentCostCentre.Id);
                    CompanyName = costCentre.Name;
                }

                //CompanyName = ConfigurationManager.AppSettings["CompanyName"];
                Address = ConfigurationManager.AppSettings["Address"];
                Telephone = ConfigurationManager.AppSettings["Telephone"];
                AppNAme = commodityReleaseNote.DocumentIssuerCostCentre.Name;
                ReleaseNo = commodityReleaseNote.DocumentReference;
                Clerk = string.Format(commodityReleaseNote.DocumentIssuerUser.Username);
                Date = DateTime.Now.ToShortDateString();
                Store = commodityReleaseNote.DocumentRecipientCostCentre.Name;

                string[] data = commodityReleaseNote.Description.Split(';');

                string[] Name = data[0].Split(':');
                RecepientName = Name[1];
                
                string[] CoName = data[1].Split(':');
                RecepientCoName = CoName[1];
                
                string[] ClinetAddress = data[2].Split(':');
                RecepientAddress = ClinetAddress[1];

                foreach (var item in commodityReleaseNote.LineItems)
                {
                    var lineItem = new ReleaseDocumentLineItem()
                    {
                        Commodity = item.Commodity.Name,
                        Grade = item.CommodityGrade.Name,
                        Weight = item.Weight.ToString(),
                        ContainerNo = item.ContainerNo
                    };
                    ReleaseLineItemList.Add(lineItem);
                }

                #endregion
            }
        }
Пример #4
0
 public void ShowReleaseDocument(CommodityReleaseNote retreavcommodityReleaseNote)
 {
     _vm.LoadReleaseDocument(retreavcommodityReleaseNote);
     ShowDialog();
 }