Beispiel #1
0
        /// <summary>
        /// Loads rows for CurrentPageIndex from <see cref="PaginationConfiguration"/>.
        /// When page is bigger than zero this method will add missing dummy pages to maintain sparse page indicies in Pages collection.
        /// </summary>
        private void LoadRowsForCurrentPage()
        {
            CheckDisposed();
            var page = this.DataProvider.PaginationConfiguration.CurrentPageIndex;

            if (page > 0)
            {
                // Add missing dummy pages to maintain sparse page indicies in Pages
                while (this.Pages.ElementAtOrDefault(page - 1) == null)
                {
                    this.Pages.Add();
                }
            }

            var newRowsData = new PagesViewModel();

            foreach (var currentPageRow in this.DataProvider.CurrentPageRows)
            {
                newRowsData.Rows.Add(currentPageRow);
            }

            if (this.Pages.ElementAtOrDefault(page) != null)
            {
                this.Pages[page] = newRowsData;
            }
            else
            {
                this.Pages.Add(newRowsData);
            }

            this.TotalRows = this.DataProvider.TotalRows;
        }
        private TypesProductsViewModel CreateProductsModel(string[] typesNames, string kind,
                                                           int currentPage, int maxPage,
                                                           string actionName, IEnumerable <ProductIndexViewModel> products)
        {
            var pageViewModel = new PagesViewModel
            {
                CurrentPage    = currentPage,
                MaxPage        = maxPage,
                AreaName       = "",
                ActionName     = actionName,
                ControllerName = ControllersConstants.Types
            };

            var manufacturers = GetAllManufacturers();
            var types         = CreateTypesViewModel(typesNames);

            return(new TypesProductsViewModel
            {
                Types = types,
                Manufacturers = manufacturers,
                Products = products,
                Page = pageViewModel,
                Kind = kind
            });
        }
Beispiel #3
0
        public async Task <IActionResult> Index(string searchToken = null, int page = 1)
        {
            if (page < 1)
            {
                return(RedirectToAction(nameof(Index)));
            }

            PagesViewModel <CourseBasicServiceModel> model = new PagesViewModel <CourseBasicServiceModel>
            {
                Elements    = await this.courseService.GetAllListingAsync(searchToken, page),
                SearchToken = searchToken,
                Pagination  = new PaginationViewModel
                {
                    TotalElements = await this.courseService.TotalCountAsync(searchToken),
                    PageSize      = CoursePageSize,
                    CurrentPage   = page
                }
            };

            if (page > model.Pagination.TotalPages && model.Pagination.TotalPages != 0)
            {
                return(RedirectToAction(nameof(Index), new { page = model.Pagination.TotalPages }));
            }

            return(View(model));
        }
        public ActionResult Index(int page = 1, int pageSize = 10)
        {
            var butterClient = new ButterCMSClient("YOUR KEY");

            var parameterDict = new Dictionary <string, string>()
            {
                { "page", page.ToString() },
                { "page_size", pageSize.ToString() },
            };



            PagesResponse <Page> caseStudyPages = butterClient.ListPages <Page>("sample-page", parameterDict);

            var viewModel = new PagesViewModel();

            viewModel.CaseStudies = new List <PageViewModel>();
            PageResponse <Page> myPage             = butterClient.RetrievePage <Page>("*", "sample-page", parameterDict);
            PageViewModel       caseStudyViewModel = new PageViewModel();

            caseStudyViewModel.Readme      = myPage.Data.Fields.readme;
            caseStudyViewModel.Seo         = myPage.Data.Fields.seo;
            caseStudyViewModel.twitterCard = myPage.Data.Fields.twitter_card;
            caseStudyViewModel.openGraph   = myPage.Data.Fields.open_graph;
            caseStudyViewModel.Slug        = myPage.Data.Slug;
            viewModel.CaseStudies.Add(caseStudyViewModel);

            return(View(viewModel));
        }
        private BrandsProductsViewModel CreateProductsModel(string[] brandsNames, string gender,
                                                            int currentPage, int maxPage,
                                                            string actionName, IEnumerable <ProductIndexViewModel> products)
        {
            var pageViewModel = new PagesViewModel()
            {
                CurrentPage    = currentPage,
                MaxPage        = maxPage,
                AreaName       = "",
                ActionName     = actionName,
                ControllerName = ControllersConstants.Brands
            };

            var teams  = this.GetAllTeams();
            var brands = this.CreateBrandsViewModel(brandsNames);

            return(new BrandsProductsViewModel()
            {
                Brands = brands,
                Teams = teams,
                Products = products,
                Page = pageViewModel,
                Gender = gender
            });
        }
