Example #1
0
        private void InnerUpdateLinks(webModel.ListEntryLink[] links, Action <moduleModel.ILinkSupport, moduleModel.CategoryLink> action)
        {
            var changedObjects = new List <moduleModel.ILinkSupport>();

            foreach (var link in links)
            {
                moduleModel.ILinkSupport changedObject;
                var newlink = new moduleModel.CategoryLink
                {
                    CategoryId = link.CategoryId,
                    CatalogId  = link.CatalogId
                };

                if (String.Equals(link.ListEntryType, webModel.ListEntryCategory.TypeName, StringComparison.InvariantCultureIgnoreCase))
                {
                    changedObject = _categoryService.GetById(link.ListEntryId);
                }
                else
                {
                    changedObject = _itemService.GetById(link.ListEntryId, moduleModel.ItemResponseGroup.ItemLarge);
                }
                action(changedObject, newlink);
                changedObjects.Add(changedObject);
            }

            _categoryService.Update(changedObjects.OfType <moduleModel.Category>().ToArray());
            _itemService.Update(changedObjects.OfType <moduleModel.CatalogProduct>().ToArray());
        }
Example #2
0
        public static moduleModel.CategoryLink ToModuleModel(this webModel.CategoryLink link)
        {
            var retVal = new moduleModel.CategoryLink();

            retVal.InjectFrom(link);
            return(retVal);
        }
Example #3
0
        private void InnerUpdateLinks(webModel.ListEntryLink[] links, Action <coreModel.ILinkSupport, coreModel.CategoryLink> action)
        {
            var changedObjects = new List <coreModel.ILinkSupport>();

            foreach (var link in links)
            {
                coreModel.ILinkSupport changedObject;
                var newlink = new coreModel.CategoryLink
                {
                    CategoryId = link.CategoryId,
                    CatalogId  = link.CatalogId
                };

                if (link.ListEntryType.EqualsInvariant(webModel.ListEntryCategory.TypeName))
                {
                    changedObject = _categoryService.GetById(link.ListEntryId, coreModel.CategoryResponseGroup.Full);
                }
                else
                {
                    changedObject = _itemService.GetById(link.ListEntryId, coreModel.ItemResponseGroup.ItemLarge);
                }
                action(changedObject, newlink);
                changedObjects.Add(changedObject);
            }

            _categoryService.Update(changedObjects.OfType <coreModel.Category>().ToArray());
            _itemService.Update(changedObjects.OfType <coreModel.CatalogProduct>().ToArray());
        }
Example #4
0
        public static webModel.CategoryLink ToWebModel(this moduleModel.CategoryLink link)
        {
            var retVal = new webModel.CategoryLink();

            retVal.CatalogId  = link.CatalogId;
            retVal.CategoryId = link.CategoryId;
            retVal.Priority   = link.Priority;

            return(retVal);
        }
Example #5
0
        /// <summary>
        /// Converting to foundation type
        /// </summary>
        /// <param name="catalog"></param>
        /// <returns></returns>
        public static dataModel.CategoryRelation ToDataModel(this coreModel.CategoryLink categoryLink, coreModel.Category category)
        {
            var retVal = new dataModel.CategoryRelation
            {
                SourceCategoryId = category.Id,
                TargetCategoryId = categoryLink.CategoryId,
                TargetCatalogId  = categoryLink.CatalogId
            };

            return(retVal);
        }
Example #6
0
        /// <summary>
        /// Converting to foundation type
        /// </summary>
        /// <param name="catalog"></param>
        /// <returns></returns>
        public static dataModel.CategoryItemRelation ToDataModel(this coreModel.CategoryLink categoryLink, coreModel.CatalogProduct product)
        {
            var retVal = new dataModel.CategoryItemRelation
            {
                CategoryId = categoryLink.CategoryId,
                ItemId     = product.Id,
                CatalogId  = categoryLink.CatalogId,
                Priority   = 100
            };

            return(retVal);
        }
Example #7
0
        /// <summary>
        /// Converting to foundation type
        /// </summary>
        /// <param name="catalog"></param>
        /// <returns></returns>
        public static coreModel.CategoryLink ToCoreModel(this dataModel.CategoryRelation linkedCategory, coreModel.Category category)
        {
            if (linkedCategory == null)
            {
                throw new ArgumentNullException("linkedCategory");
            }

            var retVal = new coreModel.CategoryLink();

            retVal.CategoryId = linkedCategory.TargetCategoryId;
            retVal.CatalogId  = linkedCategory.TargetCatalogId;

            return(retVal);
        }
