예제 #1
0
        /// <summary>
        /// Map a paged list of models to a viewmodel equivalent
        /// </summary>
        /// <typeparam name="T">Model item type</typeparam>
        /// <typeparam name="TReturn">Viewmodel item type</typeparam>
        /// <param name="baseList"></param>
        /// <param name="itemMapper">Function to map a model item to it's viewmodel</param>
        /// <returns>Paged list containing viewmodels</returns>
        public static IPagedList <TReturn> MapToViewModel <T, TReturn>(this IPagedList <T> baseList, Func <T, TReturn> itemMapper)
        {
            var mappedItems = baseList.Select(itemMapper);
            var newList     = new StaticPagedList <TReturn>(mappedItems, baseList.GetMetaData());

            return(newList);
        }
예제 #2
0
 public static PagedListDto <T> ToPagedListDto <T>(this IPagedList <T> pagedList)
 {
     return(new PagedListDto <T>
     {
         Items = pagedList.AsEnumerable(),
         Metadata = pagedList.GetMetaData()
     });
 }
        public IPagedList <TDestination> Convert(IPagedList <TSource> source,
                                                 IPagedList <TDestination> destination, ResolutionContext context)
        {
            var vm = source.Select(m
                                   => context.Mapper.Map <TSource, TDestination>(m)).ToList();

            return(new StaticPagedList <TDestination>(vm, source.GetMetaData()));
        }
예제 #4
0
        public ActionResult Index(string keyword, int page = 1)
        {
            IPagedList <Car> cars = carService.GetCars(keyword, page, 15);
            var carModels         = mapper.Map <IEnumerable <Car>, IEnumerable <CarModel> >(cars);
            var viewModel         = new StaticPagedList <CarModel>(carModels, cars.GetMetaData());

            return(Request.IsAjaxRequest() ? (ActionResult)PartialView("CarListPartial", viewModel) : View(viewModel));
        }
예제 #5
0
                IPagedList <TDestination> ITypeConverter <IPagedList <TSource>, IPagedList <TDestination> > .Convert(IPagedList <TSource> source, IPagedList <TDestination> destination, ResolutionContext context)
                {
                    var pagedList = source.GetMetaData();

                    var superset = context.Mapper.Map <IEnumerable <TDestination> >(source);

                    return(new PagedList <TDestination>(pagedList, superset));
                }
예제 #6
0
        public ActionResult Index(string keyword, int page = 1)
        {
            ViewBag.keyword = keyword;
            IPagedList <Car> carList = carService.GetCars(keyword, page, 10);
            var viewModel            = mapper.Map <IEnumerable <Car>, IEnumerable <CarViewModel> >(carList);
            var pagedViewModel       = new StaticPagedList <CarViewModel>(viewModel, carList.GetMetaData());

            return(Request.IsAjaxRequest() ? (ActionResult)PartialView("CarListPartial", pagedViewModel) : View(pagedViewModel));
        }
예제 #7
0
        public ActionResult Index(DateTime?startDate = null, DateTime?endDate = null, string severity = null, int page = 1)
        {
            ViewBag.severity = new SelectList(Enum.GetNames(typeof(System.Diagnostics.TraceEventType)));
            IPagedList <Log> logs = logService.GetLogs(startDate, endDate, severity, page, 15);
            var config            = new MapperConfiguration(cfg => cfg.CreateMap <Log, LogModel>().ForMember(m => m.FormattedMessage, p => p.Ignore()));
            var logModels         = config.CreateMapper().Map <IEnumerable <Log>, IEnumerable <LogModel> >(logs);
            var viewModel         = new StaticPagedList <LogModel>(logModels, logs.GetMetaData());

            return(Request.IsAjaxRequest() ? (ActionResult)PartialView("LogListPartial", viewModel) : View(viewModel));
        }
예제 #8
0
        public static TrueFormPagedList <SlotViewModel> ToViewModel(this IPagedList <Slot> models)
        {
            var viewModels = new List <SlotViewModel>();

            models.ToList().ForEach(b =>
            {
                viewModels.Add(ToViewModel(b));
            });

            return(viewModels.ToTrueFormPagedList(models.GetMetaData()));
        }
        public async Task <IActionResult> PageCollateralItems([FromQuery] PageOption pageOption, long loanApplicationId, string session = "")
        {
            IPagedList <CollateralItemResponse> data = await this.collateralItemService.PageByLoanApplication(pageOption, loanApplicationId);

            PagedListMetaData metaData = data.GetMetaData();

            PagedDataResponse pagedData = new PagedDataResponse {
                Data = data, MetaData = metaData
            };

            return(Ok(pagedData));
        }
        public async Task <IActionResult> GetPersonalExpenses([FromQuery] PageOption pageOption, long loanApplicationId, string session = "")
        {
            IPagedList <PersonalExpenseResponse> data = await this.personalExpenseService.PageByLoanApplication(pageOption, loanApplicationId);

            PagedListMetaData metaData = data.GetMetaData();

            PagedDataResponse pagedData = new PagedDataResponse {
                Data = data, MetaData = metaData
            };

            return(Ok(pagedData));
        }
        public async Task <IActionResult> FindCustomerExistingLoans([FromQuery] PageOption pageOption, long loanApplicationId, string session = "")
        {
            IPagedList <ExistingLoanResponse> data = await this.existingLoanService.PageByLoanApplication(pageOption, loanApplicationId);

            PagedListMetaData metaData = data.GetMetaData();

            PagedDataResponse pagedData = new PagedDataResponse {
                Data = data, MetaData = metaData
            };

            return(Ok(pagedData));
        }
        public async Task <IActionResult> PaginateBusinesses([FromQuery] PageOption pageOption, long loanApplicationId, string session = "")
        {
            IPagedList <BusinessResponseDTO> data = await this.businessService.PageByLoanApplication(pageOption, loanApplicationId);

            PagedListMetaData metaData = data.GetMetaData();

            PagedDataResponse pagedData = new PagedDataResponse {
                Data = data, MetaData = metaData
            };

            return(Ok(pagedData));
        }
