Esempio n. 1
0
        public void UpdateMagentoProductGroupSetting(MagentoProductGroupSetting currentMagentoSetting, MagentoProductGroupSetting compareMagentoSetting, List <string> ignoreProperties)
        {
            List <string> changes = generateUpdateFields.GetPropertiesForUpdate(compareMagentoSetting, currentMagentoSetting, ignoreProperties);

            if (changes.Count > 0)
            {
                var updateQuery = string.Join(",", changes);
                petaPoco.Update <MagentoProductGroupSetting>(string.Format(@"
          SET {1}
          WHERE MagentoProductGroupSettingID = {0}
        ", currentMagentoSetting.MagentoProductGroupSettingID, updateQuery));
            }
        }
Esempio n. 2
0
        public void UpdateContent(Content content)
        {
            Content currentContent = GetContentByID(content.ProductID, content.ConnectorID);

            List <string> listOfIngnoreProperties = generateUpdateProperties.GenerateIgnoreProperties(
                new Content(),
                x => x.CreatedBy,
                x => x.LastModifiedBy,
                x => x.LastModificationTime,
                x => x.CreationTime);

            List <string> listOfChanges = generateUpdateProperties.GetPropertiesForUpdate(content, currentContent, listOfIngnoreProperties);

            if (listOfChanges.Count > 0)
            {
                var updateQuery = string.Join(",", listOfChanges);
                petaPoco.Update <Content>(string.Format(@"
          SET {2}
          WHERE ProductID = {0}
	          AND ConnectorID = {1}
        ", content.ProductID, content.ConnectorID, updateQuery));
            }
        }
Esempio n. 3
0
        public void UpdateMasterGroupMapping(MasterGroupMapping masterGroupMapping)
        {
            MasterGroupMapping currentMasterGroupMapping = GetMasterGroupMappingByMasterGroupMappingID(masterGroupMapping.MasterGroupMappingID);

            StringBuilder changes = new StringBuilder();

            List <string> listOfChanges = generateUpdateFields.GetPropertiesForUpdate(masterGroupMapping, currentMasterGroupMapping);

            if (masterGroupMapping.ParentMasterGroupMappingID.HasValue && masterGroupMapping.ParentMasterGroupMappingID.Value > 0)
            {
                if (masterGroupMapping.ParentMasterGroupMappingID != currentMasterGroupMapping.ParentMasterGroupMappingID)
                {
                    changes.Append(string.Format("ParentMasterGroupMappingID = {0}", masterGroupMapping.ParentMasterGroupMappingID));
                }
            }

            if (masterGroupMapping.ConnectorID.HasValue && masterGroupMapping.ConnectorID.Value > 0)
            {
                if (masterGroupMapping.ConnectorID != currentMasterGroupMapping.ConnectorID)
                {
                    if (!string.IsNullOrEmpty(changes.ToString()))
                    {
                        changes.Append(",");
                    }
                    changes.Append(string.Format("ConnectorID = {0}", masterGroupMapping.ConnectorID));
                }
            }

            if (masterGroupMapping.ProductGroupID != currentMasterGroupMapping.ProductGroupID)
            {
                if (!string.IsNullOrEmpty(changes.ToString()))
                {
                    changes.Append(",");
                }
                changes.Append(string.Format("ProductGroupID = {0}", masterGroupMapping.ProductGroupID));
            }

            if (masterGroupMapping.SourceMasterGroupMappingID.HasValue && masterGroupMapping.SourceMasterGroupMappingID.Value > 0)
            {
                if (masterGroupMapping.SourceMasterGroupMappingID != currentMasterGroupMapping.SourceMasterGroupMappingID)
                {
                    if (!string.IsNullOrEmpty(changes.ToString()))
                    {
                        changes.Append(",");
                    }
                    changes.Append(string.Format("SourceMasterGroupMappingID = {0}", masterGroupMapping.SourceMasterGroupMappingID));
                }
            }

            if (masterGroupMapping.Score.HasValue)
            {
                if (masterGroupMapping.Score != currentMasterGroupMapping.Score)
                {
                    if (!string.IsNullOrEmpty(changes.ToString()))
                    {
                        changes.Append(",");
                    }
                    changes.Append(string.Format("Score = {0}", masterGroupMapping.Score));
                }
            }

            if (masterGroupMapping.FlattenHierarchy != currentMasterGroupMapping.FlattenHierarchy)
            {
                if (!string.IsNullOrEmpty(changes.ToString()))
                {
                    changes.Append(",");
                }
                changes.Append(string.Format("FlattenHierarchy = {0}", (masterGroupMapping.FlattenHierarchy ? 1 : 0)));
            }

            if (masterGroupMapping.FilterByParentGroup != currentMasterGroupMapping.FilterByParentGroup)
            {
                if (!string.IsNullOrEmpty(changes.ToString()))
                {
                    changes.Append(",");
                }
                changes.Append(string.Format("FilterByParentGroup = {0}", (masterGroupMapping.FilterByParentGroup ? 1 : 0)));
            }

            if (!string.IsNullOrEmpty(changes.ToString()))
            {
                petaPoco.Update <MasterGroupMapping>(string.Format(@"
          SET {1}
          WHERE MasterGroupMappingID = {0}
        ", masterGroupMapping.MasterGroupMappingID, changes));
            }
        }