public void ReGeneratePages()
        {
            var session = SessionFactory.Create();
            var repos = new PageTreeRepository(session);
            var pageRepos = new PageRepository(session);
            var locator = new Mock<IServiceLocator>();
            locator.Setup(x => x.ResolveAll<IPostLoadProcessor>()).Returns(new IPostLoadProcessor[] { new ChildPageSection(pageRepos) });

            locator.Setup(x => x.ResolveAll<ITextProcessor>()).Returns(new ITextProcessor[]
                                                                           {
                                                                               new MarkdownParser(),
                                                                               new WikiLinkProcessor(repos)
                                                                           });
            locator.Setup(x => x.ResolveAll<IHtmlProcessor>()).Returns(new IHtmlProcessor[] { new HeadingProcessor() });
            var pre = new PreProcessorService(locator.Object);

            var user = new UserRepository(session).GetOrCreate("BA84194", "Jonas Gauffin");
            var myIdentity = new WikiIdentity(user);
            Thread.CurrentPrincipal = new WikiPrinicpal(myIdentity);

            using (var transaction = session.BeginTransaction())
            {
                foreach (var page in pageRepos.FindAll())
                {
                    var ctx = new PreProcessorContext(page, page.RawBody);
                    pre.Invoke(ctx);
                    page.SetBody(ctx, "Changed to relative links", pageRepos);
                }

                transaction.Commit();
            }
        }
Exemple #2
0
        public PartialViewResult _Edit(int id)
        {
            var item = new PageRepository().FindbyId(id);

            ViewBag.RootPageId = new SelectList(new PageRepository().GetAll(), "Id", "Title", item.RootPageId);
            return(PartialView("_Create", item));
        }
        public async Task SerializeDeserialize()
        {
            var siteId = await MakeSite().ConfigureAwait(false);

            using var api = CreateApi();
            MyPage page = await MyPage.CreateAsync(api).ConfigureAwait(false);

            page.SiteId    = siteId;
            page.Title     = "Startpage";
            page.Text      = "Welcome";
            page.IsHidden  = true;
            page.Published = DateTime.Now;
            await PageRepository.Save(page).ConfigureAwait(false);

            var pageId = page.Id;

            using var session     = SessionFactory.OpenSession();
            using var transaction = session.BeginTransaction();
            var pageEntities = session.Query <PageEntity>().Where(p => p.Id == pageId);
            var mapped       = Module.Mapper.ProjectTo <PageEntity>(pageEntities).First();
            var data         = JsonConvert.SerializeObject(mapped);
            var pageType     = mapped.PageType;
            var type         = pageType.GetType().FullName;

            transaction.Commit();
        }
Exemple #4
0
        private async Task CreateHomepage()
        {
            // Create a homepage with text through repositories as it's simpler
            string   createdBy = "editor";
            DateTime createdOn = DateTime.Today;

            PageRepository repository = CreatePageRepository();

            Page page = _fixture.Create <Page>();

            page.Id             = -1; // should be reset
            page.CreatedBy      = createdBy;
            page.CreatedOn      = createdOn;
            page.LastModifiedBy = createdBy;
            page.LastModifiedOn = createdOn;
            page.Tags           = "homepage";

            Page newPage = await repository.AddNewPageAsync(page);

            _outputHelper.WriteLine($"Created homepage - id: {page.Id}");

            PageVersionRepository pageRepository = CreatePageVersionRepository();
            PageVersion           pageVersion    = await pageRepository.AddNewVersionAsync(newPage.Id, "## This is some markdown\nAnd some **bold** text", "editor");

            _outputHelper.WriteLine($"Created homepage version - id: {pageVersion.Id}");
        }
Exemple #5
0
        public void RemovePage_Test()
        {
            Page page1 = this.BuildObjectPage();
            Page page2 = this.BuildObjectPage();

            PageRepository repository = new PageRepository(BaseTest.ServerMapPath);

            repository.Insert(page1);
            repository.Insert(page2);

            repository.Remove(page1.Id);

            string file = string.Concat(BaseTest.ServerMapPath, "Page_", page1.Id, ".xml");

            Assert.IsFalse(File.Exists(file), "The fille exist: " + file);

            XDocument documnetRepository = XDocument.Load(BaseTest.StorageXmlPath + "Page.xml");

            XElement pageInReposioty = documnetRepository.Root
                                       .Elements("Page")
                                       .Where(p => p.Attribute("Id").Value == page1.Id.ToString())
                                       .SingleOrDefault();

            Assert.IsNull(pageInReposioty, "The element Page does not removed");
        }
        public void UpdateModulePermissionSuccess()
        {
            //Arrange
            var pageRepository = new PageRepository(_container);
            var dbContext      = _serviceProvider.GetRequiredService <DeviserDbContext>();
            var pageModule     = TestDataRepository.GetPageModules().First();

            pageRepository.CreatePageModule(pageModule);
            var modulePermissions = TestDataRepository.GetModulePermissions();

            foreach (var mp in modulePermissions)
            {
                mp.PageModuleId = pageModule.Id;
            }

            pageModule.InheritEditPermissions = pageModule.InheritViewPermissions = true;
            pageModule.ModulePermissions      = modulePermissions;

            //Act
            pageRepository.UpdateModulePermission(pageModule);
            var result = pageRepository.GetPageModule(pageModule.Id);


            //Assert
            Assert.NotNull(result);
            Assert.True(result.ModulePermissions.Count > 1);
            Assert.True(result.InheritViewPermissions);
            Assert.True(result.InheritEditPermissions);

            //Clean
            dbContext.ModulePermission.RemoveRange(dbContext.ModulePermission);
        }
Exemple #7
0
 public FileTemplateServices(PXHotelEntities entities)
 {
     _localizedResourceServices = HostContainer.GetInstance <ILocalizedResourceServices>();
     _pageTemplateServices      = HostContainer.GetInstance <IPageTemplateServices>();
     _fileTemplateRepository    = new FileTemplateRepository(entities);
     _pageRepository            = new PageRepository(entities);
 }
Exemple #8
0
        public void CanUnlockDataofPage()
        {
            PageRepository repository = new PageRepository();
            CmsPage        newpage    = pagerepository.Get(29);

            repository.clearCurrentPageLock(newpage);
        }
        /// <summary>
        ///     Конструктор
        /// </summary>
        public DataBaseViewModel()
        {
            IRepository <Page> pageRepository = new PageRepository();

            PagesCollection = new ObservableCollection <Page>(pageRepository.GetList());
            SelectedPage    = null;
        }