예제 #13
0
        public ActionResult Index(string keyword, int page = 1)
        {
            IPagedList <Product> products = productService.GetProducts(keyword, page, 15);

            var productModels = mapper.Map <IEnumerable <Product>, IEnumerable <ProductModel> >(products);

            var viewModel = new StaticPagedList <ProductModel>(productModels, products.GetMetaData());

            return(View(viewModel));

            //return Request.IsAjaxRequest() ? (ActionResult)PartialView("ProductListPartial", viewModel) : View(viewModel);
        }
예제 #14
0
        public async Task <IActionResult> Paginate([FromQuery] PageOption pageOption, [FromQuery] string session = "")
        {
            IPagedList <IEntityResponseDTO> data = await this.service.PaginateAsync(pageOption);

            PagedListMetaData metaData = data.GetMetaData();

            PagedDataResponse pagedData = new PagedDataResponse {
                Data = data, MetaData = metaData
            };

            return(Ok(pagedData));
        }
        public async Task <IActionResult> PageBorrowerChildren([FromQuery] PageOption pageOption, long loanApplicationId, string session = "")
        {
            IPagedList <BorrowerChildResponse> data = await this.borrowerChildService.PageByLoanApplication(pageOption, loanApplicationId);

            PagedListMetaData metaData = data.GetMetaData();

            PagedDataResponse pagedData = new PagedDataResponse {
                Data = data, MetaData = metaData
            };

            return(Ok(pagedData));
        }
예제 #16
0
        public ActionResult Index(string keyword, int page = 1)
        {
            IPagedList <Menu> menus = menuService.GetModels(keyword, page, 15);

            var menuModels = mapper.Map <IEnumerable <Menu>, IEnumerable <MenuModel> >(menus);

            var viewModel = new StaticPagedList <MenuModel>(menuModels, menus.GetMetaData());

            return(View(viewModel));

            //return Request.IsAjaxRequest() ? (ActionResult)PartialView("MenuListPartial", viewModel) : View(viewModel);
        }
        public async Task <IActionResult> FindBorrower([FromQuery] PageOption pageOption, long loanBorrowerId, string session = "")
        {
            IPagedList <SavingsDepositResponse> data = await this.savingsDepositService.PageByLoanBorrower(pageOption, loanBorrowerId);

            PagedListMetaData metaData = data.GetMetaData();

            PagedDataResponse pagedData = new PagedDataResponse {
                Data = data, MetaData = metaData
            };

            return(Ok(pagedData));
        }
예제 #18
0
        public async Task <IActionResult> Paginate([FromQuery] PageOption pageOption)
        {
            IPagedList <IEntity> data = await this.eFRepository.PaginateAsync(pageOption);

            PagedListMetaData metaData = data.GetMetaData();

            PagedDataResponse pagedData = new PagedDataResponse {
                Data = data, MetaData = metaData
            };

            return(Ok(pagedData));
        }
예제 #19
0
        public async Task <IActionResult> FindCustomerExistingLoans([FromQuery] PageOption pageOption, long savingsId, string session = "")
        {
            IPagedList <SavingsDailyBalanceResponse> data = await this.savingsDailyBalanceService.PageBySavingsId(pageOption, savingsId);

            PagedListMetaData metaData = data.GetMetaData();

            PagedDataResponse pagedData = new PagedDataResponse {
                Data = data, MetaData = metaData
            };

            return(Ok(pagedData));
        }
예제 #20
0
        public async Task <IActionResult> PaginateCostOfSales([FromQuery] PageOption pageOption, long businessTypeId, [FromQuery] string session = "")
        {
            IPagedList <BusinessTypeCostOfSaleResponseDTO> data = await this.businessCostOfSaleService.PageByBusinessType(pageOption, businessTypeId);

            PagedListMetaData metaData = data.GetMetaData();

            PagedDataResponse pagedData = new PagedDataResponse {
                Data = data, MetaData = metaData
            };

            return(Ok(pagedData));
        }
        public async Task <IActionResult> PaginateUserApplications([FromQuery] PageOption pageOption, string session = "")
        {
            RSUser user = ((RSUser)this.RouteData.Values[nameof(RSUser)]);

            IPagedList <LoanApplicationResponseDTO> data = await this.loanApplicationService.PageUserApplications(pageOption, user.UserName);

            PagedListMetaData metaData = data.GetMetaData();

            PagedDataResponse pagedData = new PagedDataResponse {
                Data = data, MetaData = metaData
            };

            return(Ok(pagedData));
        }
