Esempio n. 1
0
        public ActionResult FundSummary()
        {
            PageViewModel page = new PageViewModel();
            page.RedLogoImageUrl = "http://castlerockproperty.blob.core.windows.net/auslinkproperty/images/header/stable-income.png";
            page.RedLogoText = "Stable Income";
            page.HeaderImageUrl = "http://castlerockproperty.blob.core.windows.net/auslinkproperty/images/header/financials.jpg";

            return View(page);
        }
Esempio n. 2
0
        public override ActionResult CurrentUnitholders()
        {
            PageViewModel page = new PageViewModel();
            page.RedLogoImageUrl = "http://castlerockproperty.blob.core.windows.net/auslinkproperty/images/header/low-management-fees.png";
            page.RedLogoText = "Low Management Fees";
            page.HeaderImageUrl = "http://castlerockproperty.blob.core.windows.net/auslinkproperty/images/header/investors-unitholders.jpg";

            return View(page);
        }
Esempio n. 3
0
        public ActionResult Returns()
        {
            PageViewModel page = new PageViewModel();
            page.RedLogoImageUrl = "http://castlerockproperty.blob.core.windows.net/auslinkproperty/images/header/tax-advantage-income.png";
            page.RedLogoText = "Tax Advantage Income";
            page.HeaderImageUrl = "http://castlerockproperty.blob.core.windows.net/auslinkproperty/images/header/financials.jpg";

            return View(page);
        }
Esempio n. 4
0
        public ActionResult Overview()
        {
            PageViewModel page = new PageViewModel();
            page.RedLogoImageUrl = "http://castlerockproperty.blob.core.windows.net/auslinkproperty/images/header/low-entry-costs.png";
            page.RedLogoText = "Low Entry Costs";
            page.HeaderImageUrl = "http://castlerockproperty.blob.core.windows.net/auslinkproperty/images/header/about-key-features.jpg";

            return View(page);
        }
Esempio n. 5
0
        public ActionResult Index()
        {
            PageViewModel page = new PageViewModel();
            page.RedLogoImageUrl = "http://castlerockproperty.blob.core.windows.net/auslinkproperty/images/header/attractive-yields.png";
            page.RedLogoText = "Attractive Yields";
            page.HeaderImageUrl = "http://castlerockproperty.blob.core.windows.net/auslinkproperty/images/header/contact-us.jpg";

            return View(page);
        }
Esempio n. 6
0
        public ActionResult Index()
        {
            var model = new PageViewModel();
            ViewBag.Title = "Experience";
            ViewBag.SelectedNavigation = "Experience";
            var viewModel = this.GetProperties(this._propertyService.GetManagedProperties());

            return View("Index", viewModel);
        }
        public ActionResult Property(string propertyName)
        {
            PageViewModel page = new PageViewModel();
            page.RedLogoImageUrl = "http://castlerockproperty.blob.core.windows.net/auslinkproperty/images/header/property-location-diversification.png";
            page.RedLogoText = "Property Location Diversification";
            page.HeaderImageUrl = "http://castlerockproperty.blob.core.windows.net/auslinkproperty/images/header/property-portfolio-02.jpg";

            return View(propertyName, page);
        }
        public ActionResult AllProperties()
        {
            PageViewModel page = new PageViewModel();
            page.RedLogoImageUrl = "http://castlerockproperty.blob.core.windows.net/auslinkproperty/images/header/property-development.png";
            page.RedLogoText = "Property Development";
            page.HeaderImageUrl = "http://castlerockproperty.blob.core.windows.net/auslinkproperty/images/header/property-portfolio-01.jpg";

            return View(page);
        }
        public virtual ActionResult Index(PageViewModel currentPage)
        {
            var model = PageHelper.GetNavigationMenu(currentPage, this.CorePrincipal());

            if (model.MenuItems.Any())
            {
                return View(MVC.Pages.Views.NavigationMenu, model);
            }
            return Content(String.Empty);
        }
Esempio n. 10
0
        public ActionResult showpage(string key, int page)
        {
            Book b = BookProvider.GetByKey(key);
              Guid pageId = b.PageIds[page - 1];
              Page p = PageProvider.Get(pageId);
              p.InitializeForView(ObjectResolver);

              PageViewModel result = new PageViewModel
              {
            Book = b,
            Page = p,
            PageTemplateName = "PageTemplates/" + p.TemplateName
              };
              return View(result);
        }
Esempio n. 11
0
        public async Task<IActionResult> Index()
        {
            var viewModel = new PageViewModel();

            var authData = await _swiftService.Authenticate();

            if (authData != null)
            {
                viewModel.Message = $"Connected on proxy node: {authData.StorageUrl} with authentication token: {authData.AuthToken}";

                viewModel.Tree = await GetTree();
            }
            else
            {
                viewModel.Message = $"Error connecting to proxy node: {_swiftService.GetCredentials().Endpoints.First()} with credentials: {_swiftService.GetCredentials().Username} / {_swiftService.GetCredentials().Password}";
            }

            return View(viewModel);
        }
