Exemple #1
0
        public PagingVM Index(int page)
        {
            var pages = Math.Ceiling(_DB.MaintenanceServices.Count() / 10.0);


            if (page < 1 || page > pages)
            {
                page = 1;
            }

            var skip = (page - 1) * 10;
            var MaintenanceServices = _DB.MaintenanceServices.Include(x => x.MaintenanceReport).Include(x => x.Car)
                                      .Select(x => new MaintenanceServiceVM()
            {
                EntryDate         = x.EntryDate,
                ExitDate          = x.ExitDate,
                MaintenanceReport = new MaintenanceReportVM()
                {
                    FilePath = x.MaintenanceReport.FilePath
                },
            }).Skip(skip).Take(10).ToList();
            var paging = new PagingVM()
            {
                Data          = MaintenanceServices,
                NumberOfPages = (int)pages,
                CureentPage   = page
            };

            return(paging);
        }
Exemple #2
0
        public PagingVM Index(int page)

        {
            var pages = Math.Ceiling(_DB.Users.Count() / 10.0);


            if (page < 1 || page > pages)
            {
                page = 1;
            }

            var skip = (page - 1) * 10;

            var users = _DB.Users.Where(x => !x.IsDelete).Select(x => new UserVM()
            {
                Id          = x.Id,
                FirstName   = x.FirstName,
                LastName    = x.LastName,
                Email       = x.Email,
                PhoneNumber = x.PhoneNumber,
                DOB         = x.DOB
            }).ToList();

            var pagingResult = new PagingVM();

            pagingResult.Data          = users;
            pagingResult.NumberOfPages = (int)pages;
            pagingResult.CureentPage   = page;

            return(pagingResult);
        }
Exemple #3
0
        public PagingVM Index(int page)

        {
            var pages = Math.Ceiling(_DB.Employees.Count() / 10.0);


            if (page < 1 || page > pages)
            {
                page = 1;
            }

            var skip      = (page - 1) * 10;
            var Employees = _DB.Employees.Include(x => x.MaintenanceServices)
                            .Select(x => new EmployeeVM()
            {
                Name                = x.Name,
                Phone               = x.Phone,
                Address             = x.Address,
                Salary              = x.Salary,
                MaintenanceServices = x.MaintenanceServices
                                      .Select(y => new MaintenanceServiceVM()
                {
                    EntryDate = y.EntryDate,
                    ExitDate  = y.ExitDate
                }).ToList()
            }).Skip(skip).Take(10).ToList();
            var paging = new PagingVM()
            {
                Data          = Employees,
                NumberOfPages = (int)pages,
                CureentPage   = page
            };

            return(paging);
        }
Exemple #4
0
        public PagingVM Index(int page)

        {
            var pages = Math.Ceiling(_DB.Cars.Count() / 10.0);


            if (page < 1 || page > pages)
            {
                page = 1;
            }

            var skip = (page - 1) * 10;
            var Cars = _DB.Customers.Include(x => x.Cars)
                       .Select(x => new CustomerVM()
            {
                Name    = x.Name,
                Address = x.Address,
                Phone   = x.Phone,
                Cars    = x.Cars
                          .Select(y => new CarVM()
                {
                    Model = y.Model,
                    Brand = y.Brand,
                    Color = y.Color
                }).ToList()
            }).Skip(skip).Take(10).ToList();
            var paging = new PagingVM()
            {
                Data          = Cars,
                NumberOfPages = (int)pages,
                CureentPage   = page
            };

            return(paging);
        }
        public ActionResult List(string OpenID, string Date, int Type, int pageIndex)
        {
            DateTime?dTime = null;
            DateTime parsedTime;

            if (DateTime.TryParse(Date, out parsedTime))
            {
                dTime = parsedTime.Date;
            }
            ;

            EG.WeChat.Model.PagingM modle;
            if (Type == -1)
            {
                modle = TextBL.List(OpenID, dTime, pageIndex);
            }
            else
            {
                modle = MediaBL.List(OpenID, dTime, Type, pageIndex);
            }

            PagingVM result = new PagingVM();

            result.PageIndex  = modle.PageIndex;
            result.PageSize   = modle.PageSize;
            result.TotalCount = modle.TotalCount;
            result.TotalPages = modle.TotalPages;
            result.JsonData   = DataConvert.DataTableToJson(modle.DataTable);

            return(Json(result));
        }
 private IQueryable <Contact> ApplyPaging(PagingVM paging, IQueryable <Contact> contacts)
 {
     if (paging != null)
     {
         contacts = contacts.Skip(paging.PageIndex * paging.PageSize)
                    .Take(paging.PageSize);
     }
     return(contacts);
 }