Exemple #10
0
        public void CanInsertPage()
        {
            PageRepository repository = new PageRepository();

            CmsPage targetPage = new CmsPage();

            targetPage.LastModifiedBy      = "test";
            targetPage.LastUpdatedDateTime = DateTime.Now;
            targetPage.RevisionNumber      = -1;
            targetPage.ShowInMenu          = true;
            targetPage.SortOrdinal         = 1;
            targetPage.TemplateName        = "_login";
            targetPage.ParentID            = 1;

            CmsPageLanguageInfo languagein = new CmsPageLanguageInfo();

            languagein.LanguageShortCode       = "en";
            languagein.MenuTitle               = "test insert";
            languagein.SearchEngineDescription = "description of test insert";
            languagein.Title           = "test insert title";
            languagein.Page            = targetPage;
            targetPage.LanguageInfo[0] = languagein;
            Assert.That(targetPage.LanguageInfo[0].LanguageShortCode, Is.EqualTo("en"));

            CmsPage returnpage = repository.Save(targetPage);

            Assert.That(returnpage, Is.Not.Null);
        }
Exemple #11
0
 public PageCopyHelper(int sourceId, int destinationId)
 {
     SourceId      = sourceId;
     DestinationId = destinationId;
     Source        = PageRepository.GetPagePropertiesById(sourceId);
     Destination   = PageRepository.GetPagePropertiesById(destinationId);
 }
Exemple #12
0
        public static int CopySiteTemplates(int sourceSiteId, int destinationSiteId, int templateNumber)
        {
            var templateIdNew       = PageTemplateRepository.CopySiteTemplates(sourceSiteId, destinationSiteId, templateNumber);
            var relBetweenTemplates = PageTemplateRepository.GetRelationsBetweenTemplates(sourceSiteId, destinationSiteId, templateIdNew);
            var relBetweenContents  = ContentRepository.GetRelationsBetweenContentsXml(sourceSiteId, destinationSiteId, string.Empty);

            PageRepository.CopySiteTemplatePages(sourceSiteId, destinationSiteId, relBetweenTemplates);

            var relBetweenPages = PageRepository.GetRelationsBetweenPages(relBetweenTemplates);

            ObjectRepository.CopySiteTemplateObjects(relBetweenTemplates, relBetweenPages, out var relBetweenObjects);

            ObjectFormatRepository.CopySiteTemplateObjectFormats(relBetweenObjects, out var relBetweenObjectFormats);

            ObjectRepository.CopySiteUpdateObjects(relBetweenObjectFormats, relBetweenObjects);
            ObjectRepository.CopySiteObjectValues(relBetweenObjects);
            ObjectRepository.CopySiteContainers(relBetweenObjects, relBetweenContents);

            var relBetweenStatuses = ContentRepository.GetRelationsBetweenStatuses(sourceSiteId, destinationSiteId);

            ObjectRepository.CopyContainerStatuses(relBetweenStatuses, relBetweenObjects);

            NotificationRepository.CopySiteUpdateNotifications(relBetweenObjectFormats, relBetweenContents);

            return(templateIdNew != 0 ? 1 : 0);
        }
Exemple #13
0
        public async Task FindPagesLastModifiedBy_should_find_pages_with_case_insensitive_search()
        {
            // given
            PageRepository repository = CreateRepository();

            CreateTenPages(repository);             // add random pages

            var page1 = _fixture.Create <Page>();
            var page2 = _fixture.Create <Page>();

            page1.LastModifiedBy = "THAT guy";
            page2.LastModifiedBy = "That Guy";

            await repository.AddNewPageAsync(page1);

            await repository.AddNewPageAsync(page2);

            // when
            IEnumerable <Page> actualPages = await repository.FindPagesLastModifiedByAsync("that guy");

            // then
            actualPages.Count().ShouldBe(2);
            actualPages.First(x => x.Id == page1.Id).ShouldNotBeNull();
            actualPages.First(x => x.Id == page2.Id).ShouldNotBeNull();
        }
Exemple #14
0
        public async void AddNewPage_should_add_page_and_increment_id()
        {
            // given
            string   createdBy = "lyon";
            DateTime createdOn = DateTime.Today;

            PageRepository repository = CreateRepository();

            Page page = _fixture.Create <Page>();

            page.Id             = -1; // should be reset
            page.CreatedBy      = createdBy;
            page.CreatedOn      = createdOn;
            page.LastModifiedBy = createdBy;
            page.LastModifiedOn = createdOn;

            // when
            await repository.AddNewPageAsync(page);

            Page actualPage = await repository.AddNewPageAsync(page);

            // then
            actualPage.ShouldNotBeNull();
            actualPage.CreatedOn.ShouldBe(createdOn);
            actualPage.CreatedBy.ShouldBe(createdBy);

            Page savedVersion = await repository.GetPageByIdAsync(actualPage.Id);

            savedVersion.ShouldNotBeNull();
            savedVersion.Id.ShouldBeGreaterThanOrEqualTo(1);
        }
Exemple #15
0
        public async Task FindPagesContainingTag_should_find_tags_using_case_insensitive_search()
        {
            // given
            PageRepository repository = CreateRepository();

            CreateTenPages(repository);

            List <Page> pages = _fixture.CreateMany <Page>(3).ToList();

            pages.ForEach(p => p.Tags = _fixture.Create <string>() + ", facebook-data-leak");
            await repository.AddNewPageAsync(pages[0]);

            await repository.AddNewPageAsync(pages[1]);

            await repository.AddNewPageAsync(pages[2]);

            // when
            var actualPages = await repository.FindPagesContainingTagAsync("facebook-data-leak");

            // then
            actualPages.Count().ShouldBe(3);
            actualPages.First(x => x.Id == pages[0].Id).ShouldNotBeNull();
            actualPages.First(x => x.Id == pages[1].Id).ShouldNotBeNull();
            actualPages.First(x => x.Id == pages[2].Id).ShouldNotBeNull();
        }
 public FileTemplateServices(PXHotelEntities entities)
 {
     _localizedResourceServices = HostContainer.GetInstance<ILocalizedResourceServices>();
     _pageTemplateServices = HostContainer.GetInstance<IPageTemplateServices>();
     _fileTemplateRepository = new FileTemplateRepository(entities);
     _pageRepository = new PageRepository(entities);
 }
Exemple #17
0
 static void Initialize()
 {
     mangaRepository   = new MangaRepository(config);
     chapterRepository = new ChapterRepository(config);
     pageRepository    = new PageRepository(config);
     tagRepository     = new TagRepository(config);
 }
