コード例 #1
0
        private ViewingAndCancelRecordingViewModel GetFilledViewingAndCancelRecordingViewModel()
        {
            ViewingAndCancelRecordingViewModel viewModel = new ViewingAndCancelRecordingViewModel
            {
                FioPatient      = HttpContext.Session.GetString("fioPatient"),
                BirthdayPatient = HttpContext.Session.GetString("birthdayPatient"),
                NameLpu         = HttpContext.Session.GetString("nameCurrentLpu"),
                AddressLpu      = HttpContext.Session.GetString("addressCurrentLpu")
            };

            List <AppointmentQualityDBModel> appointmentQuality = null;

            using (DataBaseContext db = new DataBaseContext())
            {
                appointmentQuality = db.AppointmentQuality.Where(a => a.FioPatient == viewModel.FioPatient &&
                                                                 a.DateAppointment >= DateTime.Today &&
                                                                 a.Rating == 0 &&
                                                                 a.RecordingCancel == false).ToList();
            }

            int page          = 1;
            int itemPageCount = 2;
            int count         = appointmentQuality.Count();
            var items         = appointmentQuality.Skip((page - 1) * itemPageCount).Take(itemPageCount).ToList();
            PaginationViewModel pageViewModel = new PaginationViewModel(count, page, itemPageCount);

            viewModel.AppointmentQuality  = items;
            viewModel.PaginationViewModel = pageViewModel;

            return(viewModel);
        }
コード例 #2
0
        public JsonResult GetVehicles(VehicleViewModel vViewModel)
        {
            PaginationInfo pager = new PaginationInfo();

            pager = vViewModel.Pager;

            PaginationViewModel pViewModel = new PaginationViewModel();

            try
            {
                pViewModel.dt = _vRepo.GetVehicles(vViewModel.Vehicle.VehicleName, vViewModel.Vehicle.VehicleTypeId, vViewModel.Vehicle.VehicleBrandId, ref pager);

                pViewModel.Pager = pager;

                Logger.Debug("Vehicle Controller GetVehicles");
            }

            catch (Exception ex)
            {
                vViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01"));

                Logger.Error("Vehicle Controller - GetVehicles" + ex.ToString());
            }

            return(Json(JsonConvert.SerializeObject(pViewModel), JsonRequestBehavior.AllowGet));
        }
コード例 #3
0
        private ServiceEvaluationViewModel GetFilledServiceEvaluationViewModel()
        {
            ServiceEvaluationViewModel viewModel = new ServiceEvaluationViewModel
            {
                FioPatient      = HttpContext.Session.GetString("fioPatient"),
                BirthdayPatient = HttpContext.Session.GetString("birthdayPatient"),
                NameLpu         = HttpContext.Session.GetString("nameCurrentLpu"),
                AddressLpu      = HttpContext.Session.GetString("addressCurrentLpu")
            };

            List <AppointmentQualityDBModel> appointmentQuality = null;

            using (DataBaseContext db = new DataBaseContext())
            {
                appointmentQuality = db.AppointmentQuality.Where(a => a.FioPatient == viewModel.FioPatient &&
                                                                 (a.DateAppointment == DateTime.Today ||
                                                                  a.DateAppointment == DateTime.Today.AddDays(-1)) &&
                                                                 a.Rating == 0).ToList();
            }

            int page          = 1;
            int itemPageCount = 2;
            int count         = appointmentQuality.Count();
            var items         = appointmentQuality.Skip((page - 1) * itemPageCount).Take(itemPageCount).ToList();
            PaginationViewModel pageViewModel = new PaginationViewModel(count, page, itemPageCount);

            viewModel.AppointmentQuality  = items;
            viewModel.PaginationViewModel = pageViewModel;

            return(viewModel);
        }