Beispiel #6
0
 public AppViewModel(DashboardViewModel dashboardViewModel, MenuViewModel menuViewModel, ToolBarViewModel toolBarViewModel, PagesViewModel pagesViewModel)
 {
     MenuViewModel                  = menuViewModel;
     PagesViewModel                 = pagesViewModel;
     ToolBarViewModel               = toolBarViewModel;
     DashboardViewModel             = dashboardViewModel;
     ToolBarViewModel.MenuViewModel = MenuViewModel;
 }
        public App()
        {
            InitializeComponent();

            mainViewmodel        = new PagesViewModel();
            Barrel.ApplicationId = Constants.BarrelApplicationId;
            MainPage             = new NavigationPage(new MainPage());
        }
Beispiel #8
0
        public ActionResult Pages()
        {
            var model = new PagesViewModel
            {
                PageList = _pageService.Get().ToList()
            };

            return(PartialView("_PageManager", model));
        }
Beispiel #9
0
        public ServiceResult <int> UpdatePagesById(PagesViewModel model)
        {
            var oldEntity = _context.Pages.FirstOrDefault(q => q.Id == model.Id);

            Mapper.Map(model, oldEntity);
            _context.SaveChanges();
            var result = ServiceResult <int> .Okay(model.Id);

            return(result);
        }
Beispiel #10
0
 public CharitiesController(Models.MarathonSkillsContext context)
 {
     this.context        = context;
     pagesViewModel      = new PagesViewModel <Charity>();
     pagesViewModel.Data = new PageData()
     {
         ControllerName = "Charities",
         ActionName     = "Index",
         ButtonsLimit   = 6
     };
     pagesManager = new PagesManager <Charity>(context.Charities, 5);
 }
Beispiel #11
0
        public async Task <ActionResult> Create(
            PagesViewModel applicationPage,
            long[] childernPages)
        {
            if (ModelState.IsValid)
            {
                applicationPage.Page.Active       = true;
                applicationPage.Page.NamesUpdated = true;
                await PageManager.CreatePageAsync(page : applicationPage.Page, parentPages : null, childernPages : childernPages);

                return(RedirectToAction("Index"));
            }
            return(View(applicationPage));
        }
        public ContentPage()
        {
            InitializeComponent();

            viewModel = (PagesViewModel)DataContext;
            canvas    = BookCanvas;

            DrawContentPages();

            viewModel.PropertyChanged   += OnViewModelPropertyChanged;
            viewModel.Redraw            += OnViewModelRedraw;
            viewModel.BackgroundChanged += OnViewModelBackgroundChanged;
            viewModel.ImageChanged      += OnViewModelImageChanged;
            viewModel.CommentChanged    += OnViewModelCommentChanged;
        }
Beispiel #13
0
        public IActionResult Index([FromRoute] string title)
        {
            var page = _context.Pages.Where(x => x.Title == title).FirstOrDefault();

            if (page == null)
            {
                return(NotFound());
            }
            var            careers = _context.Careers.Where(x => x.Pages.Id == page.Id).AsEnumerable();
            PagesViewModel model   = new PagesViewModel {
                Pages = page, Careers = careers
            };

            return(View(model));
        }
        public ActionResult AdminPages()
        {
            var pages = _db.WikiPages.Include(x => x.Author);

            if (!IsWikiAdmin)
            {
                pages = pages.Where(x => !x.IsSystemPage && x.Author.Login == CurrentUser.Login);
            }

            var model = new PagesViewModel()
            {
                Pages = GetPages(pages),
            };

            return(View(model));
        }
Beispiel #15
0
        public async Task <ActionResult> Create()
        {
            var pagesViewModel = new PagesViewModel();
            var allPages       = await this.PageManager.Pages.ToListAsync();

            foreach (var page in allPages)
            {
                var listItem = new SelectListItem()
                {
                    Text  = page.NameEn + "|" + page.NameAr,
                    Value = page.ApplicationPageId.ToString(),
                };
                pagesViewModel.ChildernPagesList.Add(listItem);
            }

            return(View(pagesViewModel));
        }