Exemple #18
0
        public BllObject NewObjectProperties(int parentId, bool pageOrTemplate)
        {
            var obj = BllObject.Create(parentId, pageOrTemplate);

            obj.PageTemplate = pageOrTemplate ? PageRepository.GetPagePropertiesById(parentId).PageTemplate : PageTemplateRepository.GetPageTemplatePropertiesById(parentId);
            return(obj);
        }
 public MenuContentController()
 {
     menuRepository        = new MenuRepository(DbContext);
     contentRepository     = new ContentRepository(DbContext);
     pageRepository        = new PageRepository(DbContext);
     contentTypeRepository = new ContentTypeRepository(DbContext);
 }
        public void GetPageTranslationFail()
        {
            //Arrange
            var pageRepository  = new PageRepository(_container);
            var dbContext       = _serviceProvider.GetRequiredService <DeviserDbContext>();
            var pages           = TestDataRepository.GetPages();
            var page            = pages.First();
            var pagePermissions = page.PagePermissions;

            pagePermissions.Add(new PagePermission
            {
                Id           = Guid.NewGuid(),
                PermissionId = Guid.NewGuid(),
                RoleId       = Guid.NewGuid(),
            });
            pageRepository.CreatePage(page);
            var pageTranslation = page.PageTranslation.First();

            //Act
            var result = pageRepository.GetPageTranslations(null);

            //Assert
            Assert.Null(result);

            //Clean
            dbContext.Page.RemoveRange(dbContext.Page);
        }
        public void CreatePageModuleSuccess()
        {
            //Arrange
            var pageRepository = new PageRepository(_container);
            var dbContext      = _serviceProvider.GetRequiredService <DeviserDbContext>();
            var pageModules    = TestDataRepository.GetPageModules();
            var pageModule     = pageModules.First();

            //Act
            var result           = pageRepository.CreatePageModule(pageModule);
            var resultPermission = result.ModulePermissions.First();

            //Assert
            Assert.NotNull(result);
            Assert.NotNull(result.ModuleAction);
            Assert.NotNull(result.ModulePermissions);
            Assert.True(result.ModulePermissions.Count > 0);
            Assert.NotNull(resultPermission);
            Assert.True(resultPermission.Id != Guid.Empty);
            Assert.True(resultPermission.PermissionId != Guid.Empty);
            Assert.True(resultPermission.RoleId != Guid.Empty);

            //Clean
            dbContext.PageModule.RemoveRange(dbContext.PageModule);
        }
        public void UpdatePageModulesSuccess()
        {
            //Arrange
            var pageRepository = new PageRepository(_container);
            var dbContext      = _serviceProvider.GetRequiredService <DeviserDbContext>();
            var pageModules    = TestDataRepository.GetPageModules();

            foreach (var pageModule in pageModules)
            {
                pageModule.ModulePermissions = null;
                pageRepository.CreatePageModule(pageModule);
            }

            var pageModuleToUpdate = pageModules.First();

            pageModuleToUpdate.SortOrder = 10;
            var pageModulesToUpdate = new List <PageModule>
            {
                pageModuleToUpdate
            };

            //Act
            pageRepository.UpdatePageModules(pageModulesToUpdate);
            var result = pageRepository.GetPageModule(pageModuleToUpdate.Id);

            //Assert
            Assert.NotNull(result);
            Assert.True(result.SortOrder == pageModuleToUpdate.SortOrder);

            //Clean
            dbContext.PageModule.RemoveRange(dbContext.PageModule);
        }
        public void GetPageSuccess()
        {
            //Arrange
            var pageRepository = new PageRepository(_container);
            var dbContext      = _serviceProvider.GetRequiredService <DeviserDbContext>();
            var pages          = TestDataRepository.GetPages();
            var page           = pages.First();

            pageRepository.CreatePage(page);


            //Act
            var result = pageRepository.GetPage(page.Id);
            var resultPageTranslation = result.PageTranslation.First();

            //Assert
            Assert.NotNull(result);
            Assert.NotEqual(result.Id, Guid.Empty);
            Assert.NotNull(result.PageTranslation);
            Assert.True(result.PageTranslation.Count > 0);
            Assert.NotNull(result.PagePermissions);
            Assert.True(result.PagePermissions.Count > 0);
            Assert.True(result.CreatedDate > DateTime.MinValue);
            Assert.True(result.LastModifiedDate > DateTime.MinValue);
            Assert.NotNull(resultPageTranslation);
            Assert.True(!string.IsNullOrEmpty(resultPageTranslation.Name));
            Assert.True(!string.IsNullOrEmpty(resultPageTranslation.Description));
            Assert.True(!string.IsNullOrEmpty(resultPageTranslation.Locale));
            Assert.True(!string.IsNullOrEmpty(resultPageTranslation.Title));
            Assert.True(!string.IsNullOrEmpty(resultPageTranslation.URL));

            //Clean
            dbContext.Page.RemoveRange(dbContext.Page);
        }
        public void UpdatePageTreeFail()
        {
            //Arrange
            var  pageRepository = new PageRepository(_container);
            var  dbContext      = _serviceProvider.GetRequiredService <DeviserDbContext>();
            var  pages          = TestDataRepository.GetPages();
            Page parentPage     = pages.First();

            pages.Remove(parentPage);
            pageRepository.CreatePage(parentPage);
            parentPage.ChildPage = new List <Page>();
            foreach (var page in pages)
            {
                page.ParentId = parentPage.Id;
                pageRepository.CreatePage(page);
                parentPage.ChildPage.Add(page);
            }

            //Act
            Page pageToUpdate = null;

            var result = pageRepository.UpdatePageTree(pageToUpdate);

            //Assert
            Assert.Null(result);

            //Clean
            dbContext.Page.RemoveRange(dbContext.Page);
        }
        // Save the map to the context
        public void Save(Episode episode)
        {
            // First, find if another episode was inserted before
            if (this.EpisodeHasBeenLoaded(episode.EpisodeNumber, episode.Idiom) == false)
            {
                // If is not, insert a new episode
                var sqlCommand = new SqlCommand("INSERT INTO EPISODES(EpisodeNumber, IDIOM, Prologue, Title, ImgHeaderPath) VALUES(@EPISODENUMBER, @IDIOM, @Prologue, @Title, @ImgHeaderPath)");
                // Set parameters
                sqlCommand.Parameters.AddWithValue("EPISODENUMBER", episode.EpisodeNumber);
                sqlCommand.Parameters.AddWithValue("IDIOM", episode.Idiom);
                sqlCommand.Parameters.AddWithValue("Prologue", episode.Prologue);
                sqlCommand.Parameters.AddWithValue("Title", episode.Title);
                sqlCommand.Parameters.AddWithValue("ImgHeaderPath", episode.ImgHeaderPath);
                
                SQLOperation.ExecuteSQLCommand(sqlCommand);
            }


            // Adding all pages
            var pageRep = new PageRepository();

            foreach (Page page in episode.Pages)
            {
                page.episodeNumber = episode.EpisodeNumber;
                pageRep.Save(page);
            }

        }