コード例 #4
0
        public static PaginationViewModel CreatePaginationData(int take, int pageNumber, int totalItemCount, int pageItemCount)
        {
            var pagination = new PaginationViewModel();

            pagination.ItemCount = totalItemCount;

            pagination.PageNumber = pageNumber;
            var numberOfPages = (int)Math.Ceiling(Decimal.Divide(totalItemCount, take));

            pagination.NumberOfPages = numberOfPages;

            pagination.FromItem = pageNumber * take - take + 1;
            pagination.ToItem   = pageNumber * take - take + pageItemCount;

            var pagesList = new List <int>();

            for (int i = 1; i <= numberOfPages; i++)
            {
                pagesList.Add(i);
            }

            var numberOfFivePages = (int)Math.Floor((decimal)pageNumber / 5);

            if (pageNumber % 5 == 0)
            {
                numberOfFivePages -= 1;
            }
            var skipPages = numberOfFivePages * 5;

            pagesList            = pagesList.Skip(skipPages).Take(5).ToList();
            pagination.PagesList = pagesList;
            return(pagination);
        }
コード例 #5
0
ファイル: FeedController.cs プロジェクト: IncAlpha/FeedApp
        public async Task <IActionResult> MyArticles(int page = 1)
        {
            var query = _articlesRepository.GetByOwner(GetCurrentUserId());

            var count = await query.CountAsync();

            var paginationModel = new PaginationViewModel("Feed", "MyArticles", count, page);

            try
            {
                paginationModel.Validate(page);
            }
            catch (PaginationOutOfRangeException ex)
            {
                page = ex.Negative ? 1 : paginationModel.TotalPages;

                return(RedirectToAction("MyArticles", new { Page = page }));
            }

            var articles = await paginationModel.GetQuery(query
                                                          .OrderByDescending(article => article.CreatedAt))
                           .ToListAsync();


            var model = new MyArticlesViewModel(paginationModel, articles);

            return(View(model));
        }
コード例 #6
0
        //  [AuthorizeUser(RoleModule.HotelTariff, Function.View)]
        public JsonResult GetRoomOccupancy(HotelTariffViewModel htViewModel)
        {
            PaginationInfo pager = new PaginationInfo();

            pager = htViewModel.Pager;

            PaginationViewModel pViewModel = new PaginationViewModel();

            try
            {
                pViewModel.dt = _htRepo.GetRoomOccupancy(htViewModel.HotelTariffRoomOccupancy.HotelTariffRoomDetailsId, ref pager);

                pViewModel.Pager = pager;

                Logger.Debug("HotelTariff Controller GetRoomOccupancy");
            }

            catch (Exception ex)
            {
                htViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01"));

                Logger.Error("HotelTariff Controller - GetRoomOccupancy" + ex.ToString());
            }

            return(Json(JsonConvert.SerializeObject(pViewModel), JsonRequestBehavior.AllowGet));
        }
コード例 #7
0
        public ActionResult Search(string tag = "", int page = 1)
        {
            var     imagesOnPage = ImagesOnPage;
            BllPost ad;

            var pageInfo = new PageInfo
            {
                PageNumber = page,
                PageSize   = ImagesOnPage,
                TotalItems = _postService.CountByTag(tag),
                UrlPart    = Url.Action("LoadMore", "Posts", new { tag })
            };

            var photosIds = _postService.GetByTag(tag, pageInfo.Skip, pageInfo.PageSize)
                            .Select(p => p.PostId);
            var photos = new List <ImageViewModel>(photosIds.Count());

            photos.AddRange(photosIds.Select(id => new ImageViewModel
            {
                ImageUrl        = ToImageUrl(id),
                ImageDetailsUrl = ToImageDetailsUrl(id)
            }));

            var pagedPosts =
                new PaginationViewModel <ImageViewModel> {
                PageInfo = pageInfo, Items = photos
            };

            return(Json(pagedPosts, JsonRequestBehavior.AllowGet));
        }
コード例 #8
0
        public JsonResult GetStates(StateViewModel sViewModel)
        {
            PaginationInfo pager = new PaginationInfo();

            pager = sViewModel.Pager;

            PaginationViewModel pViewModel = new PaginationViewModel();

            try
            {
                pViewModel.dt = _sRepo.GetStates(sViewModel.State.CountryId, sViewModel.State.StateCode, sViewModel.State.StateName, ref pager);

                pViewModel.Pager = pager;

                Logger.Debug("State Controller GetStates");
            }

            catch (Exception ex)
            {
                sViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01"));

                Logger.Error("State Controller - GetStates" + ex.ToString());
            }

            return(Json(JsonConvert.SerializeObject(pViewModel), JsonRequestBehavior.AllowGet));
        }
