예제 #1
0
        private void PublishAlias(AutoroutePart part)
        {
            _lockingProvider.Lock(LockString, () => {
                ProcessAlias(part);

                // Should it become the home page?
                if (part.PromoteToHomePage)
                {
                    // Get the current homepage an unmark it as the homepage.
                    var currentHomePage = _homeAliasService.GetHomePage(VersionOptions.Latest);
                    if (currentHomePage != null && currentHomePage.Id != part.Id)
                    {
                        var autoroutePart = currentHomePage.As <AutoroutePart>();

                        if (autoroutePart != null)
                        {
                            autoroutePart.PromoteToHomePage = false;
                            if (autoroutePart.IsPublished())
                            {
                                _orchardServices.ContentManager.Publish(autoroutePart.ContentItem);
                            }
                        }
                    }

                    // Update the home alias to point to this item being published.
                    _homeAliasService.PublishHomeAlias(part);
                }

                _autorouteService.Value.PublishAlias(part);
            });
        }
        public TagRecord CreateTag(string tagName)
        {
            TagRecord result = null;

            var lockString = string.Join(".",
                                         _orchardServices.WorkContext?.CurrentSite?.BaseUrl ?? "",
                                         _orchardServices.WorkContext?.CurrentSite?.SiteName ?? "",
                                         "TagService.CreateTag",
                                         tagName);

            _lockingProvider.Lock(lockString,
                                  () => {
                result = _tagRepository.Get(x => x.TagName == tagName);
                if (result == null)
                {
                    result = new TagRecord {
                        TagName = tagName
                    };
                    _tagRepository.Create(result);
                }
            });

            return(result);
        }