Esempio n. 12
0
        public ActionResult Index(int id)
        {
            Page page = this.PageServices.GetById(id);

            if (page == null)
            {
                return this.View("Error");
            }

            var paragraphs = this.PageServices
                .GetParagraphsByPage(page)
                .ProjectTo<PageParagraphViewModel>(this.MapperConfiguration)
                .ToList();

            PageViewModel videModel = new PageViewModel()
            {
                PageTitle = page.Heading,
                Paragraphs = paragraphs
            };

            return this.View(videModel);
        }
        public async Task <IActionResult> Index(int currentPage = 1)
        {
            var users = await this.users.GetAllAsync(currentPage);

            users = await this.users.SetRoleToModelAsync(users);

            var page = new PageViewModel
            {
                CurrentPage = currentPage,
                Area        = string.Empty,
                Controller  = nameof(UsersController),
                Action      = nameof(Index),
                Count       = await this.users.GetUsersCountAsync()
            };

            var model = new AllUsersListingAdminModel
            {
                Page  = page,
                Users = users
            };

            return(View(model));
        }
Esempio n. 14
0
        public void post_should_add_page()
        {
            // Arrange
            PageViewModel page = new PageViewModel()
            {
                Title     = "Hello",
                CreatedBy = "admin",
                CreatedOn = DateTime.UtcNow,
                Content   = "some content",
                RawTags   = "tag1,tag2"
            };

            WebApiClient apiclient = new WebApiClient();

            // Act
            WebApiResponse response = apiclient.Post <PageViewModel>("Pages", page);

            // Assert
            IPageRepository    repository = GetRepository();
            IEnumerable <Page> pages      = repository.AllPages();

            Assert.That(pages.Count(), Is.EqualTo(1), response);
        }
Esempio n. 15
0
        public ActionResult PageDetails(int id)
        {
            // declare pagevm
            PageViewModel model;

            using (Db db = new Db())
            {
                // get the page
                PageDTO dto = db.Pages.Find(id);
                // confirm page exists
                if (dto == null)
                {
                    return(Content("The page does not exist."));
                }

                // init pagevm
                model = new PageViewModel(dto);
            }


            //redirect
            return(View(model));
        }
Esempio n. 16
0
        public async Task <IActionResult> Delete(PageViewModel viewModel)
        {
            var menuViewModel = await _pageService.GetByIdAsync(viewModel.Id);

            if (menuViewModel == null)
            {
                ModelState.AddModelError("", RequestNotFound);
            }
            else
            {
                var result = await _pageService.DeleteAsync(menuViewModel.Id);

                if (result)
                {
                    _searchManager.DeleteFromIndex(menuViewModel);
                    return(Json(new { success = true }));
                }

                ModelState.AddModelError("", RequestNotFound);
            }

            return(PartialView("_Delete", model: viewModel));
        }
Esempio n. 17
0
        public ActionResult EditPage(int id)
        {
            // Declare pageVM
            PageViewModel model;

            using (Db db = new Db())
            {
                // Get the page
                PageDTO dto = db.Pages.Find(id);

                // Confirm page exists
                if (dto == null)
                {
                    return(Content("The page does not exist."));
                }

                // Init pageVM
                model = new PageViewModel(dto);
            }

            // Return view with model
            return(View(model));
        }
Esempio n. 18
0
        public IActionResult Index(Genre genre, int page)
        {
            var       sessionSortState = HttpContext.Session.GetString("SortStateGenre");
            SortState sortOrder        = new SortState();

            if (sessionSortState != null)
            {
                sortOrder = (SortState)Enum.Parse(typeof(SortState), sessionSortState);
            }

            IQueryable <Genre> genres = Sort(_context.Genres, sortOrder,
                                             _genre.NameGenre, (int)page);
            PageViewModel pageViewModel = new PageViewModel(NoteCount(_context.Genres,
                                                                      _genre.NameGenre), page, pageSize);
            GenresViewModel genresView = new GenresViewModel
            {
                GenreViewModel = _genre,
                PageViewModel  = genres,
                PageNumber     = page
            };

            return(View(genresView));
        }
Esempio n. 19
0
        //获取数据列表
        public ActionResult GetDataList(string sw)
        {
            var pageIndex = Common.GetPageIndex();
            var pageSize  = Common.GetPageSize();
            var total     = 0;
            List <ITC_Position_M> list_mo = uifo.GetList(sw, pageIndex, pageSize, out total);
            var list = from f in list_mo
                       select new
            {
                f.Position_ID,
                f.Position_name,
                f.Position_Oprt,
                f.Position_remark,
                Position_createdtime = f.Position_createdtime.ToString("g"),
                Position_status      = Common.GetStatus(f.Position_status),
                f.Position_Order
            };
            var page = new PageViewModel {
                rows = list, total = total
            };

            return(Json(page, JsonRequestBehavior.DenyGet));
        }
Esempio n. 20
0
        public async Task <IActionResult> MyBorrowedBooks(int currentPage = 1)
        {
            var userName = User.Identity.Name;

            var books = await this.books.MyBorrowedAsync(userName, currentPage);

            var page = new PageViewModel
            {
                CurrentPage = currentPage,
                Area        = string.Empty,
                Controller  = nameof(BooksController),
                Action      = nameof(MyBorrowedBooks),
                Count       = await this.books.GetMyBorrowedCountAsync(userName)
            };

            var model = new BorrowedBooksListingViewModel
            {
                Page  = page,
                Books = books
            };

            return(View(model));
        }