コード例 #9
0
        public DataTable GetAllPatientList(PaginationViewModel paginatedDTO, string CNIC = "")
        {
            DataTable dt = new DataTable();

            using (var db = new HMISDBContext())
            {
                var conn = (SqlConnection)db.Database.GetDbConnection();
                try
                {
                    DataSet    ds      = new DataSet();
                    SqlCommand sqlComm = new SqlCommand("GetPatientList", conn);
                    sqlComm.Parameters.AddWithValue("@vCNIC", CNIC);
                    sqlComm.CommandType = CommandType.StoredProcedure;
                    SqlDataAdapter da = new SqlDataAdapter();
                    da.SelectCommand = sqlComm;
                    da.Fill(ds);
                    dt = ds.Tables[0];
                    return(dt);
                }
                catch (Exception ex)
                {
                    throw;
                }
                finally
                {
                    conn.Close();
                }
            }
        }
コード例 #10
0
        public IActionResult All(string searchTerm, int page = 1)
        {
            if (page < 1)
            {
                return(RedirectToAction(nameof(All), new { searchTerm = searchTerm }));
            }

            var companiesPagination = new PaginationViewModel()
            {
                CurrentPage   = page,
                PageSize      = WebConstants.Pagination.CompaniesPageSize,
                TotalElements = this.companies.TotalCompanies(searchTerm),
                SearchTerm    = searchTerm,
                Action        = nameof(All),
                Controller    = WebConstants.Controller.Companies
            };

            if (page > companiesPagination.TotalPages && companiesPagination.TotalPages != 0)
            {
                return(RedirectToAction(nameof(All), new { searchTerm = searchTerm, page = companiesPagination.TotalPages }));
            }

            return(View(new AllCompanies()
            {
                Companies = this.companies.All(page, searchTerm, WebConstants.Pagination.CompaniesPageSize),
                Pagination = companiesPagination
            }));
        }
コード例 #11
0
        public JsonResult GetSightSeeingTariffBasic(SightSeeingTariffViewModel sstViewModel)
        {
            PaginationInfo pager = new PaginationInfo();

            pager = sstViewModel.Pager;

            PaginationViewModel pViewModel = new PaginationViewModel();

            try
            {
                pViewModel.dt = _sstRepo.GetSightSeeingTariffBasic(sstViewModel.SightSeeingTariff.VendorId, sstViewModel.SightSeeingTariff.SightSeeingId, ref pager);

                pViewModel.Pager = pager;

                Logger.Debug("SightSeeingTariff Controller GetSightSeeingTariffBasic");
            }

            catch (Exception ex)
            {
                sstViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01"));

                Logger.Error("SightSeeingTariff Controller - GetSightSeeingTariffBasic" + ex.ToString());
            }

            return(Json(JsonConvert.SerializeObject(pViewModel), JsonRequestBehavior.AllowGet));
        }
コード例 #12
0
        public IActionResult Index(int id = 1)
        {
            var games = this.gamesService
                        .GetAll <GameAdministrationViewModel>(GamesPerPage, (id - 1) * GamesPerPage);

            var viewModel = new GameAdministrationIndexViewModel {
                Games = games
            };

            var count = this.gamesService.GetCount();

            var pagination = new PaginationViewModel();

            pagination.PagesCount = (int)Math.Ceiling((double)count / GamesPerPage);
            if (pagination.PagesCount == 0)
            {
                pagination.PagesCount = 1;
            }

            pagination.CurrentPage = id;

            viewModel.Pagination = pagination;

            return(this.View(viewModel));
        }
コード例 #13
0
        public JsonResult GetUser(UserViewModel uViewModel)
        {
            PaginationInfo pager = new PaginationInfo();

            pager = uViewModel.Pager;

            PaginationViewModel pViewModel = new PaginationViewModel();

            try
            {
                pViewModel.dt = _uRepo.GetUser(uViewModel.User.UserName, uViewModel.User.RoleId, ref pager);

                pViewModel.Pager = pager;

                Logger.Debug("User Controller GetUser");
            }

            catch (Exception ex)
            {
                uViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01"));

                Logger.Error("User Controller - GetUser" + ex.ToString());
            }

            return(Json(JsonConvert.SerializeObject(pViewModel), JsonRequestBehavior.AllowGet));
        }