Exemple #7
0
 private IQueryable <Company> ApplyPaging(PagingVM paging, IQueryable <Company> companies)
 {
     if (paging != null)
     {
         companies = companies.Skip(paging.PageIndex * paging.PageSize)
                     .Take(paging.PageSize);
     }
     return(companies);
 }
        public async Task <IEnumerable <Contact> > GetContacts(PagingVM paging = null)
        {
            var contacts = context.Contacts
                           .Include(c => c.ContactType)
                           .Include(c => c.Company)
                           .AsQueryable();

            contacts = ApplyPaging(paging, contacts);

            return(await contacts.ToListAsync());
        }
Exemple #9
0
        public IActionResult TransactionHistory(int?accountId, int page = 1)
        {
            int totalItem = 0;
            var pagingVM  = new PagingVM <int, TransactionHistoryDto>()
            {
                Id    = accountId.Value,
                Items = _accountService.ReadHistory(UserId, accountId.Value, page, _appSettings.ItemPerPage, out totalItem),
                Pager = new Pager(totalItem, page, _appSettings.ItemPerPage)
            };

            return(View(pagingVM));
        }
Exemple #10
0
        public ActionResult TypeList(int page = 1)
        {
            PagingVM pageparam = new PagingVM();

            pageparam.page     = page;
            pageparam.pageSize = 10;
            var source = _TypeSerivce.GetAllTypes(pageparam);
            // ViewBag.count = _TypeSerivce.GetAllTypes().Count();
            var resultAsPagedList = new StaticPagedList <TypeMasterVM>(source, page, pageparam.pageSize, 25);

            return(PartialView(resultAsPagedList));
        }
Exemple #11
0
        public async Task <IEnumerable <Company> > GetCompanies(PagingVM paging = null, CompanySearchVM search = null)
        {
            var companies = context.Company
                            .Include(c => c.Affiliates).ThenInclude(a => a.Region)
                            .Include(c => c.BusinessLines).ThenInclude(bl => bl.BusinessLine)
                            .Include(c => c.Affiliates).ThenInclude(a => a.Region)
                            .Include(c => c.Contacts).ThenInclude(c => c.ContactType).AsQueryable();

            companies = ApplyFiltering(search, companies);
            companies = ApplyPaging(paging, companies);

            return(await companies.ToListAsync());
        }
Exemple #12
0
        public ActionResult List(string userID, string userName, int pageIndex)
        {
            var modle = UserBL.List(userID, userName, pageIndex);

            PagingVM result = new PagingVM();

            result.PageIndex  = modle.PageIndex;
            result.PageSize   = modle.PageSize;
            result.TotalCount = modle.TotalCount;
            result.TotalPages = modle.TotalPages;
            result.JsonData   = DataConvert.DataTableToJson(modle.DataTable);

            return(Json(result));
        }
Exemple #13
0
        public PagingVM Index(int page)
        {
            var pages = Math.Ceiling(_DB.Cars.Count() / 10.0);


            if (page < 1 || page > pages)
            {
                page = 1;
            }

            var skip = (page - 1) * 10;
            var Cars = _DB.Cars.Include(x => x.MaintenanceService).ThenInclude(c => c.MaintenanceReport)
                       .Select(x => new CarVM()
            {
                Brand = x.Brand,
                Model = x.Model,
                Color = x.Color,
                MaintenanceServices = x.MaintenanceService
                                      .Select(y => new MaintenanceServiceVM()
                {
                    EntryDate         = y.EntryDate,
                    ExitDate          = y.ExitDate,
                    MaintenanceReport = new MaintenanceReportVM()
                    {
                        FilePath = y.MaintenanceReport.FilePath
                    }
                }).ToList()
            }).Skip(skip).Take(10).ToList();
            var paging = new PagingVM()
            {
                Data          = Cars,
                NumberOfPages = (int)pages,
                CureentPage   = page
            };

            return(paging);
        }
 public List <TypeMasterVM> GetAllTypes(PagingVM pageparam)
 {
     throw new NotImplementedException();
 }
        public IActionResult GetAll([FromQuery] PagingVM pagingVM)
        {
            var tickets = ticketService.GetTickets(pagingVM, out int totalCount);

            return(PagingResponse(tickets, totalCount));
        }
Exemple #16
0
 public IActionResult GetAll([FromQuery] PagingVM paging)
 {
     return(Ok(authorService.GetAllAuthors(paging.Offset, paging.Take)));
 }
        public IActionResult GetHappy([FromQuery] PagingVM pagingVM)
        {
            var tickets = ticketService.GetHappyTickets(pagingVM, out int total);

            return(PagingResponse(tickets, total));
        }
Exemple #18
0
 public IActionResult GetAll([FromQuery] PagingVM paging)
 {
     return(Ok(bookService.GetAllBooks(paging.Offset, paging.Take)));
 }
Exemple #19
0
 public IActionResult GetByAuthor(long authorId, [FromQuery] PagingVM paging)
 {
     return(Ok(bookService.GetByAuthor(authorId, paging.Offset, paging.Take)));
 }