예제 #22
0
        public ActionResult GetAuthors(Pagination pagination, AuthorFilter authorFilter, string orderBy = "Name")
        {
            var orderByEntities = OrderMapper.MapTo <Author>(orderBy);

            IPagedList <Author> authors = _libraryRepository.GetAuthors(pagination, authorFilter, orderByEntities);
            var authorDtos = _mapper.Map <IEnumerable <AuthorDto> >(authors);

            var result = new
            {
                meta  = authors.GetMetaData(),
                value = authorDtos
            };

            return(Ok(result));
        }
예제 #23
0
        public static string SerializePagedList(IPagedList <T> pagedList)
        {
            string result = JsonConvert.SerializeObject(
                new
            {
                Items    = pagedList,
                MetaData = pagedList.GetMetaData()
            },
                new JsonSerializerSettings
            {
                NullValueHandling     = NullValueHandling.Ignore,
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            });

            return(result);
        }
예제 #24
0
        public FilesPagedResult GetFilesPaged(int?categoryId, bool imagesOnly, int page = 1)
        {
            IQueryOver <MediaFile, MediaFile> queryOver = _session.QueryOver <MediaFile>().Where(file => file.Site == _currentSite);

            if (categoryId.HasValue)
            {
                queryOver = queryOver.Where(file => file.MediaCategory.Id == categoryId);
            }

            if (imagesOnly)
            {
                queryOver.Where(file => file.FileExtension.IsIn(MediaFileExtensions.ImageExtensions));
            }

            IPagedList <MediaFile> mediaFiles = queryOver.OrderBy(file => file.CreatedOn).Desc.Paged(page, _siteSettings.DefaultPageSize);

            return(new FilesPagedResult(mediaFiles, mediaFiles.GetMetaData(), categoryId, imagesOnly));
        }
예제 #25
0
        public async Task <IPagedList <SavingsDepositResponse> > PageByLoanApplication(PageOption pageOption, long loanApplicationId)
        {
            IPagedList <SavingsDeposit> entities = await this.repository.PageByLoanApplication(pageOption, loanApplicationId);

            IEnumerable <SavingsDepositResponse> entitiesDTO = mapper.Map <IEnumerable <SavingsDepositResponse> >(entities);

            IPagedList <SavingsDepositResponse> pagedDTO = new StaticPagedList <SavingsDepositResponse>(entitiesDTO, entities.GetMetaData());

            return(pagedDTO);
        }
        public async Task <IPagedList <SavingsDailyBalanceResponse> > PageBySavingsId(PageOption pageOption, long depositAccountId)
        {
            IPagedList <SavingsDailyBalance> entities = await this.repository.PageBySavingsId(pageOption, depositAccountId);

            IEnumerable <SavingsDailyBalanceResponse> entitiesDTO = mapper.Map <IEnumerable <SavingsDailyBalanceResponse> >(entities);

            IPagedList <SavingsDailyBalanceResponse> pagedDTO = new StaticPagedList <SavingsDailyBalanceResponse>(entitiesDTO, entities.GetMetaData());

            return(pagedDTO);
        }
예제 #27
0
        public static IPagedList <TResult> ToMappedPagedList <TSource, TResult>(this IPagedList <TSource> list, ICustomMapper <TSource, TResult> mapper) where TSource : class
        {
            var sourceList = mapper.Map(list);

            return(new StaticPagedList <TResult>(sourceList, list.GetMetaData()));
        }
예제 #28
0
        public IPagedList <TDestination> Convert(IPagedList <TSource> source, IPagedList <TDestination> destination,
                                                 ResolutionContext context)
        {
            var sourceList = context.Mapper.Map <IEnumerable <TSource>, IEnumerable <TDestination> >(source);
            IPagedList <TDestination> pagedResult = new StaticPagedList <TDestination>(sourceList, source.GetMetaData());

            return(pagedResult);
        }
 public static PagedListResult <T> ToListResult <T>(this IPagedList <T> list)
 {
     return(new PagedListResult <T> {
         Items = list, MetaData = list.GetMetaData()
     });
 }
        public async Task <IPagedList <IEntityResponse> > PageByLoanBorrower(PageOption pageOption, long loanBorrowerId)
        {
            IPagedList <IEntity> entities = await repository.PageByLoanBorrower(pageOption, loanBorrowerId);

            IEnumerable <IEntityResponse> entitiesDto = mapper.Map <IEnumerable <IEntityResponse> >(entities);

            IPagedList <IEntityResponse> pagedDto = new StaticPagedList <IEntityResponse>(entitiesDto, entities.GetMetaData());

            return(pagedDto);
        }