Esempio n. 21
0
        public static PageViewModel ConvertToPageViewModel(PageModel page)
        {
            PageViewModel pageModel = new PageViewModel
            {
                Conteudo       = Encoding.UTF8.GetString(page.Conteudo),
                DataCriacao    = page.DataCriacao,
                DateAlteracao  = page.DateAlteracao,
                Descricao      = page.Descricao,
                ID             = page.ID,
                idCliente      = page.idCliente,
                idMenu         = page.idMenu,
                Nome           = page.Nome,
                Status         = page.Status,
                Titulo         = page.Titulo,
                Url            = page.Url,
                UsuarioCriacao = page.UsuarioCriacao,
                UsuarioEdicao  = page.UsuarioEdicao,
                Ativo          = page.Ativo
            };


            return(pageModel);
        }
Esempio n. 22
0
        // GET: Admin/Pages/PageDetails/id
        public ActionResult PageDetails(int id)
        {
            // Declare PageVM
            PageViewModel model;

            using (HAPINUTSHOPEntities db = new HAPINUTSHOPEntities())
            {
                // Get the page
                Page dto = db.Pages.Find(id);

                // Confirm page exists
                if (dto == null)
                {
                    return(Content("The page does not exist."));
                }

                // Init PageVM
                model = new PageViewModel(dto);
            }

            // Return view with model
            return(View(model));
        }
Esempio n. 23
0
        private StaffViewModel SetViewModel(string FIO, string NameOfPost, int Age, int WorkExp, SortState sortState, int page = 1)
        {
            IEnumerable <Staff> staffs = railroadContext.Staffs.Include(p => p.Post).Include(t => t.Train).Include(t => t.Train.Schedules);

            staffs = SortSearch(staffs, Age, WorkExp, FIO ?? "", NameOfPost ?? "", sortState);
            int pageSize = 20;
            int count    = staffs.Count();

            staffs = staffs.Skip((page - 1) * pageSize).Take(pageSize).ToList();
            PageViewModel  pageViewModel = new PageViewModel(count, page, pageSize);
            StaffViewModel viewModel     = new StaffViewModel
            {
                Staffs        = staffs,
                PageViewModel = pageViewModel,
                NameOfPost    = NameOfPost,
                FIO           = FIO,
                Age           = Age,
                WorkExp       = WorkExp,
                SortViewModel = new SortViewModel(sortState)
            };

            return(viewModel);
        }
Esempio n. 24
0
        public static HtmlString PageLinks(this IHtmlHelper html,
                                           PageViewModel pageInfo, Func <int, string> pageUrl)
        {
            StringBuilder result = new StringBuilder();

            for (int i = 1; i <= pageInfo.TotalPages; i++)
            {
                TagBuilder tag = new TagBuilder("a");
                tag.MergeAttribute("href", pageUrl(i));

                tag.InnerHtml.Append(i.ToString());
                if (i == pageInfo.PageNumber)
                {
                    tag.AddCssClass("selected");
                    tag.AddCssClass("btn-primary");
                }
                tag.AddCssClass("btn btn-default");
                var writer = new System.IO.StringWriter();
                tag.WriteTo(writer, System.Text.Encodings.Web.HtmlEncoder.Default);
                result.Append(writer.ToString());
            }
            return(new HtmlString(result.ToString()));
        }
Esempio n. 25
0
        public ActionResult EditPage(int id)
        {
            // об'явлення моделі PageViewModel
            PageViewModel model;

            using (DB db = new DB()) // конструкція відкриває підключення до бази даних
            {
                // отримуємо дані сторінки
                PagesDTO dto = db.Pages.Find(id);

                // перевірка, чи доступна сторінка
                if (dto == null)
                {
                    return(Content("The Page Does Not Exist."));
                }

                // ініціалізація моделі даними
                model = new PageViewModel(dto);
            }

            // повертаємо модель в представлення
            return(View(model));
        }
Esempio n. 26
0
        public ActionResult EditPage(int id)
        {
            PageViewModel model;

            using (DataB db = new DataB())
            {
                //Get the page
                PageDtO dto = db.pages.Find(id);

                //confirm that the page exists
                if (dto == null)
                {
                    return(Content("The page does not exist"));
                }

                //no need to initialize all fields because
                //of the handy 1 parameter constructor in the
                //PageViewModel Class!
                model = new PageViewModel(dto);
            }

            return(View(model));
        }
Esempio n. 27
0
        public void Search_By_TagsField_Returns_Multiple_Results()
        {
            // Arrange
            SearchService searchService = new SearchService(_config, _repository, _pluginFactory);

            searchService.CreateIndex();

            PageViewModel page1 = CreatePage(1, "admin", "random name1", "homepage1, tag1", "title content");
            PageViewModel page2 = CreatePage(2, "admin", "random name2", "tag1, tag", "title content");
            PageViewModel page3 = CreatePage(3, "admin", "random name3", "tag3, tag", "title content");
            PageViewModel page4 = CreatePage(4, "admin", "random name4", "tag4, tag", "title content");

            searchService.Add(page1);
            searchService.Add(page2);
            searchService.Add(page3);
            searchService.Add(page4);

            // Act
            List <SearchResultViewModel> results = searchService.Search("tags:\"tag1\"").ToList();

            // Assert
            Assert.That(results.Count, Is.EqualTo(2));
        }
