BlendInteractive.ExtendedCategories.Implementations.CategoryRepository.AddAssignment C# (CSharp) Метод

AddAssignment() публичный Метод

public AddAssignment ( EPiServer.Core.ContentReference contentRef, EPiServer.Core.ContentReference categoryRef, string scope ) : void
contentRef EPiServer.Core.ContentReference
categoryRef EPiServer.Core.ContentReference
scope string
Результат void
        public void AddAssignment(ContentReference contentRef, ContentReference categoryRef, string scope)
        {
            contentRef = contentRef.ToReferenceWithoutVersion();
            categoryRef = categoryRef.ToReferenceWithoutVersion();

            var matchingAssignments = Store.Items<CategoryAssignment>().Where(ca => ca.ContentPage == contentRef && ca.CategoryPage == categoryRef && ca.Scope == scope);
            if(matchingAssignments.Count() > 0)
            {
                return;
            }

            var categoryAssignment = new CategoryAssignment()
            {
                ContentPage = contentRef,
                CategoryPage = categoryRef,
                Scope = scope
            };
            Store.Save(categoryAssignment);
        }