コード例 #14
0
        public async Task <IActionResult> GetAll(SearchFormModel searchForm, int page = WebConstants.FirstPage)
        {
            if (page < WebConstants.FirstPage)
            {
                page = WebConstants.FirstPage;
            }

            var allRequests = await this.requests.GetAll(searchForm.Status, page);

            var pagination = new PaginationViewModel()
            {
                PageSize      = WebConstants.ItemsPerPage,
                TotalElements = allRequests.TotalItems,
                CurrentPage   = page
            };

            if (page > pagination.TotalPages)
            {
                pagination.CurrentPage = pagination.TotalPages;
            }

            var result = new RequestListingViewModel()
            {
                Requests   = allRequests.Requests,
                Pagination = pagination,
                Search     = searchForm
            };

            return(this.View(result));
        }
コード例 #15
0
        public async Task <IHttpActionResult> SearchDeliveryNote(int page, int pageSize, string searchString)
        {
            searchString.Trim();
            var deliveryNotes = await _db.Deliveries
                                .Where(
                d =>
                d.DeliveryDeleted == false &&
                (d.DeliveryOrder.OrderGuid.ToString() == searchString ||
                 d.DeliveryGuid.ToString() == searchString))
                                .OrderByDescending(o => o.DeliveryGuid)
                                .Skip(page * pageSize)
                                .Take(pageSize)
                                .ToListAsync();

            var dataVm = new PaginationViewModel
            {
                DataObject = deliveryNotes,
                PageAmount =
                    (_db.Deliveries.Count(
                         d =>
                         d.DeliveryDeleted == false &&
                         (d.DeliveryOrder.OrderGuid.ToString() == searchString ||
                          d.DeliveryGuid.ToString() == searchString)) + pageSize - 1) / pageSize,
                CurrentPage = page
            };

            return(Ok(dataVm));
        }
コード例 #16
0
            public void ItShouldReturnCorrectRecipesForSubsequentPages()
            {
                var recipes = new List <Recipe>();

                for (int i = 1; i < 15; i++)
                {
                    recipes.Add(new Recipe {
                        Id = i, Title = "Recipe_" + i
                    });
                }
                _recipeRepositoryMock.Setup(x => x.GetAll()).Returns(recipes.AsQueryable);
                var recipeViewModelList = _iMapper.Map <IEnumerable <Recipe>, IEnumerable <RecipeViewModel> >(recipes);
                var pager     = new Pager(recipeViewModelList.Count(), 2);
                var viewModel = new PaginationViewModel
                {
                    Items = recipeViewModelList.Skip((pager.CurrentPage - 1) * pager.PageSize).Take(pager.PageSize).ToList(),
                    Pager = pager
                };

                var result          = _controller.RecipesList(2) as ViewResult;
                var paginationModel = (PaginationViewModel)result.Model;

                Assert.Collection(paginationModel.Items,
                                  item => Assert.Equal(11, item.Id),
                                  item => Assert.Equal(12, item.Id),
                                  item => Assert.Equal(13, item.Id),
                                  item => Assert.Equal(14, item.Id)
                                  );
            }
コード例 #17
0
        public JsonResult GetSightSeeing(SightSeeingViewModel sViewModel)
        {
            PaginationInfo pager = new PaginationInfo();

            pager = sViewModel.Pager;

            PaginationViewModel pViewModel = new PaginationViewModel();

            try
            {
                //Modification by swapali | Date:28/06/2017
                pViewModel.dt = _sRepo.GetSightSeeing(sViewModel.SightSeeing.SightSeeingName, sViewModel.SightSeeing.CityId, ref pager);

                pViewModel.Pager = pager;

                Logger.Debug("SightSeeing Controller GetSightSeeing");
            }

            catch (Exception ex)
            {
                sViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01"));

                Logger.Error("SightSeeing Controller - GetSightSeeing" + ex.ToString());
            }

            return(Json(JsonConvert.SerializeObject(pViewModel), JsonRequestBehavior.AllowGet));
        }
