Esempio n. 1
0
        public ActionResult Properties(string tabId, int parentId, int id, string successfulActionCode, bool?boundToExternal)
        {
            var version = ArticleVersionService.Read(id, parentId);
            var model   = ArticleVersionViewModel.Create(version, tabId, parentId, successfulActionCode, boundToExternal);

            return(JsonHtml("Properties", model));
        }
Esempio n. 2
0
        public async Task <ActionResult> Properties(string tabId, int parentId, int id, string backendActionCode, bool?boundToExternal, IFormCollection collection)
        {
            var version0 = ArticleVersionService.Read(id, parentId);
            var article  = ArticleService.ReadForUpdate(version0.ArticleId, version0.Article.ContentId);
            var version  = ArticleVersionService.CreateVersionFromArticle(article);

            version.Id = ArticleVersion.CurrentVersionId; // for proper loading aggregated articles
            var model = ArticleVersionViewModel.Create(version, tabId, parentId, boundToExternal);

            await TryUpdateModelAsync(model);

            if (ModelState.IsValid)
            {
                model.Data.Article = ArticleVersionService.Restore(model.Data, boundToExternal, HttpContext.IsXmlDbUpdateReplayAction());
                return(Redirect("Properties", new
                {
                    tabId,
                    parentId,
                    id,
                    successfulActionCode = backendActionCode,
                    boundToExternal
                }));
            }

            return(await JsonHtml("Properties", model));
        }
Esempio n. 3
0
        public ActionResult Compare(string tabId, int parentId, int[] IDs, bool?boundToExternal)
        {
            var version = ArticleVersionService.GetMergedVersion(IDs, parentId);
            var model   = ArticleVersionViewModel.Create(version, tabId, parentId, boundToExternal);

            model.ViewType = ArticleVersionViewType.CompareVersions;
            return(JsonHtml("Properties", model));
        }
Esempio n. 4
0
        public ActionResult CompareWithCurrent(string tabId, int parentId, int id, bool?boundToExternal)
        {
            var version = ArticleVersionService.GetMergedVersion(new[] { id, ArticleVersion.CurrentVersionId }, parentId);
            var model   = ArticleVersionViewModel.Create(version, tabId, parentId, boundToExternal);

            model.ViewType = ArticleVersionViewType.CompareWithCurrent;
            return(JsonHtml("Properties", model));
        }
Esempio n. 5
0
        public async Task <ActionResult> Compare(string tabId, int parentId, [FromBody] SelectedItemsViewModel selModel, bool?boundToExternal)
        {
            var version = ArticleVersionService.GetMergedVersion(selModel.Ids, parentId);
            var model   = ArticleVersionViewModel.Create(version, tabId, parentId, boundToExternal);

            model.ViewType = ArticleVersionViewType.CompareVersions;
            return(await JsonHtml("Properties", model));
        }
Esempio n. 6
0
        public ActionResult Index()
        {
            //var domains = from domain in db.Domains.Include("Articles")
            //              orderby domain.LastArticlePublished descending
            //              select domain;

            var domains = db.Domains
                          .Include("Articles")
                          .OrderByDescending(d => d.Articles.OrderByDescending(a => a.DatePublished).FirstOrDefault().DatePublished);

            var doms = domains.ToList();
            List <DomainArticleViewModel> daVMs = new List <DomainArticleViewModel>();

            foreach (var dom in doms)
            {
                DomainArticleViewModel daVM = new DomainArticleViewModel();
                daVM.DomainId   = dom.Id;
                daVM.DomainName = dom.Title;
                daVM.articles   = new List <ArticleVersionViewModel>();

                if (dom.Articles != null)
                {
                    daVM.LastArticlePublishDate = DateTime.MinValue;
                    List <Article> la = new List <Article>();
                    la = dom.Articles.OrderByDescending(a => a.DatePublished).Take(3).ToList();
                    daVM.LastArticlePublishDate = la.FirstOrDefault().DatePublished;
                    foreach (var article in la)
                    {
                        ArticleVersionViewModel av = new ArticleVersionViewModel();
                        av.ArticleId = article.ArticleId;
                        av.VersionId = article.CurrentVersionId;
                        av.Domains   = article.Domains;
                        Models.Version v = db.Versions.Find(article.CurrentVersionId);
                        av.Title         = v.Title;
                        av.DatePublished = article.DatePublished;
                        av.LastEdit      = v.LastEdit;
                        daVM.articles.Add(av);
                    }

                    daVMs.Add(daVM);
                }
            }
            return(View(daVMs));
        }
Esempio n. 7
0
        public ActionResult Properties(string tabId, int parentId, int id, string backendActionCode, bool?boundToExternal, FormCollection collection)
        {
            var version = ArticleVersionService.Read(id);
            var model   = ArticleVersionViewModel.Create(version, tabId, parentId, boundToExternal);

            TryUpdateModel(model);
            model.Validate(ModelState);

            if (ModelState.IsValid)
            {
                model.Data.Article = ArticleVersionService.Restore(model.Data, boundToExternal, HttpContext.IsXmlDbUpdateReplayAction());
                return(Redirect("Properties", new
                {
                    tabId,
                    parentId,
                    id,
                    successfulActionCode = backendActionCode,
                    boundToExternal
                }));
            }

            return(JsonHtml("Properties", model));
        }