private void AddRepositoryMetadataFields(RepositoryMetadataField repMetadataField)
 {
     IRepositoryDetails repository = new RepositoryDetails(testDBContext);
     testDBContext.RepositoryMetadataFields.Add(repMetadataField);
     testDBContext.Commit();
 }
示例#2
0
        public RepositoryMetadataField SaveRepositoryMetaDataField(RepositoryMetadataField repositoryMetadataField)
        {
            if (repositoryMetadataField.RepositoryMetadataFieldId > 0)
            {
                var updatedRepositoryMetaDataField = Context.RepositoryMetadataFields.Attach(repositoryMetadataField);

                Context.SetEntityState<RepositoryMetadataField>(updatedRepositoryMetaDataField, EntityState.Modified);

                return updatedRepositoryMetaDataField;
            }
            else
            {
                return Context.RepositoryMetadataFields.Add(repositoryMetadataField);
            }
        }
        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);
        }