コード例 #18
0
        //[AuthorizeUser(RoleModule.Agent, Function.View)]
        public JsonResult GetAgents(AgentViewModel aViewModel)
        {
            PaginationInfo pager = new PaginationInfo();

            pager = aViewModel.Pager;

            PaginationViewModel pViewModel = new PaginationViewModel();

            try
            {
                pViewModel.dt = _agentManager.GetAgents(aViewModel.AgentInfo.BranchId, aViewModel.AgentInfo.FirstName, ref pager);

                pViewModel.Pager = pager;

                Logger.Debug("Agent Controller GetAgents");
            }

            catch (Exception ex)
            {
                aViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01"));

                Logger.Error("Agent Controller - GetAgents" + ex.ToString());
            }

            return(Json(JsonConvert.SerializeObject(pViewModel), JsonRequestBehavior.AllowGet));
        }
コード例 #19
0
        public JsonResult GetHotelType(HotelTypeViewModel hViewModel)
        {
            PaginationInfo pager = new PaginationInfo();

            pager = hViewModel.Pager;

            PaginationViewModel pViewModel = new PaginationViewModel();

            try
            {
                pViewModel.dt = _hRepo.GetHotelType(hViewModel.HotelTypeInfo.HotelType, ref pager);

                pViewModel.Pager = pager;

                Logger.Debug("HotelType Controller GetHotelType");
            }

            catch (Exception ex)
            {
                hViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01"));

                Logger.Error("HotelType Controller - GetHotelType" + ex.ToString());
            }

            return(Json(JsonConvert.SerializeObject(pViewModel), JsonRequestBehavior.AllowGet));
        }
コード例 #20
0
        public JsonResult GetBusinesses(BusinessViewModel bViewModel)
        {
            PaginationInfo pager = new PaginationInfo();

            pager = bViewModel.Pager;

            PaginationViewModel pViewModel = new PaginationViewModel();

            try
            {
                pViewModel.dt = _bRepo.GetBusinesses(bViewModel.Business.BusinessName, ref pager);

                pViewModel.Pager = pager;

                Logger.Debug("Business Controller GetBusinesses");
            }

            catch (Exception ex)
            {
                bViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01"));

                Logger.Error("Business Controller - GetBusinesses" + ex.ToString());
            }

            return(Json(JsonConvert.SerializeObject(pViewModel), JsonRequestBehavior.AllowGet));
        }
コード例 #21
0
ファイル: CatalogService.cs プロジェクト: Kagankoc/GoldStore
        public PagedProductViewModel FetchProducts(string categorySlug, string brandSlug)
        {
            var brands     = _brandRepository.GetAllBrands().Where(brand => brand.IsDeleted == false);
            var categories = _categoryRepository.GetAllCategories().Where(category => category.IsDeleted == false);

            var productPage = GetCurrentPage();

            IEnumerable <Product> products = new List <Product>();
            var productCount = 0;


            productCount = GetProducts(categorySlug, brandSlug, productPage, out products);


            var totalPages = (int)Math.Ceiling((decimal)productCount / _productPerPage);

            int[] pages = Enumerable.Range(1, totalPages).ToArray();

            var pagedProduct = new PaginationViewModel
            {
                Products         = products,
                HasPreviousPages = (productPage > 1),
                CurrentPage      = productPage,
                HasNextPages     = (productPage < totalPages),
                Pages            = pages
            };
            var pagedProducts = new PagedProductViewModel
            {
                PagedProducts = pagedProduct,
                Brands        = brands,
                Categories    = categories
            };

            return(pagedProducts);
        }