Exemple #26
0
        public void CanGetAllPage()
        {
            PageRepository  repository = new PageRepository();
            IList <CmsPage> pagelist   = repository.FetchPagesByTemplateName("_login");

            Assert.That(pagelist, Is.Not.Null);
        }
        public void GetPageTranslationSuccess()
        {
            //Arrange
            var pageRepository  = new PageRepository(_container);
            var dbContext       = _serviceProvider.GetRequiredService <DeviserDbContext>();
            var pages           = TestDataRepository.GetPages();
            var page            = pages.First();
            var pagePermissions = page.PagePermissions;

            pagePermissions.Add(new PagePermission
            {
                Id           = Guid.NewGuid(),
                PermissionId = Guid.NewGuid(),
                RoleId       = Guid.NewGuid(),
            });
            pageRepository.CreatePage(page);
            var pageTranslation = page.PageTranslation.First();

            //Act
            var result = pageRepository.GetPageTranslation(pageTranslation.URL);

            //Assert
            Assert.NotNull(result);
            Assert.True(!string.IsNullOrEmpty(result.Name));
            Assert.True(!string.IsNullOrEmpty(result.Description));
            Assert.True(!string.IsNullOrEmpty(result.Locale));
            Assert.True(!string.IsNullOrEmpty(result.Title));
            Assert.True(!string.IsNullOrEmpty(result.URL));

            //Clean
            dbContext.Page.RemoveRange(dbContext.Page);
        }
Exemple #28
0
        public void CanCreatepage()
        {
            PageRepository repository = new PageRepository();
            CmsPage        newpage    = pagerepository.Get(29);

            Assert.That(newpage, Is.Not.Null);
        }
Exemple #29
0
        public MessageResult MultipleAssemblePage(int[] ids)
        {
            var failedIds = new List <int>();

            foreach (var id in ids)
            {
                var page = PageRepository.GetPagePropertiesById(id);
                if (page.PageTemplate.SiteIsDotNet)
                {
                    new AssemblePageController(id, QPContext.CurrentDbConnectionString).Assemble();
                    AssembleRepository.UpdatePageStatus(id, QPContext.CurrentUserId);
                }
                else
                {
                    var token   = _qp7Service.Authenticate();
                    var message = _qp7Service.AssemblePage(id, token);
                    if (!string.IsNullOrEmpty(message))
                    {
                        failedIds.Add(id);
                    }
                }
            }

            return(failedIds.Any()
                ? MessageResult.Error(SiteStrings.AssemblePagesError + string.Join(", ", failedIds), failedIds.ToArray())
                : null);
        }
Exemple #30
0
        public void CanGetLockDataFromPageRepository()
        {
            PageRepository repository = new PageRepository();
            CmsPage        newpage    = pagerepository.Get(29);

            Assert.That(repository.getPageLockData(newpage), Is.Null);
        }
Exemple #31
0
        public MessageResult AssemblePagePreAction(int id)
        {
            var site    = PageRepository.GetPagePropertiesById(id).PageTemplate.Site;
            var message = !site.IsLive ? null : string.Format(SiteStrings.SiteInLiveWarning, site.ModifiedToDisplay, site.LastModifiedByUserToDisplay);

            return(string.IsNullOrEmpty(message) ? null : MessageResult.Confirm(message));
        }
        public void Run()
        {
            var rootPages = new PageRepository().GetRootNodes();


            Route modalRoute = new Route("Modals/Modal/{*value}", new SalesRouteHandler("~/Modals/Modal.aspx"));

            Routes.Add(modalRoute);

            //Route wcfRoute = new Route("Services/WCFService/{*value}", new SalesRouteHandler("~/Services/Service.svc"));
            //Routes.Add(wcfRoute);

            Route defaultRoute = new Route("Home", new SalesRouteHandler("~/Default.aspx"));

            Routes.Add(defaultRoute);



            BuildUtilityRoutes();
            BuildAccountRoutes();
            BuildSalesRoutes();
            BuildProjectRoutes();
            BuildSupportRoutes();

            //Errors 404's mostly
            //Route errorRoute = new Route("{*catchall}", new ErrorRouteHandler("~/UtilityPages/Error.aspx"));
            //Routes.Add(errorRoute);
        }
Exemple #33
0
        public async Task FindPagesCreatedBy_should_find_pages_created_by_with_case_insensitive_search()
        {
            // given
            PageRepository repository = CreateRepository();

            CreateTenPages(repository);             // add random data

            var page1 = _fixture.Create <Page>();
            var page2 = _fixture.Create <Page>();

            page1.CreatedBy = "myself";
            page2.CreatedBy = "MYSELf";

            await repository.AddNewPageAsync(page1);

            await repository.AddNewPageAsync(page2);

            // when
            IEnumerable <Page> actualPages = await repository.FindPagesCreatedByAsync("myself");

            // then
            actualPages.Count().ShouldBe(2);
            actualPages.First(x => x.Id == page1.Id).ShouldNotBeNull();
            actualPages.First(x => x.Id == page2.Id).ShouldNotBeNull();
        }
        public void Create5NewPageSuccessfulTest()
        {
            using (UnitOfWork uow = new UnitOfWork())
            {
                PageRepository pr = new PageRepository(uow.Current);
                BlogRepository br = new BlogRepository(uow.Current);

                Blog.Model.Domain.Entities.Blog b = new Blog.Model.Domain.Entities.Blog("Nombe blog", "Desc blog");

                Category c = new Category("Categoria 1", "Desc 1");
                Author a = new Author("Nome autore", "Cognome autore", Convert.ToDateTime("27/12/1987"), "*****@*****.**", true, "pass", b);

                Page p1 = new Page("Nome pagina 1", "descr pagine", DateTime.Now, "test", a, b, c);
                Page p2 = new Page("Nome pagina 2", "descr pagine", DateTime.Now, "test", a, b, c);
                Page p3 = new Page("Nome pagina 3", "descr pagine", DateTime.Now, "test", a, b, c);
                Page p4 = new Page("Nome pagina 4", "descr pagine", DateTime.Now, "test", a, b, c);
                Page p5 = new Page("Nome pagina 5", "descr pagine", DateTime.Now, "test", a, b, c);

                br.Save(b);
                pr.Save(p1);
                pr.Save(p2);
                pr.Save(p3);
                pr.Save(p4);
                pr.Save(p5);

                uow.Commit();
            }
        }
