Пример #1
0
        public static RecordServiceResult Upsert(Record record, IDocumentSession db, IRecordValidator validator)
        {
            CorrectlyOrderKeywords(record);
            StandardiseUnconditionalUseConstraints(record);
            SetMetadataPointOfContactRoleToOnlyAllowedValue(record);

            var validation = validator.Validate(record);

            if (!validation.Errors.Any())
            {
                PerformDenormalizations(record);
                db.Store(record);
            }

            return(new RecordServiceResult
            {
                Record = record,
                RecordState = new RecordState
                {
                    OpenDataPublishingState = new OpenDataPublishingState {
                        AssessedAndUpToDate = record.IsAssessedAndUpToDate(),
                        SignedOffAndUpToDate = record.IsSignedOffAndUpToDate(),
                        UploadedAndUpToDate = record.IsUploadedAndUpToDate()
                    }
                },
                Validation = validation,
            });
        }
        public static RecordServiceResult Upsert(Record record, IDocumentSession db, IRecordValidator validator)
        {
            CorrectlyOrderKeywords(record);
            StandardiseUnconditionalUseConstraints(record);
            SetMetadataPointOfContactRoleToOnlyAllowedValue(record);
            TrimPublishableResourcePaths(record);

            var validation = validator.Validate(record);

            if (!validation.Errors.Any())
            {
                PerformDenormalizations(record);
                db.Store(record);
            }

            return(new RecordServiceResult
            {
                Record = record,
                RecordState = new RecordState
                {
                    PublishingState = new PublishingState {
                        AssessedAndUpToDate = record.IsAssessedAndUpToDate(),
                        SignedOffAndUpToDate = record.IsSignedOffAndUpToDate(),
                        PublishedToHubAndUpToDate = record.IsPublishedToHubAndUpToDate(),
                        PublishedToGovAndUpToDate = record.IsPublishedToGovAndUpToDate(),
                        PublishedAndUpToDate = record.IsPublishedAndUpToDate(),
                        PreviouslyPublishedWithDoi = record.HasPreviouslyBeenPublishedWithDoi()
                    }
                },
                Validation = validation
            });
        }