Beispiel #1
0
        public static WFExchangeData PostModirAction(ActionMethodParams actionMethodParams)
        {
            int contractId = actionMethodParams.InitialExchangeData[WfConstants.RelatedRecordIdKey].ConvertTo <int>();

            WFExchangeData ex = (WFExchangeData)actionMethodParams.WorkflowInstanceState.ExchangeData;

            ContractRule contractRule = new ContractRule(UnitOfWork);

            DomainClasses.Contract.Contract contract = contractRule.Find(contractId);



            if (contract == null)
            {
                throw new OMFValidationException($" قرارداد با شناسه ثبت شده یافت نشد. شناسه: {contractId}");
            }


            if (actionMethodParams.ContinueInfo.ActionId == (int)WorkFlowActionType.Taeed)
            {
                contract.Status = Status.ConfirmationContract;
                contractRule.Update(contract);
                contractRule.SaveChanges();

                InvoiceRule invoiceRule = new InvoiceRule(UnitOfWork);
                invoiceRule.ConvertContractToInvoice(contract.ID, NoeFactor.RentFrom);
            }
            return(ex);
        }
Beispiel #2
0
        public static WFExchangeData PostModirDakhiliAction(ActionMethodParams actionMethodParams)
        {
            try
            {
                int contractId = actionMethodParams.InitialExchangeData[WfConstants.RelatedRecordIdKey].ConvertTo <int>();

                WFExchangeData ex = (WFExchangeData)actionMethodParams.WorkflowInstanceState.ExchangeData;

                ContractRule contractRule = new ContractRule(UnitOfWork);
                DomainClasses.Contract.Contract contract = contractRule.Find(contractId);



                if (contract == null)
                {
                    throw new OMFValidationException($" قرارداد با شناسه ثبت شده یافت نشد. شناسه: {contractId}");
                }


                if (actionMethodParams.ContinueInfo.ActionId == (int)WorkFlowActionType.TabdelPishghrardadBeGharardad)
                {
                    using (var uow = new UnitOfWork())
                    {
                        contract.Status       = Status.ConfirmationPreContract;
                        contract.ContractType = ContractType.RentTo;

                        // var contract_Sazes = uow.Repository<Contract_Saze>().Queryable().Where(x => x.ContractID == contract.ID).ToList();

                        foreach (var contract_Saze in contract.Contract_Sazes ?? new List <Contract_Saze>())
                        {
                            contract_Saze.Status      = Status.ConfirmationPreContract;
                            contract_Saze.ObjectState = OMF.Common.Enums.ObjectState.Modified;
                        }

                        uow.Repository <DomainClasses.Contract.Contract>().Update(contract);


                        uow.SaveChanges();
                    }


                    InvoiceRule invoiceRule = new InvoiceRule(UnitOfWork);
                    var         invoice     = invoiceRule.ConvertContractToInvoice(contract.ID, NoeFactor.RentTo);

                    var document = invoiceRule.RegisterDocument(invoice, invoice.OrganId);

                    DocumentRule documentRule = new DocumentRule();
                    documentRule.Insert(document, invoice.OrganId);
                    documentRule.SaveChanges();
                }
                return(ex);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Beispiel #3
0
        public static WFExchangeData PostModirAction(ActionMethodParams actionMethodParams)
        {
            int contractSazeId = actionMethodParams.InitialExchangeData[WfConstants.RelatedRecordIdKey].ConvertTo <int>();

            WFExchangeData ex = (WFExchangeData)actionMethodParams.WorkflowInstanceState.ExchangeData;

            Contract_SazeRule contract_SazeRule = new Contract_SazeRule(UnitOfWork);
            Contract_Saze     contract_Saze     = contract_SazeRule.Find(contractSazeId);



            if (contract_Saze == null)
            {
                throw new OMFValidationException($"رسانه قرارداد با شناسه ثبت شده یافت نشد. شناسه: {contractSazeId}");
            }

            ContractRule contractRule = new ContractRule(UnitOfWork);

            DomainClasses.Contract.Contract contract = contractRule.Find(contract_Saze.ContractID);


            if (actionMethodParams.ContinueInfo.ActionId == (int)WorkFlowActionType.TaeedVaKhateme)
            {
                contract_Saze.Status = Status.ConfirmationContract;
                contract_SazeRule.Update(contract_Saze);
                contract_SazeRule.SaveChanges();

                if (contract.Contract_Sazes.All(x => x.Status == Status.ConfirmationContract))
                {
                    contract.Status = Status.ConfirmationContract;
                    contractRule.Update(contract);
                    contractRule.SaveChanges();
                }
            }
            return(ex);
        }