示例#1
0
        public static void UpdateDocumentViewModel(this VerDocumentViewModel viewModel,
                                                   ClientFieldData[] clientFieldData)
        {
            var documentsForDelete = clientFieldData
                                     .FirstOrDefault(o => !string.IsNullOrWhiteSpace(o.Name) &&
                                                     o.Name.Equals(
                                                         VerGlobalValues.DOCUMENTS_FOR_DELETE));

            viewModel.DocumentForDelete = documentsForDelete != null &&
                                          string.IsNullOrEmpty(documentsForDelete.Value) == false
                ? documentsForDelete.Value.Split('|').Select(int.Parse).ToList()
                : new List <int>();

            var documentsRowId = clientFieldData
                                 .Where(o => !string.IsNullOrWhiteSpace(o.Name) && o.Name.Equals(VerGlobalValues.VER_DOCUMENT_ID))
                                 .ToList();
            var documentsId = clientFieldData
                              .Where(o => !string.IsNullOrWhiteSpace(o.Name) && o.Name.Equals(VerGlobalValues.DOCUMENT_ID))
                              .ToList();
            var documentsNumber = clientFieldData
                                  .Where(o => !string.IsNullOrWhiteSpace(o.Name) && o.Name.Equals(VerGlobalValues.DOCUMENT_NUMBER))
                                  .ToList();
            var documentsName = clientFieldData
                                .Where(o => !string.IsNullOrWhiteSpace(o.Name) && o.Name.Equals(VerGlobalValues.DOCUMENT_NAME))
                                .ToList();
            var documentsType = clientFieldData
                                .Where(o => !string.IsNullOrWhiteSpace(o.Name) && o.Name.Equals(VerGlobalValues.DOCUMENT_TYPE))
                                .ToList();
            var documentUrl = clientFieldData
                              .Where(o => !string.IsNullOrWhiteSpace(o.Name) && o.Name.Equals(VerGlobalValues.SHP_URL_DOCUMENT))
                              .ToList();
            var documentIsPrimary = clientFieldData
                                    .Where(o => !string.IsNullOrWhiteSpace(o.Name) && o.Name.Equals(VerGlobalValues.IS_PRIMARY))
                                    .ToList();
            var documentsIsDocPackage = clientFieldData
                                        .Where(o => !string.IsNullOrWhiteSpace(o.Name) && o.Name.Equals(VerGlobalValues.PACKAGE_DOC))
                                        .ToList();
            var documentsIsGenerated = clientFieldData
                                       .Where(o => !string.IsNullOrWhiteSpace(o.Name) && o.Name.Equals(VerGlobalValues.IS_GENERATED))
                                       .ToList();
            var documentIsRequired = clientFieldData
                                     .Where(o => !string.IsNullOrWhiteSpace(o.Name) && o.Name.Equals(VerGlobalValues.IS_REQUIRED))
                                     .ToList();
            var documentIsVer = clientFieldData
                                .Where(o => !string.IsNullOrWhiteSpace(o.Name) && o.Name.Equals(VerGlobalValues.IS_VER))
                                .ToList();
            var isOtherList = clientFieldData
                              .Where(o => !string.IsNullOrWhiteSpace(o.Name) && o.Name.Equals(VerGlobalValues.IS_OTHER))
                              .ToList();
            var isVersionHistoryList = clientFieldData
                                       .Where(o => !string.IsNullOrWhiteSpace(o.Name) && o.Name.Equals(VerGlobalValues.IS_VERSION_HISTORY))
                                       .ToList();
            var isDocumentPackageList = clientFieldData
                                        .Where(o => !string.IsNullOrWhiteSpace(o.Name) && o.Name.Equals(VerGlobalValues.IS_DOCUMENT_PACKAGE))
                                        .ToList();
            var isNewDocumentList = clientFieldData
                                    .Where(o => !string.IsNullOrWhiteSpace(o.Name) &&
                                           o.Name.Equals(VerGlobalValues.IS_NEW_DOCUMENT))
                                    .ToList();
            var documentNameTempList = clientFieldData
                                       .Where(o => !string.IsNullOrWhiteSpace(o.Name) && o.Name.Equals(VerGlobalValues.DOCUMENT_NAME_TEMP))
                                       .ToList();

            viewModel.Documents = (from verDocumentId in documentsRowId
                                   join docId in documentsId
                                   on documentsRowId.IndexOf(verDocumentId)
                                   equals documentsId.IndexOf(docId)
                                   join docNumber in documentsNumber
                                   on documentsRowId.IndexOf(verDocumentId)
                                   equals documentsNumber.IndexOf(docNumber)
                                   join docName in documentsName
                                   on documentsRowId.IndexOf(verDocumentId)
                                   equals documentsName.IndexOf(docName)
                                   join docType in documentsType
                                   on documentsRowId.IndexOf(verDocumentId)
                                   equals documentsType.IndexOf(docType)
                                   join shpUrl in documentUrl
                                   on documentsRowId.IndexOf(verDocumentId)
                                   equals documentUrl.IndexOf(shpUrl)
                                   join isPrimary in documentIsPrimary
                                   on documentsRowId.IndexOf(verDocumentId)
                                   equals documentIsPrimary.IndexOf(isPrimary)
                                   join isDocument in documentsIsDocPackage
                                   on documentsRowId.IndexOf(verDocumentId)
                                   equals documentsIsDocPackage.IndexOf(isDocument)
                                   join isGenerated in documentsIsGenerated
                                   on documentsRowId.IndexOf(verDocumentId)
                                   equals documentsIsGenerated.IndexOf(isGenerated)
                                   join isRequired in documentIsRequired
                                   on documentsRowId.IndexOf(verDocumentId)
                                   equals documentIsRequired.IndexOf(isRequired)
                                   join isVer in documentIsVer
                                   on documentsRowId.IndexOf(verDocumentId)
                                   equals documentIsVer.IndexOf(isVer)
                                   join isOther in isOtherList
                                   on documentsRowId.IndexOf(verDocumentId)
                                   equals isOtherList.IndexOf(isOther)
                                   join isVersionHistory in isVersionHistoryList
                                   on documentsRowId.IndexOf(verDocumentId)
                                   equals isVersionHistoryList.IndexOf(isVersionHistory)
                                   join isDocumentPackage in isDocumentPackageList
                                   on documentsRowId.IndexOf(verDocumentId)
                                   equals isDocumentPackageList.IndexOf(isDocumentPackage)
                                   join isNewDocument in isNewDocumentList
                                   on documentsRowId.IndexOf(verDocumentId)
                                   equals isNewDocumentList.IndexOf(isNewDocument)
                                   join documentNameTemp in documentNameTempList
                                   on documentsRowId.IndexOf(verDocumentId)
                                   equals documentNameTempList.IndexOf(documentNameTemp)
                                   select new VerDocumentRowViewModel
            {
                VerDocumentId = Convert.ToInt32(verDocumentId.Value),
                DocumentNumber = docNumber.Value,
                DocumentType = int.Parse(docType.Value),
                DocumentName = docName.Value,
                DocumentId = string.IsNullOrEmpty(docId.Value) ? (int?)null : Convert.ToInt32(docId.Value),
                IsPrimary = Convert.ToBoolean(isPrimary.Value),
                ShpUrlDocument = shpUrl.Value,
                IncInPackage = Convert.ToBoolean(isDocument.Value),
                IsGenerated = Convert.ToBoolean(isGenerated.Value),
                IsRequired = Convert.ToBoolean(isRequired.Value),
                IsVer = isVer.Value != null && bool.Parse(isVer.Value),
                IsOther = isOther.Value != null && bool.Parse(isOther.Value),
                IsVersionHistory = Convert.ToBoolean(isVersionHistory.Value),
                IsDocumentPackage = isDocumentPackage.Value != null && bool.Parse(isDocumentPackage.Value),
                IsNewDocument = isNewDocument.Value != null && bool.Parse(isNewDocument.Value),
                DocumentNameTemp = documentNameTemp.Value
            }).ToList();
        }
