public async Task <RepositoryResponse <FileViewModel> > SiteMapAsync()
 {
     return(await SitemapService.ParseSitemapAsync());
 }
Exemple #2
0
 public void Setup()
 {
     svc = new SitemapService();
 }
Exemple #3
0
        /// <summary>
        /// Executes the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        public SitemapViewModel Execute(SitemapViewModel request)
        {
            createdNodes.Clear();
            updatedNodes.Clear();
            deletedNodes.Clear();

            var createNew = request.Id.HasDefaultValue();

            Models.Sitemap sitemap;

            if (!createNew)
            {
                var sitemapQuery = Repository.AsQueryable <Models.Sitemap>().Where(s => s.Id == request.Id);

                if (CmsConfiguration.Security.AccessControlEnabled)
                {
                    sitemapQuery = sitemapQuery.FetchMany(f => f.AccessRules);
                }

                sitemap = sitemapQuery.ToList().First();

                if (CmsConfiguration.Security.AccessControlEnabled)
                {
                    AccessControlService.DemandAccess(sitemap, Context.Principal, AccessLevel.ReadWrite);
                }
            }
            else
            {
                sitemap = new Models.Sitemap()
                {
                    AccessRules = new List <AccessRule>()
                };
            }

            var nodeList = !createNew?Repository.AsQueryable <SitemapNode>()
                           .Where(node => node.Sitemap.Id == sitemap.Id)
                           .ToFuture()
                               : new List <SitemapNode>();

            var translationList = !createNew
                                      ? Repository.AsQueryable <SitemapNodeTranslation>()
                                  .Where(t => t.Node.Sitemap.Id == sitemap.Id)
                                  .Fetch(t => t.Node)
                                  .ToFuture()
                                      : new List <SitemapNodeTranslation>();

            UnitOfWork.BeginTransaction();

            if (!createNew)
            {
                SitemapService.ArchiveSitemap(request.Id);
            }

            if (CmsConfiguration.Security.AccessControlEnabled)
            {
                sitemap.AccessRules.RemoveDuplicateEntities();

                var accessRules = request.UserAccessList != null?request.UserAccessList.Cast <IAccessRule>().ToList() : null;

                AccessControlService.UpdateAccessControl(sitemap, accessRules);
            }

            sitemap.Title   = request.Title;
            sitemap.Version = request.Version;
            Repository.Save(sitemap);

            SaveNodeList(sitemap, request.RootNodes, null, nodeList.ToList(), translationList.ToList());

            IList <Tag> newTags;

            TagService.SaveTags(sitemap, request.Tags, out newTags);


            UnitOfWork.Commit();

            foreach (var node in createdNodes)
            {
                Events.SitemapEvents.Instance.OnSitemapNodeCreated(node);
            }

            foreach (var node in updatedNodes)
            {
                Events.SitemapEvents.Instance.OnSitemapNodeUpdated(node);
            }

            foreach (var node in deletedNodes)
            {
                Events.SitemapEvents.Instance.OnSitemapNodeDeleted(node);
            }

            if (createNew)
            {
                Events.SitemapEvents.Instance.OnSitemapCreated(sitemap);
            }
            else
            {
                Events.SitemapEvents.Instance.OnSitemapUpdated(sitemap);
            }

            Events.RootEvents.Instance.OnTagCreated(newTags);

            return(GetModelMainData(sitemap));
        }
 public Sitemap SitemapGet([FromServices] SitemapService sitemapService)
 {
     return(sitemapService.Sitemap);
 }