Beispiel #1
0
    internal static PropertyTypeDto BuildPropertyTypeDto(int groupId, IPropertyType propertyType, int contentTypeId)
    {
        var propertyTypeDto = new PropertyTypeDto
        {
            Alias                   = propertyType.Alias,
            ContentTypeId           = contentTypeId,
            DataTypeId              = propertyType.DataTypeId,
            Description             = propertyType.Description,
            Mandatory               = propertyType.Mandatory,
            MandatoryMessage        = propertyType.MandatoryMessage,
            Name                    = propertyType.Name,
            SortOrder               = propertyType.SortOrder,
            ValidationRegExp        = propertyType.ValidationRegExp,
            ValidationRegExpMessage = propertyType.ValidationRegExpMessage,
            UniqueId                = propertyType.Key,
            Variations              = (byte)propertyType.Variations,
            LabelOnTop              = propertyType.LabelOnTop,
        };

        if (groupId != default)
        {
            propertyTypeDto.PropertyTypeGroupId = groupId;
        }
        else
        {
            propertyTypeDto.PropertyTypeGroupId = null;
        }

        if (propertyType.HasIdentity)
        {
            propertyTypeDto.Id = propertyType.Id;
        }

        return(propertyTypeDto);
    }
Beispiel #2
0
        internal PropertyTypeDto BuildPropertyTypeDto(int tabId, PropertyType propertyType)
        {
            var propertyTypeDto = new PropertyTypeDto
            {
                Alias            = propertyType.Alias,
                ContentTypeId    = _id,
                DataTypeId       = propertyType.DataTypeDefinitionId,
                Description      = propertyType.Description,
                Mandatory        = propertyType.Mandatory,
                Name             = propertyType.Name,
                SortOrder        = propertyType.SortOrder,
                ValidationRegExp = propertyType.ValidationRegExp,
                UniqueId         = propertyType.HasIdentity
                    ? propertyType.Key == Guid.Empty
                        ? Guid.NewGuid()
                        : propertyType.Key
                    : Guid.NewGuid()
            };

            if (tabId != default(int))
            {
                propertyTypeDto.PropertyTypeGroupId = tabId;
            }
            else
            {
                propertyTypeDto.PropertyTypeGroupId = null;
            }

            if (propertyType.HasIdentity)
            {
                propertyTypeDto.Id = propertyType.Id;
            }

            return(propertyTypeDto);
        }
Beispiel #3
0
 private void AddProperty(string addres, string neighborhood, OwnerDto owner,
                          PropertyTypeDto propertype, decimal price, int rooms, int square, int stratum)
 {
     _dataContext.Properties.Add(new PropertyDto
     {
         Address       = addres,
         Neighborhood  = neighborhood,
         Owner         = owner,
         HasParkingLot = false,
         Price         = price,
         IsAvailable   = true,
         Rooms         = rooms,
         SquareMeters  = square,
         Stratum       = stratum,
         PropertyType  = propertype,
         Remarks       = ""
     });
 }
        internal PropertyTypeGroupDto Map(PropertyTypeGroupDto a, PropertyTypeDto p, DataTypeDto d)
        {
            // Terminating call.  Since we can return null from this function
            // we need to be ready for PetaPoco to callback later with null
            // parameters
            if (a == null)
            {
                return(current);
            }

            //Set the PropertyTypeDto's DataTypeDto object
            if (p.DataTypeId == d.DataTypeId)
            {
                p.DataTypeDto = d;
            }

            // Is this the same Group as the current one we're processing
            if (current != null && current.Id == a.Id)
            {
                // Yes, just add this PropertyType to the current Group's collection of PropertyTypes
                current.PropertyTypeDtos.Add(p);

                // Return null to indicate we're not done with this Group yet
                return(null);
            }

            // This is a different Group to the current one, or this is the
            // first time through and we don't have a Tab yet

            // Save the current Group
            var prev = current;

            // Setup the new current Group
            current = a;
            current.PropertyTypeDtos = new List <PropertyTypeDto>();
            current.PropertyTypeDtos.Add(p);

            // Return the now populated previous Tab (or null if first time through)
            return(prev);
        }