Esempio n. 28
0
        /// <summary>
        /// Gets a particular version of a page.
        /// </summary>
        /// <param name="id">The Guid ID for the version.</param>
        /// <returns>A <see cref="PageViewModel"/> as the model, which contains the HTML diff
        /// output inside the <see cref="PageViewModel.Content"/> property.</returns>
        public ActionResult Version(Guid id)
        {
            MarkupConverter       converter    = _pageService.GetMarkupConverter();
            IList <PageViewModel> bothVersions = _historyService.CompareVersions(id).ToList();
            string diffHtml = "";

            if (bothVersions[1] != null)
            {
                string   oldVersion = converter.ToHtml(bothVersions[1].Content).Html;
                string   newVersion = converter.ToHtml(bothVersions[0].Content).Html;
                HtmlDiff diff       = new HtmlDiff(oldVersion, newVersion);
                diffHtml = diff.Build();
            }
            else
            {
                diffHtml = converter.ToHtml(bothVersions[0].Content).Html;
            }

            PageViewModel model = bothVersions[0];

            model.Content = diffHtml;
            return(View(model));
        }
Esempio n. 29
0
        public void AllPages_Should_Load_From_Cache(bool loadPageContent)
        {
            string cacheKey = (loadPageContent) ? (CacheKeys.AllPagesWithContent()) : (CacheKeys.AllPages());

            // Arrange
            SettingsRepositoryMock settingsRepository = new SettingsRepositoryMock();
            PageRepositoryMock     pageRepository     = new PageRepositoryMock();
            CacheMock listCache = new CacheMock();

            PageService   pageService   = CreatePageService(null, listCache, settingsRepository, pageRepository);
            PageViewModel expectedModel = CreatePageViewModel();

            AddListCacheItem(listCache, cacheKey, new List <PageViewModel>()
            {
                expectedModel
            });

            // Act
            IEnumerable <PageViewModel> actualList = pageService.AllPages(loadPageContent);

            // Assert
            Assert.That(actualList, Contains.Item(expectedModel));
        }
Esempio n. 30
0
		public void version_should_return_viewresult_and_pagesummary_model()
		{
			// Arrange
			Page page = AddDummyPage1();
			page.IsLocked = true;

			Guid version2Guid = Guid.NewGuid();
			Guid version3Guid = Guid.NewGuid();

			_pageRepository.PageContents.Add(new PageContent() { Id = version2Guid, Page = page, Text = "version2 text" });
			_pageRepository.PageContents.Add(new PageContent() { Id = version3Guid, Page = page, Text = "version3 text" });

			// Act
			ActionResult result = _pagesController.Version(version2Guid);

			// Assert
			Assert.That(result, Is.TypeOf<ViewResult>(), "ViewResult");
			ViewResult viewResult = result as ViewResult;
			Assert.NotNull(viewResult, "Null ViewResult");

			PageViewModel model = viewResult.ModelFromActionResult<PageViewModel>();
			Assert.That(model.Content, Contains.Substring("version2 text"));
		}
Esempio n. 31
0
        public void search_by_title()
        {
            // Arrange
            SearchService searchService = CreateSearchService();

            searchService.CreateIndex();

            PageViewModel page1 = CreatePage(1, "admin", "the title", "tag1", "title content");
            PageViewModel page2 = CreatePage(2, "admin", "random name1", "tag1", "title content");
            PageViewModel page3 = CreatePage(3, "admin", "random name2", "tag1", "title content");
            PageViewModel page4 = CreatePage(4, "admin", "random name3", "tag1", "title content");

            searchService.Add(page1);
            searchService.Add(page2);
            searchService.Add(page3);
            searchService.Add(page4);

            // Act
            List <SearchResultViewModel> results = searchService.Search("title:\"the title\"").ToList();

            // Assert
            Assert.That(results.Count, Is.EqualTo(1));
        }
 private void ConvertToVMCore(PageViewModel vm, MergeItem mergeItem)
 {
     if (mergeItem.AssemblyNameList.Count > 0)
     {
         mergeItem.MajorItem.AssemblyNameList = mergeItem.AssemblyNameList.ToList();
     }
     if (mergeItem.Children.Count > 0)
     {
         mergeItem.MajorItem.Children = mergeItem.Children.ToList();
     }
     if (mergeItem.Platform.Count > 0)
     {
         mergeItem.MajorItem.Platform = mergeItem.Platform.ToList();
     }
     vm.Items.Add(mergeItem.MajorItem);
     if (mergeItem.MinorItems != null)
     {
         foreach (var item in mergeItem.MinorItems.Values)
         {
             ConvertToVMCore(vm, item);
         }
     }
 }
Esempio n. 33
0
        // GET: admin/pages/editpage/id
        public ActionResult EditPage(int id)
        {
            // declare pagevm
            PageViewModel model;

            using (CmsShoppingCartDb db = new CmsShoppingCartDb())
            {
                // get the page
                PageDTO dto = db.Pages.Find(id);

                //confirm page exists
                if (dto == null)
                {
                    return(Content("The page does not exist."));
                }

                // init page
                model = new PageViewModel(dto);
            }

            // return vm
            return(View(model));
        }
