예제 #1
0
 public Application()
 {
     MainAssembly      = Assembly.GetCallingAssembly();
     Container         = new IoC.Container();
     PageModelMapper   = new PageModelMapper(Container);
     NavigationService = new NavigationService(PageModelMapper);
     RegisterServices();
     RegisterPageModelMappings();
     InitialNavigation(Container.Resolve <INavigationService>());
 }
예제 #2
0
        public static string ToPagenationJson <TInstance>(this List <TInstance> collection, int currentPage,
                                                          int pageSize)
        {
            if (currentPage > 0 && pageSize > 0 && collection != null)
            {
                var totalCount = collection.Count;
                int TotalPages = (int)Math.Ceiling(totalCount / (double)pageSize);

                var items = collection.Skip((currentPage - 1) * pageSize).Take(pageSize).ToList();

                var jsonToReturn = JsonConvert.SerializeObject(items);

                var previousPage = currentPage > 1 ? "Yes" : "No";

                var nextPage = currentPage < TotalPages ? "Yes" : "No";

                return(PageModelMapper.Map(totalCount, pageSize, currentPage, TotalPages, previousPage, nextPage));
            }

            return(null);
        }
예제 #3
0
 protected virtual void RegisterPageModelMappings()
 {
     PageModelMapper.ScanAssembly(MainAssembly);
 }