Beispiel #1
0
        public async Task <IActionResult> Index(int id, DateTime FromDate, DateTime ToDate, string ApDung = "0", int page = 1)
        {
            var linhkien = await _lkRepo.getById(id);

            if (linhkien == null)
            {
                return(View("~/Views/Error/404.cshtml"));
            }

            ViewBag.IdProduct   = linhkien.Id;
            ViewBag.NameProduct = linhkien.TenLK;

            IEnumerable <DonGia> gias = new List <DonGia>();

            if (FromDate == DateTime.MinValue)
            {
                gias = await _giaRepo.getAll(linhkien.Id);
            }
            else
            {
                gias = await _giaRepo.Filter(linhkien.Id, FromDate, ToDate, ApDung);
            }

            double count     = gias.Count();
            double i         = (double)(count / ItemPerPage);
            var    pageCount = (int)Math.Ceiling(i);

            gias = gias.Skip((page - 1) * ItemPerPage).Take(ItemPerPage).ToList();

            var dto = _mapper.Map <List <DonGiaDTO> >(gias);

            IndexViewModel <DonGiaDTO> returnList = PaginationServices <DonGiaDTO> .PaginationGia(dto, page, ItemPerPage, pageCount, FromDate, ToDate, ApDung);

            return(View("~/Views/Admin/Gia/Index.cshtml", returnList));
        }
        public async Task <IActionResult> Index(string searchString, string role, int page = 1)
        {
            if (searchString == null)
            {
                searchString = "";
            }

            var list = await _userRepo.Filter(searchString, role);

            double count     = list.Count();
            double i         = (double)(count / ItemPerPage);
            var    pageCount = (int)Math.Ceiling(i);

            list = list.Skip((page - 1) * ItemPerPage).Take(ItemPerPage);
            List <UserDTO> dtos = new List <UserDTO>();

            foreach (ApplicationUser user in list)
            {
                var dto = user.MapDTO();
                dtos.Add(dto);
            }
            var roles = await _roleRepo.getAll();

            ViewBag.Roles = roles;
            IndexViewModel <UserDTO> returnList = PaginationServices <UserDTO> .Pagination(dtos, page, ItemPerPage, pageCount, searchString, role);


            return(View("~/Views/Admin/User/Index.cshtml", returnList));
        }
 public SuperpowerController(
     SuperpowerServices superpowerServices,
     PaginationServices <SuperPowersListingViewModel> paginationServices
     )
 {
     _paginationServices = paginationServices;
     _superpowerServices = superpowerServices;
 }
 public TeamController(
     TeamServices teamServices,
     PaginationServices <TeamViewModel> paginationServices
     )
 {
     _teamServices       = teamServices;
     _paginationServices = paginationServices;
 }
Beispiel #5
0
 public CharacterController(
     CharacterServices characterServices,
     TeamServices teamServices,
     SuperpowerServices superPowerServices,
     PaginationServices <CharacterViewModel> paginationServices
     )
 {
     _paginationServices = paginationServices;
     _superPowerServices = superPowerServices;
     _teamServices       = teamServices;
     _characterServices  = characterServices;
 }
        public async Task <IActionResult> Index(string searchString = "", int page = 1)
        {
            var list = await _roleRepository.Filter(searchString);

            double count     = list.Count();
            double i         = (double)(count / ItemPerPage);
            var    pageCount = (int)Math.Ceiling(i);

            list = list.Skip((page - 1) * ItemPerPage).Take(ItemPerPage);
            var dto = _mapper.Map <List <LoaiTKDTO> >(list);

            IndexViewModel <LoaiTKDTO> returnList = PaginationServices <LoaiTKDTO> .Pagination(dto, page, ItemPerPage, pageCount, searchString);

            return(View("~/Views/Admin/Role/Index.cshtml", returnList));
        }