Esempio n. 34
0
        public async Task <IActionResult> Index(int page = 1)
        {
            //var list = await db.Posts.OrderBy(p => p.Created).ToListAsync();
            //return View(list);

            int pageSize = 3;   // количество элементов на странице

            IQueryable <Post> source = db.Posts
                                       .OrderByDescending(p => p.Created);

            var count = await source.CountAsync();

            var items = await source.Skip((page - 1) *pageSize).Take(pageSize).ToListAsync();

            PageViewModel  pageViewModel = new PageViewModel(count, page, pageSize);
            IndexViewModel viewModel     = new IndexViewModel
            {
                PageViewModel = pageViewModel,
                Posts         = items
            };

            return(View(viewModel));
        }
Esempio n. 35
0
        public IActionResult Products(int page = 1)
        {
            int            pageSize      = 15;
            List <string>  storagesNames = _db.Storages.Select(x => x.Name).Distinct().ToList();
            List <Product> products      = new List <Product>();

            foreach (string name in storagesNames)
            {
                products.AddRange(_db.Products.Include(p => p.Place.Storage).Include(s => s.Place).Where(s => s.Place.Storage.Name == name).ToList());
            }

            int            count         = products.Count();
            List <Product> selectedItems = products.Skip((page - 1) * pageSize).Take(pageSize).ToList();

            PageViewModel         pageViewModel = new PageViewModel(count, page, pageSize);
            ProductsPageViewModel viewModel     = new ProductsPageViewModel
            {
                PageViewModel = pageViewModel,
                Products      = selectedItems
            };

            return(View(viewModel));
        }
Esempio n. 36
0
        public ActionResult PageDetails(int id)
        {
            // оголошення модель PageViewModel
            PageViewModel model;

            using (DB db = new DB())
            {
                // отримуємо сторінку
                PagesDTO dto = db.Pages.Find(id);

                // перевіряємо чи сторінка доступна
                if (dto == null)
                {
                    return(Content("The Page Does Not Exist"));
                }

                // присвоюємо моделі інформацію з БД
                model = new PageViewModel(dto);
            }

            // повертаємо модель в представлення
            return(View(model));
        }
Esempio n. 37
0
        // GET: Page/Details/5
        public IActionResult Details(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }

            Page page = _pageService.GetById(id);

            if (page == null)
            {
                return(HttpNotFound());
            }

            PageViewModel model = new PageViewModel
            {
                Page     = page,
                Sections = _sectionService.GetAllSectionsForPage(id),
                IsInMenu = _menuService.CheckIfPageExistsInMenu(page)
            };

            return(View(model));
        }
Esempio n. 38
0
        public RustShopSalesHistoryViewModel GetSalesHistory(Guid shopId, int page)
        {
            var shop = _easyShopContext.Shops.FirstOrDefault(x => x.Id == shopId);

            var rustPurchaseStats = _easyShopContext.RustPurchaseStats.Where(x =>
                                                                             x.Shop.Id == shop.Id && x.AppUser.Id == _currentRequestAppUser.Id)
                                    .Include(x => x.AppUser)
                                    .Include(x => x.RustPurchasedItem)
                                    .Include(x => x.RustPurchasedItem.SteamUser)
                                    .Include(x => x.RustPurchasedItem.RustItem)
                                    .OrderByDescending(x => x.RustPurchasedItem.PurchaseDateTime)
                                    .ToList();

            int pageSize                = 15;
            var purchaseStats           = rustPurchaseStats;
            var rustPurchaseStatsLength = rustPurchaseStats.Count;
            var rustPurchaseStatsPage   = purchaseStats.Skip((page - 1) * pageSize).Take(pageSize).ToList();

            PageViewModel pageModel = new PageViewModel(rustPurchaseStatsLength, page, pageSize);

            var totalFees = _payPalSettings.Fees + _configuration.GetValue <int>("ServicePercentPerTransaction");

            var result = new RustShopSalesHistoryViewModel()
            {
                Sales = rustPurchaseStatsPage.Select(x => new RustShopSaleViewModel(totalFees, x.RustPurchasedItem.TotalPaid)
                {
                    DateTime = x.RustPurchasedItem.PurchaseDateTime,
                    Name     = x.RustPurchasedItem.RustItem.Name,
                    Amount   = x.RustPurchasedItem.AmountOnPurchase,
                    UID      = x.RustPurchasedItem.SteamUser.Uid,
                    Paid     = x.RustPurchasedItem.TotalPaid
                }),
                Pages = pageModel
            };

            return(result);
        }