コード例 #22
0
        public async Task <IActionResult> SingleMeme(int id, int commentPage)
        {
            int maxNumberOfPages = (await commentRepo.CountAsync(new CountCommentsOnMeme(id)) - 1) / 20 + 1;

            if (maxNumberOfPages == 0)
            {
                maxNumberOfPages = 1;
            }

            if (commentPage < 0 || commentPage > maxNumberOfPages)
            {
                return(NotFound());
            }

            var memes = await memeRepo.GetAsync(new SingleMemeSpec(id));

            var meme = memes.FirstOrDefault();

            if (meme == null)
            {
                return(NotFound());
            }

            var userId = this.GetCurrentUserId();

            var memeUserPoint = await memeXdPointRepo.GetAsync(new MemeXdPointConcreteUserIdAndMemeIdSpec(userId, meme.Id));

            var isMemeXdClicked = (userId == null || memeUserPoint.FirstOrDefault() == null) ? false : true;

            var comments = await commentRepo.GetAsync(new PageOfCommentsSingleMemeSpec(commentPage, id));

            var commentViewModels = new List <CommentViewModel>();

            foreach (var comment in comments)
            {
                var userPoint = await commentXdPointRepo.GetAsync(new CommentXdPointConcreteUserIdAndMemeIdSpec(userId, comment.Id));

                var isXdClicked = (userId == null || userPoint.FirstOrDefault() == null) ? false : true;
                commentViewModels.Add(new CommentViewModel(comment, isXdClicked, configuration));
            }

            var paginationViewModel = new PaginationViewModel()
            {
                ActionName       = "SingleMeme",
                ControllerName   = "Home",
                CurrentPage      = commentPage,
                MaxNumberOfPages = maxNumberOfPages,
                AllRouteData     = new Dictionary <string, string> {
                    { "id", meme.Id.ToString() }
                },
                AlternativePageName = "commentPage"
            };

            return(View(new SingleMemeViewModel
            {
                MemeCardViewModel = new MemeCardViewModel(meme, isMemeXdClicked, configuration),
                CommentViewModels = commentViewModels,
                PaginationViewModel = paginationViewModel
            }));
        }
コード例 #23
0
        // GET: Shop
        public async Task <ActionResult> Index()
        {
            if (!LocalStorageExtensions.ValidSession(ControllerContext.ActionDescriptor.ControllerName))
            {
                LocalStorageExtensions.Clear();
                return(RedirectToAction(nameof(AccountController.Login), "Account"));
            }

            try
            {
                PaginationViewModel paginationViewModel = new PaginationViewModel()
                {
                    userId   = LocalStorageExtensions.Get(StorageType.UserId),
                    pageId   = 1,
                    pageSize = -1,
                };
                string response = await APICallerExtensions.APICallAsync("Shop/GetAll", paginationViewModel, false, HttpContext.Session.GetObject(StorageType.Token).ToString());

                if (response.ToLower().Contains("exception:"))
                {
                    ModelState.AddModelError(string.Empty, response);
                    return(View());
                }
                ShopViewModel shopViewModel = new ShopViewModel();
                var           content       = JsonConvert.DeserializeObject <SingleResponse <List <Shop> > >(response);
                if (!content.DidError)
                {
                    shopViewModel.listShops = content.Model;

                    PaginationViewModel paginationViewModel2 = new PaginationViewModel()
                    {
                        pageId   = 1,
                        pageSize = -1,
                    };
                    string response2 = await APICallerExtensions.APICallAsync("Company/GetAll", paginationViewModel2, false, HttpContext.Session.GetObject(StorageType.Token).ToString());

                    if (response.ToLower().Contains("exception:"))
                    {
                        ModelState.AddModelError(string.Empty, response2);
                    }
                    var content2 = JsonConvert.DeserializeObject <SingleResponse <List <Company> > >(response2);
                    if (!content.DidError)
                    {
                        shopViewModel.listCompanies = content2.Model;
                    }

                    return(View(shopViewModel));
                }
                else
                {
                    ModelState.AddModelError(string.Empty, content.Message);
                    return(View());
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);
                return(View());
            }
        }
コード例 #24
0
        public async Task <ActionResult <List <TransferRoute> > > Get([FromQuery] PaginationViewModel paginationViewModel)
        {
            var queryable = _context.TransferRoute.AsQueryable();
            await HttpContext.InsertPaginationParametersInResponse(queryable, paginationViewModel.RecordsPerPage);

            return(await queryable.Paginate(paginationViewModel).ToListAsync());
        }