Beispiel #7
0
        /*
         *  searchString: Những kí tự muốn search
         *  searchCategory: id Loại Linh Kiện của các sản phẩm muốn lấy ra
         *  searchManu: id Nhà Cung Cấp của các sản phẩm muốn lấy ra
         *  page: trang hiện tại
         */
        public async Task <IActionResult> Index(string searchString = "", int searchCategory = 0, int searchManu = 0, int page = 1)
        {
            if (searchString == null)
            {
                searchString = "";
            }

            //Get All LinhKien with search
            var linhkiens = await _linhKienRepository.Filter(searchString, searchCategory, searchManu);

            double count        = linhkiens.Count();
            int    pageCount    = (int)Math.Ceiling(count / itemPerPage);
            var    LKPagination = linhkiens.Skip((page - 1) * itemPerPage).Take(itemPerPage);

            var dtos = _mapper.Map <List <LinhKienDTO> >(LKPagination);

            foreach (var dto in dtos)
            {
                var hinh = dto.Hinh.Split(',')[0];
                dto.Hinh = hinh;
            }
            //pagination
            var pagination = PaginationServices <LinhKienDTO> .PaginationLinhKien(dtos, page, itemPerPage, pageCount, searchString, searchCategory, searchManu);

            //Get All Category
            var categorys = await _llkRepository.getAll();

            var categoryDTO = _mapper.Map <List <LoaiLinhKienDTO> >(categorys);

            ViewBag.Category = categoryDTO;

            //Get All Manufactuer
            var manufactuers = await _nccRepository.getAll();

            var manuDTO = _mapper.Map <List <NhaCungCapDTO> >(manufactuers);

            ViewBag.Manu = manuDTO;


            return(View("~/Views/Admin/Product/Index.cshtml", pagination));
        }
Beispiel #8
0
        public async Task <IActionResult> Index(string searchString = "", int page = 1)
        {
            if (searchString == null)
            {
                searchString = "";
            }

            IEnumerable <LoaiLinhKien> list = await _loaiLinhKienRepo.Filter(searchString);

            double count     = list.Count();
            double i         = (double)(count / ItemPerPage);
            var    pageCount = (int)Math.Ceiling(i);


            list = list.Skip((page - 1) * ItemPerPage).Take(ItemPerPage).ToList();
            List <LoaiLinhKienDTO> loaiLinhKiens = _mapper.Map <List <LoaiLinhKienDTO> >(list);


            IndexViewModel <LoaiLinhKienDTO> returnList = PaginationServices <LoaiLinhKienDTO> .Pagination(loaiLinhKiens, page, ItemPerPage, pageCount, searchString);

            return(View("~/Views/Admin/Category/Index.cshtml", returnList));
        }
Beispiel #9
0
        public async Task <IActionResult> Index(string searchString = "", int page = 1)
        {
            if (searchString == null)
            {
                searchString = "";
            }

            IEnumerable <NhaCungCap> list = await _nccRepo.Filter(searchString);

            double count     = list.Count();
            double i         = (double)(count / ItemPerPage);
            var    pageCount = (int)Math.Ceiling(i);


            list = list.Skip((page - 1) * ItemPerPage).Take(ItemPerPage).ToList();
            List <NhaCungCapDTO> nccs = _mapper.Map <List <NhaCungCapDTO> >(list);


            IndexViewModel <NhaCungCapDTO> returnList = PaginationServices <NhaCungCapDTO> .Pagination(nccs, page, ItemPerPage, pageCount, searchString);

            return(View("~/Views/Admin/Manufactuer/Index.cshtml", returnList));
        }
        public async Task <IActionResult> Index(string searchString = "", string tinhTrang = "", string orderBy = "", DateTime fromDate = default, DateTime toDate = default, int page = 1)
        {
            if (searchString == null)
            {
                searchString = "";
            }
            if (orderBy == null)
            {
                orderBy = "";
            }

            var list = await _hoadonRepo.Filter(searchString, orderBy, tinhTrang, fromDate, toDate);

            double count     = list.Count();
            double i         = (double)(count / ItemPerPage);
            var    pageCount = (int)Math.Ceiling(i);

            list = list.Skip((page - 1) * ItemPerPage).Take(ItemPerPage).ToList();
            List <HoaDonDTO> hoadonsDTO = _mapper.Map <List <HoaDonDTO> >(list);

            IndexViewModel <HoaDonDTO> returnList = PaginationServices <HoaDonDTO> .PaginationHoaDon(hoadonsDTO, page, ItemPerPage, pageCount, searchString, tinhTrang, orderBy, fromDate, toDate);

            return(View("~/Views/Admin/DonHang/Index.cshtml", returnList));
        }