Beispiel #5
0
        public void Can_Import_Inherited_ContentTypes_And_Verify_PropertyTypes_UniqueIds()
        {
            // Arrange
            string   strXml          = ImportResources.InheritedDocTypes_Package;
            var      xml             = XElement.Parse(strXml);
            XElement dataTypeElement = xml.Descendants("DataTypes").First();
            XElement templateElement = xml.Descendants("Templates").First();
            XElement docTypeElement  = xml.Descendants("DocumentTypes").First();

            // Act
            IReadOnlyList <IDataType>    dataTypes    = PackageDataInstallation.ImportDataTypes(dataTypeElement.Elements("DataType").ToList(), 0);
            IReadOnlyList <ITemplate>    templates    = PackageDataInstallation.ImportTemplates(templateElement.Elements("Template").ToList(), 0);
            IReadOnlyList <IContentType> contentTypes = PackageDataInstallation.ImportDocumentTypes(docTypeElement.Elements("DocumentType"), 0);

            // Assert
            IContentType mRBasePage = contentTypes.First(x => x.Alias == "MRBasePage");

            using IScope scope = ScopeProvider.CreateScope();
            foreach (IPropertyType propertyType in mRBasePage.PropertyTypes)
            {
                PropertyTypeDto propertyTypeDto = scope.Database.First <PropertyTypeDto>("WHERE id = @id", new { id = propertyType.Id });
                Assert.AreEqual(propertyTypeDto.UniqueId, propertyType.Key);
            }
        }
        public void Issue8370Test()
        {
            // fixme maybe we need to create some content?
            // yes otherwise cannot get it to fail!

            var n = new NodeDto
            {
                Text       = "text",
                CreateDate = DateTime.Now,
                Path       = "-1",
                ParentId   = -1,
                UniqueId   = Guid.NewGuid()
            };

            DatabaseContext.Database.Insert(n);
            var ct = new ContentTypeDto
            {
                Alias     = "alias",
                NodeId    = n.NodeId,
                Thumbnail = "thumb"
            };

            DatabaseContext.Database.Insert(ct);
            n = new NodeDto
            {
                Text       = "text",
                CreateDate = DateTime.Now,
                Path       = "-1",
                ParentId   = -1,
                UniqueId   = Guid.NewGuid()
            };
            DatabaseContext.Database.Insert(n);
            var dt = new DataTypeDto
            {
                PropertyEditorAlias = Constants.PropertyEditors.RelatedLinksAlias,
                DbType     = "x",
                DataTypeId = n.NodeId
            };

            DatabaseContext.Database.Insert(dt);
            var pt = new PropertyTypeDto
            {
                Alias         = "alias",
                ContentTypeId = ct.NodeId,
                DataTypeId    = dt.DataTypeId
            };

            DatabaseContext.Database.Insert(pt);
            n = new NodeDto
            {
                Text       = "text",
                CreateDate = DateTime.Now,
                Path       = "-1",
                ParentId   = -1,
                UniqueId   = Guid.NewGuid()
            };
            DatabaseContext.Database.Insert(n);
            var data = new PropertyDataDto
            {
                NodeId         = n.NodeId,
                PropertyTypeId = pt.Id,
                Text           = "text",
                VersionId      = Guid.NewGuid()
            };

            DatabaseContext.Database.Insert(data);
            data = new PropertyDataDto
            {
                NodeId         = n.NodeId,
                PropertyTypeId = pt.Id,
                Text           = "<root><node title=\"\" type=\"\" newwindow=\"\" link=\"\" /></root>",
                VersionId      = Guid.NewGuid()
            };
            DatabaseContext.Database.Insert(data);

            var migration = new UpdateRelatedLinksData(SqlSyntax, Logger);

            migration.UpdateRelatedLinksDataDo(DatabaseContext.Database);

            data = DatabaseContext.Database.Fetch <PropertyDataDto>("SELECT * FROM cmsPropertyData WHERE id=" + data.Id).FirstOrDefault();
            Assert.IsNotNull(data);
            Debug.Print(data.Text);
            Assert.AreEqual("[{\"title\":\"\",\"caption\":\"\",\"link\":\"\",\"newWindow\":false,\"type\":\"external\",\"internal\":null,\"edit\":false,\"isInternal\":false}]",
                            data.Text);
        }