コード例 #25
0
        //[AuthorizeUser(RoleModule.Department, Function.View)]
        public JsonResult GetDepartments(DepartmentViewModel dViewModel)
        {
            PaginationInfo pager = new PaginationInfo();

            pager = dViewModel.Pager;

            PaginationViewModel pViewModel = new PaginationViewModel();

            try
            {
                pViewModel.dt = _deptManager.GetDepartments(dViewModel.DepartmentInfo.DepartmentName, ref pager);

                pViewModel.Pager = pager;

                Logger.Debug("Department Controller GetDeparment");
            }

            catch (Exception ex)
            {
                dViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01"));

                Logger.Error("Department Controller - GetDeparment" + ex.ToString());
            }

            return(Json(JsonConvert.SerializeObject(pViewModel), JsonRequestBehavior.AllowGet));
        }
コード例 #26
0
        public JsonResult GetFacilities(FacilityViewModel fViewModel)
        {
            PaginationInfo pager = new PaginationInfo();

            pager = fViewModel.Pager;

            PaginationViewModel pViewModel = new PaginationViewModel();

            try
            {
                pViewModel.dt = _sRepo.GetFacilities(fViewModel.Facility.FacilityTypeId, fViewModel.Facility.FacilityName, ref pager);

                pViewModel.Pager = pager;

                Logger.Debug("Facility Controller GetFacilities");
            }

            catch (Exception ex)
            {
                fViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01"));

                Logger.Error("Facility Controller - GetFacilities" + ex.ToString());
            }

            return(Json(JsonConvert.SerializeObject(pViewModel), JsonRequestBehavior.AllowGet));
        }
コード例 #27
0
        public ActionResult Index(int id = 1)
        {
            var page          = id;
            var allItemsCount = this.sellingItems
                                .GetAll()
                                .Count(x => x.SellerId == this.UserProfile.Id);
            var totalPages = (int)Math.Ceiling(allItemsCount / (decimal)ItemsPerPage);

            var items = this.sellingItems
                        .GetByUserId(this.UserProfile.Id)
                        .OrderByDescending(x => x.CreatedOn)
                        .Skip((page - 1) * ItemsPerPage)
                        .Take(ItemsPerPage)
                        .To <SellingItemViewModel>()
                        .ToList();

            var paginationModel = new PaginationViewModel()
            {
                CurrentPage = page,
                TotalPages  = totalPages,
                Path        = "/Users/SellingItems/Index/"
            };

            var model = new ShopIndexViewModel()
            {
                PaginationModel = paginationModel,
                ItemsForSale    = items
            };

            return(this.View(model));
        }
コード例 #28
0
        public IActionResult Index(int id = 1)
        {
            var forums = this.forumsService
                         .GetAll <ForumAdministrationViewModel>(ForumsPerPage, (id - 1) * ForumsPerPage);

            var viewModel = new ForumAdministrationIndexViewModel {
                Forums = forums
            };

            var count = this.forumsService.GetCount();

            var pagination = new PaginationViewModel();

            pagination.PagesCount = (int)Math.Ceiling((double)count / ForumsPerPage);
            if (pagination.PagesCount == 0)
            {
                pagination.PagesCount = 1;
            }

            pagination.CurrentPage = id;

            viewModel.Pagination = pagination;

            return(this.View(viewModel));
        }
コード例 #29
0
        public async Task <IActionResult> All(string searchTerm, int page = 1)
        {
            if (page < 1)
            {
                return(RedirectToAction(nameof(All), new { page = 1, searchTerm }));
            }

            var users = await this.users.AllAsync(searchTerm, page, WebConstants.Pagination.AdminUsersListing);

            var usersPagination = new PaginationViewModel()
            {
                Action        = nameof(All),
                Controller    = WebConstants.Controller.AdminUsers,
                CurrentPage   = page,
                PageSize      = WebConstants.Pagination.AdminUsersListing,
                SearchTerm    = searchTerm,
                TotalElements = this.users.TotalUsers(searchTerm)
            };

            if (page > usersPagination.TotalPages && usersPagination.TotalPages != 0)
            {
                return(RedirectToAction(nameof(All), new { page = usersPagination.TotalPages, searchTerm }));
            }

            return(View(new AllUsers()
            {
                Users = users,
                Pagination = usersPagination
            }));
        }