Beispiel #16
0
        public async Task <ActionResult> Edit(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var item = await this.PageManager.GetPageWithRelationsAsync(id.Value);

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

            var model = new PagesViewModel()
            {
                Page = item
            };

            var allPages = await this.PageManager.Pages.Where(p => p.ApplicationPageId != id).ToListAsync();

            foreach (var p in allPages)
            {
                var listItem = new SelectListItem()
                {
                    Text     = p.NameEn + "|" + p.NameAr,
                    Value    = p.ApplicationPageId.ToString(),
                    Selected = item.ChildernPages.Any(g => g.ApplicationPageId == p.ApplicationPageId)
                };
                model.ChildernPagesList.Add(listItem);
            }

            //foreach (var p in allPages)
            //{
            //    var listItem = new SelectListItem()
            //    {
            //        Text = p.NameEn + "|" + p.NameAr,
            //        Value = p.ApplicationPageId.ToString(),
            //        Selected = item.ParentPages.Any(g => g.ApplicationPageId == p.ApplicationPageId)
            //    };
            //    model.ParentPagesList.Add(listItem);
            //}

            return(View(model));
        }
Beispiel #17
0
        public async Task <ActionResult> Edit(PagesViewModel applicationPage, long[] childernPages)
        {
            if (!ModelState.IsValid)
            {
                return(View(applicationPage));
            }
            applicationPage.Page.NamesUpdated = true;
            var result = await PageManager.UpdatePageAsync(applicationPage.Page);

            if (result != IdentityResult.Success)
            {
                return(RedirectToAction("Index"));
            }
            childernPages = childernPages ?? new long[] { };
            await PageManager.SetPageParentsChildernAsync(applicationPage.Page.ApplicationPageId, childernPages);

            return(RedirectToAction("Index"));
        }
        public ActionResult Pages(string tag, int page = 1)
        {
            var pages = _db.WikiPages
                        .Include(x => x.Tags)
            ;

            if (!string.IsNullOrEmpty(tag))
            {
                tag   = tag.ToLower();
                pages = pages.Where(x => x.Tags.Any(z => z.TagForLink == tag));
            }

            var model = new PagesViewModel()
            {
                Pages = GetPages(pages, global: string.IsNullOrEmpty(tag?.Trim())),
            };

            return(View(model));
        }
Beispiel #19
0
        public IHttpActionResult Get([FromUri] PagesViewModel viewModel)
        {
            //pages are zero-based and it CAN be equal zero
            if (viewModel.blocksPerPage <= 0 ||
                viewModel.stringsPerBlock <= 0 ||
                viewModel.pageNumber < 0)
            {
                return(BadRequest("Parameters can not be negative!"));
            }

            var path    = HostingEnvironment.MapPath("~/Content/data.txt");
            var strings = FileStringsGetter.GetStrings(path);

            var page = PageBuilder.GetPage(
                strings, viewModel.blocksPerPage,
                viewModel.stringsPerBlock, viewModel.pageNumber);

            return(Json(page));
        }
Beispiel #20
0
        public ActionResult Index()
        {
            var model = new PagesViewModel()
            {
                PageList  = _pageService.Get(),
                PageAreas = new List <string>()
            };

            foreach (var pageArea in model.PageList.GroupBy(x => x.PageArea))
            {
                if (pageArea.Key == null)
                {
                    continue;
                }

                model.PageAreas.Add(pageArea.Key);
            }

            return(View(model));
        }
Beispiel #21
0
        public static IViewModel LoadUserAccessiblePages()
        {
            try
            {
                using (DBContext context = DBContext.Create())
                {
                    PagesViewModel result = new PagesViewModel {
                        Result = Result.Ok
                    };
                    string login  = HttpContext.Current.User.Identity.Name;
                    Guid   userId = GetEntityValue <User, Guid>(context, o => o.Login == login, o => o.Id);

                    if (userId == Guid.Empty)
                    {
                        result.Result  = Result.Error;
                        result.Message = "Ошибка входа пользователя!";

                        return(result);
                    }
                    List <Guid> roleIds =
                        GetEntitiesWithJoin <User, UserRole, Guid, Guid>(context,
                                                                         o => o.Login == login,
                                                                         o => o.Id,
                                                                         o => o.UserId,
                                                                         (fo, so) => fo.RoleId
                                                                         );
                    List <Guid> rightIds = GetEntitiesWithJoin <Role, RightRole, Guid, Guid>(context, o => roleIds.Contains(o.Id), fo => fo.Id, so => so.RoleId, (fo, so) => fo.RightId);
                    result.AccesibleReferences     = GetUserAccesibleReferences(context, rightIds);
                    result.AccesiblePages          = GetUserAccesiblePages(context, rightIds);
                    result.AccesibleAdministration = GetUserAccesibleAdministration(context, rightIds);

                    return(result);
                }
            }
            catch (Exception exc)
            {
                return(LogErrorManager.Add(exc));
            }
        }