Exemple #35
0
        public static PageRepository CreatePageRepository(out IUnitOfWork unitOfWork)
        {
            var dbContext = Fixture.DbContextBuilder.BuildDbContext();
            var repository = new PageRepository((IDbContext)dbContext);

            unitOfWork = ReinitializeDatabase(dbContext);
            return repository;
        }
        public void WhenGetAllFromEmptyDatabase_ThenReturnsEmptyCollection()
        {
            var repository = new PageRepository(new DatabaseFactory());
            IEnumerable<Page> actual = repository.GetAll();

            Assert.NotNull(actual);
            var actualList = new List<Page>(actual);
            Assert.Equal(0, actualList.Count);
        }
 public PageTemplateServices(PXHotelEntities entities)
 {
     _localizedResourceServices = HostContainer.GetInstance<ILocalizedResourceServices>();
     _pageTemplateLogServices = HostContainer.GetInstance<IPageTemplateLogServices>();
     _settingServices = HostContainer.GetInstance<ISettingServices>();
     _templateServices = HostContainer.GetInstance<ITemplateServices>();
     _userServices = HostContainer.GetInstance<IUserServices>();
     _pageTemplateRepository = new PageTemplateRepository(entities);
     _fileTemplateRepository = new FileTemplateRepository(entities);
     _pageRepository = new PageRepository(entities);
     _pageTemplateLogRepository = new PageTemplateLogRepository(entities);
 }
Exemple #38
0
        public void TestMethod1()
        {
            var session = SessionFactory.Create();
            var repository = new PageRepository(session);

            //var wikiParser = new WikiParser(new Mock<IPageLinkGenerator>().Object);
            //var parser = new TextFormatAndWikiContentParser(new MarkdownParser(), wikiParser);
            //var svc = new PageService(repository, parser, null);

            //var page = svc.CreatePage(0, new PagePath("/somepage/"), "Some page 2", "Hwllo world!", 0);

            //repository.Delete("SomePage2");

            session.Flush();
        }
Exemple #39
0
 public PageServices(PXHotelEntities entities)
 {
     _localizedResourceServices = HostContainer.GetInstance<ILocalizedResourceServices>();
     _pageTemplateServices = HostContainer.GetInstance<IPageTemplateServices>();
     _curlyBracketServices = HostContainer.GetInstance<ICurlyBracketServices>();
     _clientMenuServices = HostContainer.GetInstance<IClientMenuServices>();
     _pageLogServices = HostContainer.GetInstance<IPageLogServices>();
     _settingServices = HostContainer.GetInstance<ISettingServices>();
     _templateServices = HostContainer.GetInstance<ITemplateServices>();
     _userServices = HostContainer.GetInstance<IUserServices>();
     _pageRepository = new PageRepository(entities);
     _clientMenuRepository = new ClientMenuRepository(entities);
     _pageLogRepository = new PageLogRepository(entities);
     _pageTagRepository = new PageTagRepository(entities);
     _tagRepository = new TagRepository(entities);
 }
        public void Generate()
        {
            var session = SessionFactory.Create();
            var repos = new PageTreeRepository(session);
            var pageRepos = new PageRepository(session);
            var locator = new Mock<IServiceLocator>();
            locator.Setup(x => x.ResolveAll<IPostLoadProcessor>()).Returns(new IPostLoadProcessor[] { new ChildPageSection(pageRepos) });

            locator.Setup(x => x.ResolveAll<ITextProcessor>()).Returns(new ITextProcessor[]
                                                                           {
                                                                               new MarkdownParser(),
                                                                               new WikiLinkProcessor(repos)
                                                                           });
            locator.Setup(x => x.ResolveAll<IHtmlProcessor>()).Returns(new IHtmlProcessor[] { new HeadingProcessor() });
            var pre = new PreProcessorService(locator.Object);


            var service = new OneDocService(repos, pre, new ImageRepository(session), new PostLoadProcessService(locator.Object));
            service.GenerateHTML("C:\\temp\\html\\working\\",
                                 new StreamWriter(new FileStream("C:\\temp\\html\\wiki.html", FileMode.Create)));
        }
        // Lookup one Episode and return it if is found
        public Episode Load(int episodeNumber, string episodeIdiom)
        {
            var sqlCommand = new SqlCommand("SELECT * FROM EPISODES WHERE EPISODENUMBER = @EPISODENUMBER");
            sqlCommand.Parameters.AddWithValue("EPISODENUMBER", episodeNumber);
            var dt = SQLOperation.ExecuteSQLCommandWithResult(sqlCommand);

            if (dt.Tables[0].Rows.Count <= 0)
            {
                return null;
            }
            
            //Setting a loaded episode
            var episode = new Episode();
            episode.EpisodeNumber = Int16.Parse(dt.Tables[0].Rows[0]["EPISODENUMBER"].ToString());
            episode.Idiom = dt.Tables[0].Rows[0]["idiom"].ToString();

            // Loading all Episode pages
            var pageRep = new PageRepository();
            episode.Pages = pageRep.LoadFromEpisode(episode.EpisodeNumber);
            
            // Sending the episode
            return episode;
            
        }