示例#2
0
        public static void UpdateDocumentViewModel(this VerDocumentViewModel viewModel, ClientFieldData[] clientFieldData)
        {
            var documentsForDelete = clientFieldData
                                     .FirstOrDefault(o => !string.IsNullOrWhiteSpace(o.Name) &&
                                                     o.Name.Equals(
                                                         VerGlobalValues.DOCUMENTS_FOR_DELETE));

            viewModel.DocumentForDelete = documentsForDelete != null &&
                                          string.IsNullOrEmpty(documentsForDelete.Value) == false
                ? documentsForDelete.Value.Split('|').Select(int.Parse).ToList()
                : new List <int>();

            var updatedCheckClearance = clientFieldData
                                        .Where(o => !string.IsNullOrWhiteSpace(o.Name) &&
                                               o.Name.Equals(VerGlobalValues.UPDATED_CHECK_CLEARANCE))
                                        .ToList();
            var docToSubmitTranslationList = clientFieldData
                                             .Where(o => !string.IsNullOrWhiteSpace(o.Name) &&
                                                    o.Name.Equals(VerGlobalValues.SUBMIT_TRANSLATION))
                                             .ToList();
            var documentsRowId = clientFieldData
                                 .Where(o => !string.IsNullOrWhiteSpace(o.Name) &&
                                        o.Name.Equals(VerGlobalValues.VER_DOCUMENT_ID))
                                 .ToList();
            var documentsId = clientFieldData
                              .Where(o => !string.IsNullOrWhiteSpace(o.Name) &&
                                     o.Name.Equals(VerGlobalValues.DOCUMENT_ID))
                              .ToList();
            var documentsNumber = clientFieldData
                                  .Where(o => !string.IsNullOrWhiteSpace(o.Name) &&
                                         o.Name.Equals(VerGlobalValues.DOCUMENT_NUMBER))
                                  .ToList();
            var documentsName = clientFieldData
                                .Where(o => !string.IsNullOrWhiteSpace(o.Name) &&
                                       o.Name.Equals(VerGlobalValues.DOCUMENT_NAME))
                                .ToList();
            var documentIsPrimary = clientFieldData
                                    .Where(o => !string.IsNullOrWhiteSpace(o.Name) &&
                                           o.Name.Equals(VerGlobalValues.IS_PRIMARY))
                                    .ToList();
            var documentsIsDocPackage = clientFieldData
                                        .Where(o => !string.IsNullOrWhiteSpace(o.Name) &&
                                               o.Name.Equals(VerGlobalValues.PACKAGE_DOC))
                                        .ToList();
            var documentsIsGenerated = clientFieldData
                                       .Where(o => !string.IsNullOrWhiteSpace(o.Name) &&
                                              o.Name.Equals(VerGlobalValues.IS_GENERATED))
                                       .ToList();
            var documentIsRequired = clientFieldData
                                     .Where(o => !string.IsNullOrWhiteSpace(o.Name) &&
                                            o.Name.Equals(VerGlobalValues.IS_REQUIRED))
                                     .ToList();
            var documentPrimaryUrl =
                clientFieldData
                .Where(o => !string.IsNullOrWhiteSpace(o.Name) &&
                       o.Name.Equals(VerGlobalValues.SHP_URL_DOCUMENT))
                .ToList();
            var documentTypeId =
                clientFieldData
                .Where(o => !string.IsNullOrWhiteSpace(o.Name) &&
                       o.Name.Equals(VerGlobalValues.DOCUMENT_TYPE))
                .ToList();
            var documentIsVer = clientFieldData
                                .Where(o => !string.IsNullOrWhiteSpace(o.Name) &&
                                       o.Name.Equals(VerGlobalValues.IS_VER))
                                .ToList();
            var documentIsPublish = clientFieldData
                                    .Where(o => !string.IsNullOrWhiteSpace(o.Name) &&
                                           o.Name.Equals(VerGlobalValues.PUBLISH_DOC))
                                    .ToList();
            var isVisibleChkPublishList = clientFieldData
                                          .Where(o => !string.IsNullOrWhiteSpace(o.Name) &&
                                                 o.Name.Equals(VerGlobalValues.IS_VISIBLE_CHK_PUBLISH))
                                          .ToList();
            var isOtherList = clientFieldData
                              .Where(o => !string.IsNullOrWhiteSpace(o.Name) &&
                                     o.Name.Equals(VerGlobalValues.IS_OTHER))
                              .ToList();
            var checkClearancePdf = clientFieldData
                                    .Where(o => !string.IsNullOrWhiteSpace(o.Name) &&
                                           o.Name.Equals(VerGlobalValues.IS_CHECK_CLEARANCE_PDF))
                                    .ToList();
            var isVersionHistoryList = clientFieldData
                                       .Where(o => !string.IsNullOrWhiteSpace(o.Name) && o.Name.Equals(VerGlobalValues.IS_VERSION_HISTORY))
                                       .ToList();
            var isNewDocumentList = clientFieldData
                                    .Where(o => !string.IsNullOrWhiteSpace(o.Name) &&
                                           o.Name.Equals(VerGlobalValues.IS_NEW_DOCUMENT))
                                    .ToList();
            var documentNameTempList = clientFieldData
                                       .Where(o => !string.IsNullOrWhiteSpace(o.Name) && o.Name.Equals(VerGlobalValues.DOCUMENT_NAME_TEMP))
                                       .ToList();

            viewModel.Documents =
                (from verDocumentId in documentsRowId
                 join docId in documentsId
                 on documentsRowId.IndexOf(verDocumentId)
                 equals documentsId.IndexOf(docId)
                 join docNumber in documentsNumber
                 on documentsRowId.IndexOf(verDocumentId)
                 equals documentsNumber.IndexOf(docNumber)
                 join docName in documentsName
                 on documentsRowId.IndexOf(verDocumentId)
                 equals documentsName.IndexOf(docName)
                 join isPrimary in documentIsPrimary
                 on documentsRowId.IndexOf(verDocumentId)
                 equals documentIsPrimary.IndexOf(isPrimary)
                 join isDocument in documentsIsDocPackage
                 on documentsRowId.IndexOf(verDocumentId)
                 equals documentsIsDocPackage.IndexOf(isDocument)
                 join isGeneratedAnnex in documentsIsGenerated
                 on documentsRowId.IndexOf(verDocumentId)
                 equals documentsIsGenerated.IndexOf(isGeneratedAnnex)
                 join isRequired in documentIsRequired
                 on documentsRowId.IndexOf(verDocumentId)
                 equals documentIsRequired.IndexOf(isRequired)
                 join shpUrl in documentPrimaryUrl
                 on documentsRowId.IndexOf(verDocumentId)
                 equals documentPrimaryUrl.IndexOf(shpUrl)
                 join documentType in documentTypeId
                 on documentsRowId.IndexOf(verDocumentId)
                 equals documentTypeId.IndexOf(documentType)
                 join documentVer in documentIsVer
                 on documentsRowId.IndexOf(verDocumentId)
                 equals documentIsVer.IndexOf(documentVer)
                 join isPublish in documentIsPublish
                 on documentsRowId.IndexOf(verDocumentId)
                 equals documentIsPublish.IndexOf(isPublish)
                 join docToSubmitTranslate in docToSubmitTranslationList
                 on documentsRowId.IndexOf(verDocumentId)
                 equals docToSubmitTranslationList.IndexOf(docToSubmitTranslate)
                 join updatedCheckForClearance in updatedCheckClearance
                 on documentsRowId.IndexOf(verDocumentId)
                 equals updatedCheckClearance.IndexOf(updatedCheckForClearance)
                 join isVisibleChkPublish in isVisibleChkPublishList
                 on documentsRowId.IndexOf(verDocumentId)
                 equals isVisibleChkPublishList.IndexOf(isVisibleChkPublish)
                 join isOther in isOtherList
                 on documentsRowId.IndexOf(verDocumentId)
                 equals isOtherList.IndexOf(isOther)
                 join isVersionHistory in isVersionHistoryList
                 on documentsRowId.IndexOf(verDocumentId)
                 equals isVersionHistoryList.IndexOf(isVersionHistory)
                 join checkClearancePdfItem in checkClearancePdf
                 on documentsRowId.IndexOf(verDocumentId)
                 equals checkClearancePdf.IndexOf(checkClearancePdfItem)
                 join isNewDocument in isNewDocumentList
                 on documentsRowId.IndexOf(verDocumentId)
                 equals isNewDocumentList.IndexOf(isNewDocument)
                 join documentNameTemp in documentNameTempList
                 on documentsRowId.IndexOf(verDocumentId)
                 equals documentNameTempList.IndexOf(documentNameTemp)
                 select new VerDocumentRowViewModel
            {
                VerDocumentId = int.Parse(verDocumentId.Value),
                DocumentNumber = docNumber.Value,
                DocumentName = docName.Value,
                DocumentId = string.IsNullOrEmpty(docId.Value) ? (int?)null : int.Parse(docId.Value),
                IsPrimary = Convert.ToBoolean(isPrimary.Value),
                IncInPackage = Convert.ToBoolean(isDocument.Value),
                IsGenerated = Convert.ToBoolean(isGeneratedAnnex.Value),
                IsRequired = Convert.ToBoolean(isRequired.Value),
                ShpUrlDocument = shpUrl.Value,
                DocumentType = int.Parse(documentType.Value),
                IsVer = documentVer.Value != null && bool.Parse(documentVer.Value),
                IncInPublish = Convert.ToBoolean(isPublish.Value),
                IsSubmittedForTranslation = Convert.ToBoolean(docToSubmitTranslate.Value),
                UpdatedCheckForClearance = Convert.ToBoolean(updatedCheckForClearance.Value),
                IsVisibleChkPublish = Convert.ToBoolean(isVisibleChkPublish.Value),
                IsOther = Convert.ToBoolean(isOther.Value),
                IsVersionHistory = Convert.ToBoolean(isVersionHistory.Value),
                IsCheckClearancePdf = Convert.ToBoolean(checkClearancePdfItem.Value),
                IsNewDocument = Convert.ToBoolean(isNewDocument.Value),
                DocumentNameTemp = documentNameTemp.Value
            }).ToList();
        }