Beispiel #22
0
        private TeamProductsViewModel TeamProductsViewModel(int id, int currentPage, int maxPage,
                                                            string actionName, TeamDetailsViewModel teamDetailsViewModel)
        {
            var pageViewModel = new PagesViewModel()
            {
                CurrentPage    = currentPage,
                MaxPage        = maxPage,
                AreaName       = "",
                ActionName     = actionName,
                ControllerName = controllerName,
                RouteId        = id,
            };

            var teams = this.GetAllTeams();

            return(new TeamProductsViewModel()
            {
                Teams = teams,
                TeamWithProducts = teamDetailsViewModel,
                Page = pageViewModel
            });
        }
Beispiel #23
0
        private ManufacturerProductsViewModel ManufacturerProductsViewModel(int id, int currentPage, int maxPage,
                                                                            string actionName, ManufacturerDetailsViewModel manufacturerDetailsViewModel)
        {
            var pageViewModel = new PagesViewModel
            {
                CurrentPage    = currentPage,
                MaxPage        = maxPage,
                AreaName       = "",
                ActionName     = actionName,
                ControllerName = _controllerName,
                RouteId        = id
            };

            var manufacturers = GetAllManufacturers();

            return(new ManufacturerProductsViewModel
            {
                Manufacturers = manufacturers,
                ManufacturerWithProducts = manufacturerDetailsViewModel,
                Page = pageViewModel
            });
        }
        private ProductsViewModel CreateProductsModel(int currentPage, int maxPage,
                                                      string actionName, IEnumerable <ProductIndexViewModel> products)
        {
            var pageViewModel = new PagesViewModel()
            {
                CurrentPage    = currentPage,
                MaxPage        = maxPage,
                AreaName       = "",
                ActionName     = actionName,
                ControllerName = controllerName
            };

            var teams  = this.GetAllTeams();
            var brands = this.GetAllBrands();

            return(new ProductsViewModel()
            {
                Brands = brands,
                Teams = teams,
                Products = products,
                Page = pageViewModel
            });
        }
        private ProductsViewModel CreateProductsModel(int currentPage, int maxPage,
                                                      string actionName, IEnumerable <ProductIndexViewModel> products)
        {
            var pageViewModel = new PagesViewModel
            {
                CurrentPage    = currentPage,
                MaxPage        = maxPage,
                AreaName       = "",
                ActionName     = actionName,
                ControllerName = _controllerName
            };


            var manufacturers = GetAllManufacturers();
            var types         = GetAllTypes();

            return(new ProductsViewModel
            {
                Types = types,
                Manufacturers = manufacturers,
                Products = products,
                Page = pageViewModel
            });
        }
Beispiel #26
0
        public ActionResult Index()
        {
            // we return a list of everything
            var viewmodel = new PagesViewModel();

            viewmodel.pages =
                MASTERdomain.pages.Select(
                    x =>
                    new Page()
            {
                id      = x.id.ToString(),
                title   = x.name,
                updated = x.updated.ToString(GeneralConstants.DATEFORMAT_STANDARD),
                visible = ((PageSettings)x.settings).HasFlag(PageSettings.VISIBLE)
            });
            viewmodel.blogs = MASTERdomain.blogs.Select(x => new Blog()
            {
                id          = x.id.ToString(),
                title       = x.title,
                articles    = x.articles.ToModel(),
                commentType = (Commenting)x.comments
            });
            return(View(viewmodel));
        }
Beispiel #27
0
 public PagesView()
 {
     InitializeComponent();
     BindingContext = new PagesViewModel();
 }
Beispiel #28
0
 protected override void OnAppearing()
 {
     Settings.CurrentPage = "pages";
     BindingContext       = new PagesViewModel();
 }
Beispiel #29
0
        public ItemsPage()
        {
            InitializeComponent();

            BindingContext = viewModel = new PagesViewModel();
        }
Beispiel #30
0
        public PagesView()
        {
            InitializeComponent();

            DataContext = new PagesViewModel();
        }