Exemple #42
0
        public ActionResult Index()
        {
            try 
            {
                HomePageViewModel m = new HomePageViewModel();
                using (UnitOfWork uow = new UnitOfWork())
                {
                    //Carica gli ultimi 10 POST
                    PageRepository pr = new PageRepository(uow.Current);

                    IList<Page> pages = pr.GetTopPost(10);
                    if (pages != null && pages.Count>0)
                    {
                        int k = 0;
                        foreach (var p in pages)
                        {
                            PostViewModel pTemp = new PostViewModel();

                            pTemp.Id = p.Id;
                            pTemp.Data = p.Date.Value;
                            pTemp.Testo = p.BodyText;
                            pTemp.Titolo = p.Title;
                            pTemp.Autore = String.Format("{0} {1}", p.Author.Name, p.Author.Surname);
                            pTemp.Categoria = p.Category.Name;
                            pTemp.IdCategoria = p.Category.Id;
                            pTemp.Visualizzazioni = p.Views;
                            pTemp.NumComments = p.Comments.Count;

                            if (k < 5)
                                m.PostDetail.Add(pTemp);
                            else
                                m.PostPreview.Add(pTemp);

                            k++;
                        }
                    }
                    else
                    {
                        PostViewModel pTemp = new PostViewModel();

                        pTemp.Id = 0;
                        pTemp.Data = DateTime.Today;
                        pTemp.Titolo = "OOPS...";
                        pTemp.Testo = "Sembra non siano presenti articoli...";
                        pTemp.Autore = "Pasquale Garzillo";

                        m.PostDetail.Add(pTemp);
                        m.PostPreview.Add(pTemp);
                    }
                   
                    //Carica le ultime 5 categoria con maggiori post
                    CategoryRepository cr = new CategoryRepository(uow.Current);
                    IList<Category> tempCats = cr.GetTopCategoryByPostCount(3);
                    if (tempCats != null && tempCats.Count > 0)
                    {
                        foreach (var c in tempCats)
                        {
                            CategoryViewModel cvTemp = new CategoryViewModel();

                            cvTemp.Id = c.Id;
                            cvTemp.Nome = c.Name;
                            cvTemp.Descrizione = c.Description;
                            cvTemp.FileName = c.ImageName;

                            m.CategoriesPreview.Add(cvTemp);
                        }
                    }
                    else
                    {
                        CategoryViewModel cvTemp = new CategoryViewModel();

                        cvTemp.Id = 0;
                        cvTemp.Nome = "OOPS...";
                        cvTemp.Descrizione = "Sembra non siano presenti categorie...";

                        m.CategoriesPreview.Add(cvTemp);
                    }
                }
                return View(m);
            }
            catch (Exception ex)
            {
                //Errore durante recupero dei dati
                //Errore gestibile, non è necessario reindirizzare alla pagine di errore
                //PostViewModel pTemp = new PostViewModel();

                //pTemp.Id = 0;
                //pTemp.Data = DateTime.Today;
                //pTemp.Titolo = "OOPS...";
                //pTemp.Testo = "Sembra non siano presenti articoli...";
                //pTemp.Autore = "Pasquale Garzillo";

                //m.PostDetail.Add(pTemp);

                //CategoryViewModel cvTemp = new CategoryViewModel();

                //cvTemp.Id = 0;
                //cvTemp.Nome = "OOPS...";
                //cvTemp.Descrizione = "Sembra non siano presenti categorie...";

                //m.CategoriesPreview.Add(cvTemp);
                return Error(ex);
            }
        }
        static void Main(string[] args)
        {
            var redisUri = ConfigurationManager.AppSettings["Redis_Server_Uri"];
            IRedisClientsManager clientManger = new PooledRedisClientManager(redisUri);
            PageRepository pageRepository = new PageRepository(clientManger.GetClient());

            // bin\windows\zookeeper-server-start.bat config\zookeeper.properties
            // bin\windows\kafka-server-start.bat config\server.properties
            // bin\windows\kafka-console-consumer.bat --zookeeper localhost:2181 --topic PageLoadTime --from-beginning
            // kafka-console-producer.bat --broker-list localhost:9092 --topic PageLoadTime

            //// CONSUMER READING OFF THE QUEUE
            //var options = new KafkaOptions(new Uri("http://localhost:9092"));
            //var router = new BrokerRouter(options);

            //var redisClient = new RedisClient("127.0.0.1:6379");
            //var db = redisClient.Instance(1);

            //var consumer = new Consumer(new ConsumerOptions("PageLoadTime", router));
            //var allData = consumer.Consume();
            //Task.Factory.StartNew(() =>
            //    {
            //        int i = 0;
            //        foreach (var data in allData)
            //        {
            //            if (string.IsNullOrEmpty(data.Key))
            //            {
            //                continue;
            //            }
            //            Console.ForegroundColor = ConsoleColor.Green;
            //            Console.WriteLine(string.Format("Reading {0} message => {1}", i, data.Value));
            //            Console.ForegroundColor = ConsoleColor.Yellow;
            //            Console.WriteLine("----------------------------------------------------------");
            //            db.StringSetAsync(data.Key, data.Value.ToString(CultureInfo.InvariantCulture));
            //            i++;
            //        }
            //    });

            var redisData = pageRepository.GetAll();
            DisplayAll(redisData);
            // CONSUMER READING OFF THE QUEUE + REDIS

            var clientSettings = new MessageBusClient();
            var router = clientSettings.GetClientRouter();
            var consumer = new JsonConsumer<PageModel>(new ConsumerOptions("PageLoadTime", router));

            var allData = consumer.Consume();

            Task.Factory.StartNew(() =>
                {
                    foreach (var data in allData)
                    {
                        if (string.IsNullOrEmpty(data.Value.Key))
                        {
                            continue;
                        }

                        var page = pageRepository.Store(data.Value);
                        DisplaySingle(page);
                    }
                });

            Console.ReadKey();
        }
        public ActionResult PageDetail(int id)
        {
            try
            {
                PageViewModel pvm = new PageViewModel();
                using (UnitOfWork uow = new UnitOfWork())
                {
                    PageRepository pr = new PageRepository(uow.Current);
                    AuthorRepository ar = new AuthorRepository(uow.Current);
                    BlogRepository br = new BlogRepository(uow.Current);
                    CategoryRepository cr = new CategoryRepository(uow.Current);

                    Page p = pr.GetById(id);
                    if (p != null)
                    {
                        IList<Author> tmpAuthors = ar.FindAll().ToList();
                        if (tmpAuthors != null && tmpAuthors.Count > 0)
                        {
                            IEnumerable<SelectListItem> tmpAuthorsItems;

                            tmpAuthorsItems =   from s in tmpAuthors
                                                select new SelectListItem
                                                {
                                                    Text = s.NameAndSurname,
                                                    Value = s.Id.ToString()
                                                };

                            pvm.Authors = tmpAuthorsItems;
                            pvm.SelectedAuthor = p.Author.Id.ToString();
                        }
                        IList<Blog.Model.Domain.Entities.Blog> tmpBlogs = br.FindAll().ToList();
                        if (tmpBlogs != null && tmpBlogs.Count > 0)
                        {
                            IEnumerable<SelectListItem> tmpBlogsItems;

                            tmpBlogsItems = from b in tmpBlogs
                                              select new SelectListItem
                                              {
                                                  Text = b.Name,
                                                  Value = b.Id.ToString()
                                              };

                            pvm.Blogs = tmpBlogsItems;
                            pvm.SelectedBlog = p.Blog.Id.ToString();
                        }
                        IList<Category> tmpCategories = cr.FindAll().ToList();
                        if (tmpCategories != null && tmpCategories.Count > 0)
                        {
                            IEnumerable<SelectListItem> tmpCategoriesItems;

                            tmpCategoriesItems = from b in tmpCategories
                                            select new SelectListItem
                                            {
                                                Text = b.Name,
                                                Value = b.Id.ToString()
                                            };

                            pvm.Categories = tmpCategoriesItems;
                            pvm.SelectedCategory = p.Category.Id.ToString();
                        }

                        pvm.Data = p.Date.Value;
                        pvm.Id = p.Id;
                        pvm.Titolo = p.Title;
                        pvm.Descrizione = p.Description;
                        pvm.FileName = p.ImageName;
                        pvm.Body = p.BodyText;

                        if (p.Tags != null && p.Tags.Count > 0)
                            pvm.Tags = String.Join(", ", p.Tags.Select(x=>x.Name));
                    }
                }
                return View(pvm);
            }
            catch (Exception ex)
            {
                return Error(ex);
            }
        }
        public ActionResult Pages()
        {
            try
            {
                IList<PageViewModel> postList = null;
                using (UnitOfWork uow = new UnitOfWork())
                {
                    PageRepository pr = new PageRepository(uow.Current);
                    IList<Page> tmpList = pr.FindAll().ToList();
                    if (tmpList != null)
                    {
                        postList = new List<PageViewModel>();
                        foreach (var p in tmpList)
                        {
                            PageViewModel pvm = new PageViewModel();

                            pvm.Id = p.Id;
                            pvm.Data = p.Date.Value;
                            pvm.Titolo = p.Title;
                            pvm.Autore = p.Author.NameAndSurname;
                            pvm.Categoria = p.Category.Name;

                            postList.Add(pvm);
                        }
                    }
                }
                return View(postList);
            }
            catch (Exception ex)
            {
                return Error(ex);
            }
        }
        public ActionResult PageNew(PageViewModel model) 
        {
            try
            {
                //Carica tutti gli elementi necessari a video
                using (UnitOfWork uow = new UnitOfWork())
                {
                    AuthorRepository ar = new AuthorRepository(uow.Current);
                    BlogRepository br = new BlogRepository(uow.Current);
                    CategoryRepository cr = new CategoryRepository(uow.Current);

                    //Ricarica la lista autori
                    IList<Author> tmpAuthors = ar.FindAll().ToList();
                    if (tmpAuthors != null && tmpAuthors.Count > 0)
                    {
                        IEnumerable<SelectListItem> tmpAuthorsItems;

                        tmpAuthorsItems = from s in tmpAuthors
                                          select new SelectListItem
                                          {
                                              Text = s.NameAndSurname,
                                              Value = s.Id.ToString()
                                          };

                        model.Authors = tmpAuthorsItems;
                    }

                    IList<Blog.Model.Domain.Entities.Blog> tmpBlogs = br.FindAll().ToList();
                    if (tmpBlogs != null && tmpBlogs.Count > 0)
                    {
                        IEnumerable<SelectListItem> tmpBlogsItems;

                        tmpBlogsItems = from b in tmpBlogs
                                        select new SelectListItem
                                        {
                                            Text = b.Name,
                                            Value = b.Id.ToString()
                                        };

                        model.Blogs = tmpBlogsItems;
                    }

                    IList<Category> tmpCategories = cr.FindAll().ToList();
                    if (tmpCategories != null && tmpCategories.Count > 0)
                    {
                        IEnumerable<SelectListItem> tmpCategoriesItems;

                        tmpCategoriesItems = from b in tmpCategories
                                             select new SelectListItem
                                             {
                                                 Text = b.Name,
                                                 Value = b.Id.ToString()
                                             };

                        model.Categories = tmpCategoriesItems;
                    }
                }

                if (ModelState.IsValid)
                {
                    using (UnitOfWork uow = new UnitOfWork())
                    {
                        string fileName = null;
                        if (model.File != null && model.File.ContentLength > 0)
                        {
                            //SALVA IL FILE
                            fileName = Path.GetFileName(model.File.FileName);
                            var path = Path.Combine(Server.MapPath("/Uploads"), fileName);
                            model.File.SaveAs(path);
                            model.FileName = fileName;
                        }

                        model.SelectedAuthor = model.SelectedAuthor;
                        model.SelectedBlog = model.SelectedBlog;
                        model.SelectedCategory = model.SelectedCategory;

                        PageRepository pr = new PageRepository(uow.Current);
                        AuthorRepository ar = new AuthorRepository(uow.Current);
                        BlogRepository br = new BlogRepository(uow.Current);
                        CategoryRepository cr = new CategoryRepository(uow.Current);
                        TagRepository tr = new TagRepository(uow.Current);

                        Author au = ar.GetById(Convert.ToInt32(model.SelectedAuthor));
                        Blog.Model.Domain.Entities.Blog bb = br.GetById(Convert.ToInt32(model.SelectedBlog));
                        Category cc = cr.GetById(Convert.ToInt32(model.SelectedCategory));

                        Page p = new Page(model.Titolo, model.Descrizione, model.Data, model.Body, au, bb, cc);

                        if (!String.IsNullOrEmpty(model.Tags))
                        {
                            foreach(var t in model.Tags.Split(','))
                            {
                                if (!String.IsNullOrEmpty(t))
                                {
                                    Tag tg = tr.GetTagByName(t.TrimStart().TrimEnd());
                                    if (tg != null)
                                    {
                                        p.AddTag(tg);
                                    }
                                    else
                                    {
                                        Tag tempTag = new Tag(t.TrimStart().TrimEnd());
                                        p.AddTag(tempTag);
                                    }
                                }
                            }
                        }

                        if (!String.IsNullOrEmpty(fileName))
                            p.SetImagePath(fileName);
                        else
                            model.FileName = p.ImageName;

                        pr.SaveOrUpdate(p);
                        uow.Commit();

                        model.Message = "Salvataggio eseguito con successo!";
                    }
                }
                return View(model);
            }
            catch (Exception ex)
            {
                return Error(ex);
            }
        }
        public ActionResult PageRemoveImage(int id)
        {
            try
            {
                using (UnitOfWork uow = new UnitOfWork())
                {
                    PageRepository pr = new PageRepository(uow.Current);

                    Page p = pr.GetById(id);

                    if (p != null)
                    {
                        p.SetImagePath(null);

                        pr.SaveOrUpdate(p);
                        uow.Commit();

                        return RedirectToAction("PageDetail", new { id = p.Id });
                    }
                    else
                    {
                        return Error("Si è verificato un errore durante la rimozione dell'immagine");
                    }
                }
            }
            catch (Exception ex)
            {
                return Error(ex);
            }
        }