コード例 #30
0
            public void ItShouldReturnCorrectRecipesForFirstPage()
            {
                var recipes = new List <Recipe>
                {
                    new Recipe {
                        Id = 1, Title = "recipe1"
                    },
                    new Recipe {
                        Id = 2, Title = "recipe2"
                    },
                    new Recipe {
                        Id = 3, Title = "recipe3"
                    }
                };

                _recipeRepositoryMock.Setup(x => x.GetAll()).Returns(recipes.AsQueryable);
                var recipesViewModel = _iMapper.Map <IEnumerable <Recipe>, IEnumerable <RecipeViewModel> >(recipes);
                var pager            = new Pager(recipesViewModel.Count(), 1);
                var viewModel        = new PaginationViewModel
                {
                    Items = recipesViewModel.ToList(),
                    Pager = pager
                };

                var result = _controller.RecipesList(1) as ViewResult;
                var paginationViewModel = (PaginationViewModel)result.ViewData.Model;

                foreach (var item in recipesViewModel)
                {
                    Assert.Contains(paginationViewModel.Items, r => r.Id == item.Id);
                }
                Assert.True(paginationViewModel.Items.Count() == 3);
                Assert.Contains(paginationViewModel.Items, r => r.Title == recipes[0].Title);
            }
コード例 #31
0
        public ActionResult Index(string brand, int page = 1, string query = null, string sortBy = SortByDefault, string sortOrder = SortOrderDefault)
        {
            brand = brand == "All" ? null : brand;
            var pagesCount = this.ProductsService.GetAllByBrand(brand, query).Count();
            var products = this.ProductsService
                 .GetAllByBrand(brand, query)
                 .To<ProductViewModel>();

            var viewModel = new PaginationViewModel()
            {
                CurrentPage = page,
                Products = this.Sort(products, sortBy, sortOrder).Skip((page - 1) * PageSize).Take(PageSize).ToList(),
                Brand = brand == null ? "All" : brand,
                Query = query,
                SortBy = sortBy,
                SortOrder = sortOrder,
                PagesCount = (int)Math.Ceiling(pagesCount / (decimal)PageSize)
            };

            return PartialView(PartialViewProducts, viewModel);
        }
コード例 #32
0
        public static MvcHtmlString PageLinks(this HtmlHelper htmlHelper,
            PaginationViewModel pagination,
            Func<int, string> pageUrl)
        {
            StringBuilder result = new StringBuilder();
            for (int i = 1; i <= pagination.TotalPages; i++)
            {
                TagBuilder tag = new TagBuilder("a");
                tag.MergeAttribute("href", pageUrl(i));
                tag.InnerHtml = i.ToString();
                if (i == pagination.CurrentPage)
                {
                    tag.AddCssClass("selected");
                    tag.AddCssClass("btn-primary");
                }

                tag.AddCssClass("btn btn-default");
                result.Append(tag.ToString());
            }

            return MvcHtmlString.Create(result.ToString());
        }
コード例 #33
0
        public ActionResult Index(string category, string subCategory, string query = null, int page = 1, string sortBy = SortByDefault, string sortOrder = SortOrderDefault)
        {
            query = query == null ? string.Empty : query;
            var pagesCount = this.ProductsService.GetAllByCategory(category, subCategory, query).Count();
            var products = this.ProductsService
                 .GetAllByCategory(category, subCategory, query)
                 .To<ProductViewModel>();

            var viewModel = new PaginationViewModel()
            {
                CurrentPage = page,
                Products = this.Sort(products, sortBy, sortOrder).Skip((page - 1) * PageSize).Take(PageSize).ToList(),
                Category = category,
                SubCategory = subCategory,
                Query = query,
                SortBy = sortBy,
                SortOrder = sortOrder,
                PagesCount = (int)Math.Ceiling(pagesCount / (decimal)PageSize)
            };

            return PartialView(PartialViewProducts, viewModel);
        }