Example #8
0
        /// <summary>
        /// Converting to model type
        /// </summary>
        /// <param name="catalogBase"></param>
        /// <returns></returns>
        public static coreModel.CategoryLink ToCoreModel(this dataModel.CategoryItemRelation categoryItemRelation)
        {
            if (categoryItemRelation == null)
            {
                throw new ArgumentNullException("categoryItemRelation");
            }

            var retVal = new coreModel.CategoryLink
            {
                CategoryId = categoryItemRelation.CategoryId,
                CatalogId  = categoryItemRelation.CatalogId
            };

            return(retVal);
        }
Example #9
0
        /// <summary>
        /// Converting to foundation type
        /// </summary>
        /// <param name="catalog"></param>
        /// <returns></returns>
        public static coreModel.CategoryLink ToCoreModel(this dataModel.CategoryRelation linkedCategory, dataModel.Catalog[] allCatalogs, dataModel.Category[] allCategories)
        {
            if (linkedCategory == null)
            {
                throw new ArgumentNullException("linkedCategory");
            }

            var retVal = new coreModel.CategoryLink();

            retVal.CategoryId = linkedCategory.TargetCategoryId;
            retVal.CatalogId  = linkedCategory.TargetCatalogId;
            retVal.Catalog    = allCatalogs.First(x => x.Id == linkedCategory.TargetCatalogId).ToCoreModel(false);
            if (linkedCategory.TargetCategoryId != null)
            {
                retVal.Category = allCategories.First(x => x.Id == linkedCategory.TargetCategoryId)
                                  .ToCoreModel(allCatalogs, allCategories, convertProps: false);
            }
            return(retVal);
        }
Example #10
0
        /// <summary>
        /// Converting to model type
        /// </summary>
        /// <param name="catalogBase"></param>
        /// <returns></returns>
        public static coreModel.CategoryLink ToCoreModel(this dataModel.CategoryItemRelation categoryItemRelation, dataModel.Catalog[] allCatalogs, dataModel.Category[] allCategories)
        {
            if (categoryItemRelation == null)
            {
                throw new ArgumentNullException("categoryItemRelation");
            }

            var retVal = new coreModel.CategoryLink
            {
                CategoryId = categoryItemRelation.CategoryId,
                CatalogId  = categoryItemRelation.CatalogId,
                Priority   = categoryItemRelation.Priority
            };

            retVal.Catalog = allCatalogs.First(x => x.Id == categoryItemRelation.CatalogId).ToCoreModel(false);
            if (categoryItemRelation.CategoryId != null)
            {
                retVal.Category = allCategories.First(x => x.Id == categoryItemRelation.CategoryId)
                                  .ToCoreModel(allCatalogs, allCategories, convertProps: false);
            }

            return(retVal);
        }
        /// <summary>
        /// Converting to model type
        /// </summary>
        /// <param name="catalogBase"></param>
        /// <returns></returns>
        public static coreModel.CategoryLink ToCoreModel(this dataModel.CategoryItemRelation categoryItemRelation)
        {
            if (categoryItemRelation == null)
            {
                throw new ArgumentNullException("categoryItemRelation");
            }

            var retVal = new coreModel.CategoryLink
            {
                CategoryId = categoryItemRelation.CategoryId,
                CatalogId  = categoryItemRelation.CatalogId,
                Priority   = categoryItemRelation.Priority
            };

            if (categoryItemRelation.Category != null)
            {
                retVal.Category = categoryItemRelation.Category.ToCoreModel(false);
            }
            if (categoryItemRelation.Catalog != null)
            {
                retVal.Catalog = categoryItemRelation.Catalog.ToCoreModel(false);
            }
            return(retVal);
        }
        private void InnerUpdateLinks(webModel.ListEntryLink[] links, Action<coreModel.ILinkSupport, coreModel.CategoryLink> action)
        {
            var changedObjects = new List<coreModel.ILinkSupport>();
            foreach (var link in links)
            {
                coreModel.ILinkSupport changedObject;
                var newlink = new coreModel.CategoryLink
                {
                    CategoryId = link.CategoryId,
                    CatalogId = link.CatalogId
                };

                if (String.Equals(link.ListEntryType, webModel.ListEntryCategory.TypeName, StringComparison.InvariantCultureIgnoreCase))
                {
                    changedObject = _categoryService.GetById(link.ListEntryId, coreModel.CategoryResponseGroup.Full);
                }
                else
                {
                    changedObject = _itemService.GetById(link.ListEntryId, coreModel.ItemResponseGroup.ItemLarge);
                }
                action(changedObject, newlink);
                changedObjects.Add(changedObject);
            }

            _categoryService.Update(changedObjects.OfType<coreModel.Category>().ToArray());
            _itemService.Update(changedObjects.OfType<coreModel.CatalogProduct>().ToArray());
        }
Example #13
0
		public static moduleModel.CategoryLink ToModuleModel(this webModel.CategoryLink link)
		{
			var retVal = new moduleModel.CategoryLink();
			retVal.InjectFrom(link);
			return retVal;
		}