Пример #1
0
        public RepositoryMetadata SaveRepositoryMetaData(RepositoryMetadata repositoryMetadata)
        {
            if (repositoryMetadata.RepositoryMetadataId > 0)
            {
                foreach (var repositoryMetaDataField in repositoryMetadata.RepositoryMetadataFields)
                {
                    SaveRepositoryMetaDataField(repositoryMetaDataField);
                }

                RepositoryMetadata updatedRepositoryMetaData = Context.RepositoryMetadata.Attach(repositoryMetadata);

                Context.SetEntityState<RepositoryMetadata>(updatedRepositoryMetaData, EntityState.Modified);

                return updatedRepositoryMetaData;
            }
            else
            {
                return Context.RepositoryMetadata.Add(repositoryMetadata);
            }
        }
        private void AddDefaultData()
        {
            User newUser = new User()
            {
                NameIdentifier = "s0Me1De9Tf!Er$tRing",
                FirstName = "SomeFirstName",
                MiddleName = "SomeMiddleName",
                LastName = "SomeLastName",
                IdentityProvider = "Windows Live",
                Organization = "SomeOrganization",
                EmailId = "*****@*****.**",
                CreatedOn = DateTime.Now,
                ModifiedOn = DateTime.Now,
                IsActive = true,
                UserAttributes = null
            };

            // User with userid 1
            AddUser(newUser);

            // Adding metadata types
            MetadataType metaType = new MetadataType() { MetadataTypeId = 1, Name = "Text", Status = true };
            MetadataType metaType1 = new MetadataType() { MetadataTypeId = 2, Name = "Numaric", Status = true };
            MetadataType metaType2 = new MetadataType() { MetadataTypeId = 3, Name = "Email", Status = true };

            AddMetaDataType(metaType);
            AddMetaDataType(metaType1);
            AddMetaDataType(metaType2);

            BaseRepository baseRepo = new BaseRepository() { BaseRepositoryId = 1, Name = "Merrit" };

            AddBaseRepository(baseRepo);

            Repository repositoryObject = new Repository()
            {
                AllowedFileTypes = "xlsx,nc,csv",
                CreatedBy = 1,
                /// Files = null,
                CreatedOn = DateTime.Now,
                HttpDeleteUriTemplate = "http://google.com",
                HttpGetUriTemplate = "http://google.com",
                HttpIdentifierUriTemplate = "http://google.com",
                HttpPostUriTemplate = "http://google.com",
                ImpersonatingPassword = "******",
                ImpersonatingUserName = "******",
                IsActive = true,
                IsImpersonating = true,
                ModifiedBy = 1,
                ModifiedOn = DateTime.Now,
                Name = "Repository1",
                RepositoryId = 1,
                UserAgreement = "Test Agreement1",
                BaseRepositoryId = 1,
                IsVisibleToAll = true
            };

            Repository repositoryObject1 = new Repository()
            {
                AllowedFileTypes = "xlsx,csv",
                CreatedBy = 1,
                //Files = null,
                CreatedOn = DateTime.Now,
                HttpDeleteUriTemplate = "http://gmail.com",
                HttpGetUriTemplate = "http://gmail.com",
                HttpIdentifierUriTemplate = "http://gmail.com",
                HttpPostUriTemplate = "http://gmail.com",
                ImpersonatingPassword = "******",
                ImpersonatingUserName = "******",
                IsActive = true,
                IsImpersonating = true,
                ModifiedBy = 1,
                ModifiedOn = DateTime.Now,
                Name = "Repository2",
                RepositoryId = 2,
                UserAgreement = "Test Agreement1",
                BaseRepositoryId = 1,
                IsVisibleToAll = true
            };

            // Adding 2 new repositories
            AddRepository(repositoryObject);
            AddRepository(repositoryObject1);

            // Adding repository metadata and metadata fields
            RepositoryMetadata repMetadata = new RepositoryMetadata() { CreatedBy = 1, CreatedOn = DateTime.UtcNow, IsActive = true, ModifiedBy = 1, ModifiedOn = DateTime.UtcNow, Name = "Merrit Test metadata", RepositoryId = 1, RepositoryMetadataId = 1, RepositoryMetadataFields = null };

            AddRepositoryMetadata(repMetadata);

            RepositoryMetadataField repMDField = new RepositoryMetadataField() { Description = "Create Name", IsRequired = true, Mapping = "Test Mapping", MetadataTypeId = 1, Name = "Create Name", Order = 1, Range = "", RepositoryMetadataFieldId = 1, RepositoryMetadataId = 1 };
            RepositoryMetadataField repMDField1 = new RepositoryMetadataField() { Description = "Create Phone", IsRequired = true, Mapping = "Test Mapping", MetadataTypeId = 1, Name = "Create Phone", Order = 2, Range = "", RepositoryMetadataFieldId = 2, RepositoryMetadataId = 1 };
            RepositoryMetadataField repMDField2 = new RepositoryMetadataField() { Description = "Create Email", IsRequired = true, Mapping = "Test Mapping", MetadataTypeId = 1, Name = "Create Email", Order = 3, Range = "", RepositoryMetadataFieldId = 3, RepositoryMetadataId = 1 };

            AddRepositoryMetadataFields(repMDField);
            AddRepositoryMetadataFields(repMDField1);
            AddRepositoryMetadataFields(repMDField2);
        }
 private void AddRepositoryMetadata(RepositoryMetadata repMetadata)
 {
     IRepositoryDetails repository = new RepositoryDetails(testDBContext);
     testDBContext.RepositoryMetadata.Add(repMetadata);
     testDBContext.Commit();
 }
Пример #4
0
        private RepositoryMetadata SetRepositoryMetaData(Repository repositoryData, Repository updatedRepositoryData, RepositoryMetadata savedRepositoryMetaData)
        {
            var actualRepositoryMetaData = repositoryData.RepositoryMetadata.FirstOrDefault();

            actualRepositoryMetaData.RepositoryId = updatedRepositoryData.RepositoryId;
            if (actualRepositoryMetaData.RepositoryMetadataId > 0)
            {
                actualRepositoryMetaData.ModifiedBy = updatedRepositoryData.CreatedBy;
                actualRepositoryMetaData.ModifiedOn = DateTime.UtcNow;
            }
            else
            {
                actualRepositoryMetaData.CreatedBy = updatedRepositoryData.CreatedBy;
                actualRepositoryMetaData.CreatedOn = DateTime.UtcNow;
            }

            savedRepositoryMetaData = this.repositoryDetails.SaveRepositoryMetaData(actualRepositoryMetaData);
            return savedRepositoryMetaData;
        }