Exemple #48
0
        public ActionResult PostComment(DetailPageViewModel model, FormCollection collection)
        {
            try
            {
                int pageId = Convert.ToInt32(collection["IdPagina"]);
                if (ModelState.IsValid)
                {
                    using (UnitOfWork uow = new UnitOfWork())
                    {
                        PageRepository pr = new PageRepository(uow.Current);
                        Page p = pr.GetById(pageId);

                        Comment c = new Comment(model.Comment.UserName, model.Comment.UserMail, model.Comment.TextComment, p);
                        p.AddComment(c);
                        uow.Commit();
                    }
                }

                DetailPageViewModel m = new DetailPageViewModel();
                using (UnitOfWork uow = new UnitOfWork())
                {
                    //Carica gli ultimi 5 POST
                    PageRepository pr = new PageRepository(uow.Current);

                    IList<Page> pages = pr.GetTopPost(5);
                    if (pages != null && pages.Count > 0)
                    {
                        int k = 0;
                        foreach (var p in pages)
                        {
                            PostViewModel pTemp = new PostViewModel();

                            pTemp.Id = p.Id;
                            pTemp.Data = p.Date.Value;
                            pTemp.Testo = p.BodyText;
                            pTemp.Titolo = p.Title;
                            pTemp.Autore = String.Format("{0} {1}", p.Author.Name, p.Author.Surname);
                            pTemp.Categoria = p.Category.Name;
                            pTemp.IdCategoria = p.Category.Id;
                            pTemp.ImageName = p.ImageName;
                            pTemp.Visualizzazioni = p.Views;
                            pTemp.NumComments = p.Comments.Count;

                            m.PostPreview.Add(pTemp);

                            k++;
                        }
                    }
                    else
                    {
                        PostViewModel pTemp = new PostViewModel();

                        pTemp.Id = 0;
                        pTemp.Data = DateTime.Today;
                        pTemp.Titolo = "OOPS...";
                        pTemp.Testo = "Sembra non siano presenti articoli...";
                        pTemp.Autore = "Pasquale Garzillo";

                        m.PostPreview.Add(pTemp);
                    }

                    if (pageId != 0)
                    {
                        Page p = pr.GetById(pageId);

                        PostViewModel pTemp = new PostViewModel();

                        pTemp.Id = p.Id;
                        pTemp.Data = p.Date.Value;
                        pTemp.Testo = p.BodyText;
                        pTemp.Titolo = p.Title;
                        pTemp.Autore = String.Format("{0} {1}", p.Author.Name, p.Author.Surname);
                        pTemp.Categoria = p.Category.Name;
                        pTemp.IdCategoria = p.Category.Id;
                        pTemp.ImageName = p.ImageName;
                        pTemp.Tags = p.Tags != null && p.Tags.Count > 0 ? p.Tags.Select(x => x.Name).ToList() : null;
                        pTemp.Visualizzazioni = p.Views;
                        pTemp.NumComments = p.Comments.Count;

                        if (pTemp.Tags != null && pTemp.Tags.Count > 0)
                        {
                            var tags = new TagCloudAnalyzer()
                                     .ComputeTagCloud(pTemp.Tags);
                            pTemp.TagCloud = tags;
                        }

                        if (p.Comments != null && p.Comments.Count > 0)
                        {
                            pTemp.Comments = (from c in p.Comments
                                              select new CommentViewModel() { UserMail = c.UserMail, TextComment = c.TextComment, UserName = c.UserName }).ToList<CommentViewModel>();
                        }


                        m.DetailedPost = pTemp;
                    }

                    //Carica le ultime 5 categoria con maggiori post
                    CategoryRepository cr = new CategoryRepository(uow.Current);
                    IList<Category> tempCats = cr.GetTopCategoryByPostCount(3);
                    if (tempCats != null && tempCats.Count > 0)
                    {
                        foreach (var c in tempCats)
                        {
                            CategoryViewModel cvTemp = new CategoryViewModel();

                            cvTemp.Id = c.Id;
                            cvTemp.Nome = c.Name;
                            cvTemp.Descrizione = c.Description;
                            cvTemp.FileName = c.ImageName;

                            m.CategoriesPreview.Add(cvTemp);
                        }
                    }
                    else
                    {
                        CategoryViewModel cvTemp = new CategoryViewModel();

                        cvTemp.Id = 0;
                        cvTemp.Nome = "OOPS...";
                        cvTemp.Descrizione = "Sembra non siano presenti categorie...";

                        m.CategoriesPreview.Add(cvTemp);
                    }
                }
                return View(m);

            }
            catch (Exception ex)
            {
                return Error(ex);
            }
        }
