示例#1
0
        public bool DocumentTemplate_UpdateDocumentId(int id, long documentId)
        {
            var saved = repo.GetById <DocumentTemplate>(id);

            if (saved != null)
            {
                saved.DocumentId = documentId;
                repo.Update(saved);

                switch (saved.SourceType)
                {
                case SourceTypeSelectVM.CaseMigration:
                {
                    var caseMigration = repo.GetById <CaseMigration>((int)saved.SourceId);
                    if (caseMigration.OutDocumentId == null)
                    {
                        caseMigration.OutDocumentId = documentId;
                        repo.Update(caseMigration);
                    }
                    if (caseMigration.CaseMigrationTypeId == NomenclatureConstants.CaseMigrationTypes.SendNextLevel && caseMigration.CaseSessionActId > 0)
                    {
                        mqService.LegalActs_SendAct(caseMigration.CaseSessionActId.Value, EpepConstants.ServiceMethod.Update);
                    }
                }
                break;

                case SourceTypeSelectVM.DocumentDecision:
                {
                    var documentDecision = repo.GetById <DocumentDecision>(saved.SourceId);
                    if (documentDecision.OutDocumentId == null)
                    {
                        documentDecision.OutDocumentId = documentId;
                        repo.Update(documentDecision);
                    }
                }
                break;

                case SourceTypeSelectVM.CaseSessionActDivorce:
                {
                    var caseDivorce = repo.GetById <CaseSessionActDivorce>((int)saved.SourceId);
                    if (caseDivorce.OutDocumentId == null)
                    {
                        caseDivorce.OutDocumentId = documentId;
                        repo.Update(caseDivorce);
                    }
                }
                break;

                case SourceTypeSelectVM.ExecList:
                {
                    var execList = repo.GetById <ExecList>((int)saved.SourceId);
                    if (execList.OutDocumentId == null)
                    {
                        execList.OutDocumentId = documentId;
                        repo.Update(execList);
                    }
                }
                break;

                case SourceTypeSelectVM.ExchangeDoc:
                {
                    var exchangeDoc = repo.GetById <ExchangeDoc>((int)saved.SourceId);
                    if (exchangeDoc.OutDocumentId == null)
                    {
                        var document = repo.AllReadonly <Document>().Where(x => x.Id == documentId).FirstOrDefault();

                        if (counterService.Counter_GetExchangeCounter(exchangeDoc) == false)
                        {
                            return(false);
                        }
                        exchangeDoc.OutDocumentId = documentId;
                        repo.Update(exchangeDoc);
                    }
                }
                break;

                case SourceTypeSelectVM.CasePersonBulletin:
                {
                    var bulletin = repo.GetById <CasePersonSentenceBulletin>((int)saved.SourceId);
                    if (bulletin.OutDocumentId == null)
                    {
                        bulletin.OutDocumentId = documentId;
                        repo.Update(bulletin);
                    }
                }
                break;

                case SourceTypeSelectVM.CasePersonSentence:
                {
                    var sentence = repo.GetById <CasePersonSentence>((int)saved.SourceId);
                    if (sentence.OutDocumentId == null)
                    {
                        sentence.OutDocumentId = documentId;
                        repo.Update(sentence);
                    }
                }
                break;
                }
                repo.SaveChanges();
                return(true);
            }

            return(false);
        }