Esempio n. 39
0
        public override ActionResult Index(RenderModel model)
        {
            var pageViewModel   = new PageViewModel();
            var extendedModel   = _pageModelExtender.ApplyLayoutToModel(pageViewModel, model.Content);
            var tagName         = Request.QueryString["tag"];
            var articles        = new List <ArticleCardViewModel>();
            var articlesWithTag = _nodeHelper.Umbraco.TagQuery.GetContentByTag(tagName).ToList();
            var header          = $"Posty otagowane {tagName}";

            articlesWithTag.ForEach(article =>
            {
                articles.Add(new ArticleCardViewModel
                {
                    Title            = article.GetPropertyValue <string>("title"),
                    ShortDescription = article.GetPropertyValue <string>("shortDescription"),
                    Tags             = article.GetPropertyValue <string>("tags").Split(','),
                    CardImage        = article.GetImage("cardImage", _nodeHelper).WithQuality(75).WithHeight(160).WithWidth(330).WithCrop(),
                    Url = article.Url
                });
            });
            var modelForArticles = new ArticleListViewModel
            {
                Title    = header,
                Articles = articles
            };
            var viewModel = new ArticleByTagViewModel
            {
                Id                = extendedModel.Id,
                Title             = header,
                Footer            = extendedModel.Footer,
                Header            = extendedModel.Header,
                Description       = "Lista wszystkich postów które zosta³y otagowane " + tagName,
                ArticlesListModel = modelForArticles
            };

            return(View("Tag", viewModel));
        }
        // GET: Employees
        public async Task <IActionResult> Index(string sortOrder, string currentFilter, string searchString, int?pageNumber)
        {
            ViewData["CurrentSort"]  = sortOrder;
            ViewData["NameSortParm"] = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";

            if (searchString != null)
            {
                pageNumber = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewData["CurrentFilter"] = searchString;
            var employees = from s in _context.Employees.Include(e => e.Position)
                            select s;

            if (!String.IsNullOrEmpty(searchString))
            {
                employees = employees.Where(s => s.Position.NamePosition.Contains(searchString));
            }
            switch (sortOrder)
            {
            case "name_desc":
                employees = employees.OrderByDescending(s => s.FirsLastMidName);
                break;

            default:
                employees = employees.OrderBy(s => s.FirsLastMidName);
                break;
            }

            int pageSize = 5;

            return(View(await PageViewModel <Employee> .CreateAsync(employees.AsNoTracking(), pageNumber ?? 1, pageSize)));
        }
Esempio n. 41
0
        public IActionResult AddPage(PageViewModel page)
        {
            if (!ModelState.IsValid)
            {
                return(View(page));
            }
            string slug;
            var    pageFromDb = _context.Pages;

            if (string.IsNullOrWhiteSpace(page.Slug))
            {
                slug = page.Title.Replace(" ", "-").ToLower();
            }
            else
            {
                slug = page.Slug.Replace(" ", "-").ToLower();
            }

            if (pageFromDb.Any(x => x.Title == page.Title) || pageFromDb.Any(x => x.Slug == slug))
            {
                ModelState.AddModelError("", "Tytuł strony bądź adres już istnieje");
                return(View(page));
            }
            var pageDTO = new Page
            {
                Title      = page.Title,
                Slug       = slug,
                Body       = page.Body,
                HasSiteBar = page.HasSiteBar,
                Sorting    = 1000
            };

            _context.Pages.Add(pageDTO);
            _context.SaveChanges();
            TempData["SM"] = "Dodałeś nową stronę";
            return(RedirectToAction("AddPage"));
        }
Esempio n. 42
0
        // GET: Indicators
        public IActionResult Index(int?currentYear, bool?disableForEdition, int page = 1)
        {
            int pageSize = 20;


            bool       enableForEdition = !(disableForEdition ?? true);
            int        currYear         = currentYear ?? DateTime.Now.Year;
            List <int> years            = _context.Indicators
                                          .OrderByDescending(f => f.Year)
                                          .Select(f => f.Year)
                                          .ToList();

            years.Insert(0, currYear); years.Insert(0, currYear + 1);
            var ListYears = new SelectList(years.Distinct(), currYear);

            var achievementsCount = _context.Achievements.Where(m => m.Year == currYear).Count();

            IQueryable <Indicator> Indicatorsc = _context.Indicators.Where(t => t.Year == currYear).OrderBy(s => s.IndicatorId1).OrderBy(s => s.IndicatorId2).OrderBy(s => s.IndicatorId3);


            var count = Indicatorsc.Count();
            var items = Indicatorsc.Skip((page - 1) * pageSize).Take(pageSize);

            PageViewModel pageViewModel = new PageViewModel(count, page, pageSize);


            IndicatorsViewModel indicators = new IndicatorsViewModel()
            {
                PageViewModel     = pageViewModel,
                Indicators        = items,
                ListYears         = new SelectList(years.Distinct(), currYear),
                EnableForEdition  = enableForEdition,
                AchievementsCount = achievementsCount
            };

            return(View(indicators));
        }
        public virtual ActionResult SavePageCommonSettings(PageViewModel model)
        {
            if (ModelState.IsValid)
            {
                var page = new Page();
                if (!permissionService.IsAllowed((Int32)PageOperations.AddNewPages, this.CorePrincipal(), typeof(Page), null))
                {
                    throw new HttpException((int)HttpStatusCode.NotFound, Translate("Messages.NotFound"));
                }

                page.OrderNumber = pageService.GetLastOrderNumber(model.ParentPageId == 0 ? null : model.ParentPageId);
                if (this.CorePrincipal() != null)
                    page.User = new User
                    {
                        Id = this.CorePrincipal().PrincipalId
                    };
                page = model.MapTo(page);
                if (!model.TemplateId.HasValue)
                {
                    page.PageLayout = new PageLayout
                    {
                        LayoutTemplate = LayoutHelper.DefaultLayoutTemplate,
                        Page = page
                    };
                }
                if (pageService.Save(page))
                {
                    permissionService.SetupDefaultRolePermissions(
                        ResourcePermissionsHelper.GetResourceOperations(typeof(Page)), typeof(Page), page.Id);
                    if (model.ClonedPageId != null)
                    {
                        var sourcePage = pageService.Find((long)model.ClonedPageId);
                        if (permissionService.IsAllowed((Int32)PageOperations.View, this.CorePrincipal(),
                                                        typeof(Page), sourcePage.Id, IsPageOwner(sourcePage),
                                                        PermissionOperationLevel.Object))
                        {
                            PageHelper.ClonePageSettings(sourcePage, page);
                        }
                    }
                    else if (model.TemplateId.HasValue)
                    {
                        var sourceTemplate = pageService.Find((long)model.TemplateId);
                        if (permissionService.IsAllowed((Int32)PageOperations.View, this.CorePrincipal(),
                                                        typeof(Page), sourceTemplate.Id, IsPageOwner(sourceTemplate),
                                                        PermissionOperationLevel.Object))
                        {
                            PageHelper.ClonePageSettingsFromTemplate(sourceTemplate, page, model.WidgetId);
                        }
                    }

                    TempData["Success"] = true;
                }

                model = model.MapFrom(page);
            }
            else Error(Translate("Messages.ValidationError"));

            return PartialView(MVC.Pages.Views.PageCreateForm, model);
        }
Esempio n. 44
0
 public ActionResult Index()
 {
     PageViewModel page = new PageViewModel();
     return View(page);
 }
Esempio n. 45
0
 public CmsPageViewModel(IWebsite website, PageViewModel pageViewModel, IList<Template> templates)
     : base(website)
 {
     this._page = pageViewModel;
     pageViewModel.AddTemplates(templates);
 }
        public ActionResult JsonEditPage()
        {
            if (!HasAdminPrivilege())
            {
                return RedirectToAction("Logon", "Account", new { ReturnUrl = Request.Url.PathAndQuery });
            }
            var pageName = Request["PageName"] ?? "";

            var pageViewModel = new PageViewModel();

            Session["EDITCUSTOMPAGE"] = pageName;

            var sr = new StreamReader(Server.MapPath("~\\CustomPages\\" + pageName + ".cws"));

            var pageContent = sr.ReadToEnd();

            sr.Close();

            pageViewModel.PageName = pageName;

            var sr1 = new StreamReader(Server.MapPath("~\\CustomPages\\" + pageName + ".desc"));

            //find out if a backup exists for this file, if so, show the restore/view backup buttons
            if (System.IO.File.Exists(Server.MapPath("~\\CustomPages\\" + pageName + ".backup")))
            {
                pageViewModel.IsBackup = true;

            }

            pageViewModel.PageDesc = sr1.ReadToEnd();

            pageViewModel.PageContent = pageContent;

            sr1.Close();

            return PartialView("EditorTemplates/Admin/EditPages", pageViewModel);
        }
        /// <summary>
        /// Restore the backup page
        /// </summary>
        /// <returns></returns>
        public ActionResult JsonRestoreBackUp()
        {
            if (!HasAdminPrivilege())
            {
                return RedirectToAction("Logon", "Account", new { ReturnUrl = Request.Url.PathAndQuery });
            }
            var pageToEdit = Request["PageName"] ?? "";

            var pageViewModel = new PageViewModel();

            if (!string.IsNullOrEmpty(pageToEdit))
            {

                System.IO.File.Copy(Server.MapPath("~\\CustomPages\\" + pageToEdit + ".cws"),
                                    Server.MapPath("~\\CustomPages\\" + pageToEdit + ".temp"), true);
                System.IO.File.Copy(Server.MapPath("~\\CustomPages\\" + pageToEdit + ".desc"),
                                    Server.MapPath("~\\CustomPages\\" + pageToEdit + ".desctemp"), true);
                System.IO.File.Copy(Server.MapPath("~\\CustomPages\\" + pageToEdit + ".backup"),
                                    Server.MapPath("~\\CustomPages\\" + pageToEdit + ".cws"), true);
                System.IO.File.Copy(Server.MapPath("~\\CustomPages\\" + pageToEdit + ".descbackup"),
                                    Server.MapPath("~\\CustomPages\\" + pageToEdit + ".desc"), true);
                System.IO.File.Copy(Server.MapPath("~\\CustomPages\\" + pageToEdit + ".temp"),
                                    Server.MapPath("~\\CustomPages\\" + pageToEdit + ".backup"), true);
                System.IO.File.Copy(Server.MapPath("~\\CustomPages\\" + pageToEdit + ".desctemp"),
                                    Server.MapPath("~\\CustomPages\\" + pageToEdit + ".descbackup"), true);
                System.IO.File.Delete(Server.MapPath("~\\CustomPages\\" + pageToEdit + ".desctemp"));
                System.IO.File.Delete(Server.MapPath("~\\CustomPages\\" + pageToEdit + ".temp"));
                System.IO.TextReader sr =
                    new System.IO.StreamReader(Server.MapPath("~\\CustomPages\\" + pageToEdit + ".cws"));

                pageViewModel.PageContent = sr.ReadToEnd();

                sr.Close();

                var sr1 = new StreamReader(Server.MapPath("~\\CustomPages\\" + pageToEdit + ".desc"));

                var pageDesc = sr1.ReadToEnd().ToString();

                sr1.Close();

                pageViewModel.PageDesc = pageDesc;
            }
            else
            {
                return Json(new { success = false, errMsg = "There is no backup for this page or page does not exist" });
            }
            //if this does not work then you can return partial edit
            return PartialView("EditorTemplates/Admin/RichEditorControl", pageViewModel.PageContent);
        }
        public ActionResult JsonSavePageContents(PageViewModel model)
        {
            var pageContent = string.IsNullOrEmpty(model.PageContent) ? "" : model.PageContent;

            var pageName = Request["PageName"] ?? "";

            var pageDesc = Request["PageDesc"] ?? "";

            if (!string.IsNullOrEmpty(pageName))
            {
                var policy = false;
                var frontpage = false;

                //  string pagetoupdate = Session["EDITCUSTOMPAGE"].ToString();
                var pagetoupdate = pageName;
                //is this a policy?

                if (System.IO.File.Exists(Server.MapPath("~\\CustomPages\\" + pagetoupdate + ".policy")))
                    policy = true;

                //is this a front page?

                var homePage = objBaseMainConfigAdmin.IwebConfigAdmin.CurrentHomePage;

                // var sHomePage = "my first page";

                if (pagetoupdate == homePage)
                    frontpage = true;

                System.IO.File.Copy(Server.MapPath("~\\CustomPages\\" + pagetoupdate + ".cws"),
                                    Server.MapPath("~\\CustomPages\\" + pagetoupdate + ".backup"), true);

                System.IO.File.Copy(Server.MapPath("~\\CustomPages\\" + pagetoupdate + ".desc"),
                                    Server.MapPath("~\\CustomPages\\" + pagetoupdate + ".descbackup"), true);

                //now lets write the new data to the file
                var tw = new StreamWriter(Server.MapPath("~\\CustomPages\\" + pagetoupdate + ".desc"));

                tw.Write(pageDesc);

                tw.Close();

                var tr = new StreamWriter(Server.MapPath("~\\CustomPages\\" + pagetoupdate + ".cws"), false);

                tr.Write(pageContent);

                tr.Close();

                if (policy) //create copy for the policy to update it

                    System.IO.File.Copy(Server.MapPath("~\\CustomPages\\" + pagetoupdate + ".cws"),
                                        Server.MapPath("~\\CustomPages\\" + pagetoupdate + ".policy"), true);

                if (frontpage) //create copy for the homepage to update it
                    System.IO.File.Copy(Server.MapPath("~\\CustomPages\\" + pagetoupdate + ".cws"),
                                        Server.MapPath("~\\contentfiles\\frontpage.txt"), true);

                var lstPageViewModel = ListOfPages();

                return PartialView("EditorTemplates/Admin/ShowPages", lstPageViewModel);
            }

            return Json(new { success = false, errMsg = "Page content can't be saved" });
        }
Esempio n. 49
0
        /// <summary>
        /// Gets the navigation menu.
        /// </summary>
        /// <returns></returns>
        public static NavigationMenuModel GetNavigationMenu(PageViewModel currentPage, ICorePrincipal user)
        {
            var pageService = ServiceLocator.Current.GetInstance<IPageService>();
            var pages = pageService.GetAllowedPagesForMainMenu(user).OrderBy(page => page.OrderNumber);
            var pagesToRemove = pageService.GetAllowedPagesByOperation(user, (int)PageOperations.Delete).OrderBy(page => page.OrderNumber);
            var permissionService = ServiceLocator.Current.GetInstance<IPermissionCommonService>();
            var pageMode = CurrentUserPageMode;
            var menuItems = new List<NavigationMenuItemModel>();

            bool addNewPagesAccess = permissionService.IsAllowed((int)PageOperations.AddNewPages, user, typeof(Page), null,
                                                  PermissionOperationLevel.Type);

            List<NavigationMenuItemModel> items = pages.Select(page => new NavigationMenuItemModel
                                                                       {
                                                                           Page = page,
                                                                           IsCurrent = currentPage != null && page.Id == currentPage.Id,
                                                                           RemoveAccess = pagesToRemove.FirstOrDefault(item => item.Id == page.Id) != null,
                                                                           PageMode = pageMode
                                                                       }).ToList();

            foreach (var item in items)
            {
                if (item.Page.ParentPageId == null)
                {
                    item.Children = Flatten(item, items, 2, addNewPagesAccess, pageMode);
                    menuItems.Add(item);
                }
            }
            if (addNewPagesAccess && pageMode == PageMode.Edit)
                menuItems.Add(new NavigationMenuItemModel
                                  {
                                      PageMode = pageMode
                                  });

            return new NavigationMenuModel
                       {
                           MenuItems = menuItems,
                           ManageAccess = addNewPagesAccess,
                           PageMode = pageMode
                       };
        }
Esempio n. 50
0
        public ActionResult ViewPage(Guid pageId, bool? published)
        {
            Page page = this._pageService.GetPageById(pageId);

            PageViewModel viewModel = new PageViewModel(page);

            ViewBag.Published = published;

            return this.View("ViewPage", viewModel);
        }