Exemple #49
0
        public ActionResult Find(string query)
        {
            try
            {
                ListPageViewModel m = new ListPageViewModel();

                using (UnitOfWork uow = new UnitOfWork())
                {
                    //Carica gli ultimi 5 POST
                    PageRepository pr = new PageRepository(uow.Current);

                    IList<Page> pages = pr.GetTopPost(5);
                    if (pages != null && pages.Count > 0)
                    {
                        int k = 0;
                        foreach (var p in pages)
                        {
                            PostViewModel pTemp = new PostViewModel();

                            pTemp.Id = p.Id;
                            pTemp.Data = p.Date.Value;
                            pTemp.Testo = p.BodyText;
                            pTemp.Titolo = p.Title;
                            pTemp.Autore = String.Format("{0} {1}", p.Author.Name, p.Author.Surname);
                            pTemp.Categoria = p.Category.Name;
                            pTemp.IdCategoria = p.Category.Id;
                            pTemp.ImageName = p.ImageName;
                            pTemp.Visualizzazioni = p.Views;
                            pTemp.NumComments = p.Comments.Count;

                            m.PostPreview.Add(pTemp);

                            k++;
                        }
                    }
                    else
                    {
                        PostViewModel pTemp = new PostViewModel();

                        pTemp.Id = 0;
                        pTemp.Data = DateTime.Today;
                        pTemp.Titolo = "OOPS...";
                        pTemp.Testo = "Sembra non siano presenti articoli...";
                        pTemp.Autore = "Pasquale Garzillo";

                        m.PostPreview.Add(pTemp);
                    }

                    //Carica le ultime 5 categoria con maggiori post
                    CategoryRepository cr = new CategoryRepository(uow.Current);
                    IList<Category> tempCats = cr.GetTopCategoryByPostCount(3);
                    if (tempCats != null && tempCats.Count > 0)
                    {
                        foreach (var c in tempCats)
                        {
                            CategoryViewModel cvTemp = new CategoryViewModel();

                            cvTemp.Id = c.Id;
                            cvTemp.Nome = c.Name;
                            cvTemp.Descrizione = c.Description;
                            cvTemp.FileName = c.ImageName;

                            m.CategoriesPreview.Add(cvTemp);
                        }
                    }
                    else
                    {
                        CategoryViewModel cvTemp = new CategoryViewModel();

                        cvTemp.Id = 0;
                        cvTemp.Nome = "OOPS...";
                        cvTemp.Descrizione = "Sembra non siano presenti categorie...";

                        m.CategoriesPreview.Add(cvTemp);
                    }


                    pages = pr.GetPostByQueryFind(query);
                    if (pages != null && pages.Count > 0)
                    {
                        foreach (var p in pages)
                        {
                            PostViewModel pTemp = new PostViewModel();

                            pTemp.Id = p.Id;
                            pTemp.Data = p.Date.Value;
                            pTemp.Testo = p.BodyText;
                            pTemp.Titolo = p.Title;
                            pTemp.Autore = String.Format("{0} {1}", p.Author.Name, p.Author.Surname);
                            pTemp.Categoria = p.Category.Name;
                            pTemp.IdCategoria = p.Category.Id;
                            pTemp.ImageName = p.ImageName;
                            pTemp.Visualizzazioni = p.Views;
                            pTemp.NumComments = p.Comments.Count;

                            m.Posts.Add(pTemp);
                        }
                    }
                }

                return View(m);
            }
            catch (Exception ex)
            {
                return Error(ex);
            }
        }
Exemple #50
0
 public PageLogServices(PXHotelEntities entities)
 {
     _localizedResourceServices = HostContainer.GetInstance<ILocalizedResourceServices>();
     _pageLogRepository = new PageLogRepository(entities);
     _pageRepository = new PageRepository(entities);
 }