Ejemplo n.º 1
0
        public async Task <PaginatedList <BannedWord> > GetAllPaged(int pageIndex, int pageSize)
        {
            var query = _context.BannedWord.OrderBy(x => x.Word);

            return(await PaginatedList <BannedWord> .CreateAsync(query.AsNoTracking(), pageIndex, pageSize));
        }
 public static Task <PaginatedList <TDestination> > PaginatedListAsync <TDestination>(this IQueryable <TDestination> queryable, int pageNumber, int pageSize)
 => PaginatedList <TDestination> .CreateAsync(queryable, pageNumber, pageSize);
Ejemplo n.º 3
0
        public void CreatePage()
        {
            if (Request.Cookies["pagesize"] != null)
            {
                PageSize = int.Parse(Request.Cookies["pagesize"]);
            }

            IQueryable <Data.Tables.Technical> query;

            if (!ShowDeleted)
            {
                query = _db.Technical.AsNoTracking().AsQueryable();
            }
            else
            {
                query = _db.Technical.AsNoTracking().IgnoreQueryFilters().AsQueryable();
            }

            char separator = ',';

            string[] filterOptions =
            {
                "Prawda",
                "Fałsz",
            };
            kanbanFilter = new SelectList(filterOptions);

            if (Filter_Rodzina != null)
            {
                var options = Filter_Rodzina.Split(separator).Select(c => c.Trim());
                foreach (var option in options)
                {
                    query = query.Where(c => c.Rodzina.Contains(option));
                }
            }
            if (Filter_Wiazka != null)
            {
                var options = Filter_Wiazka.Split(separator).Select(c => c.Trim());
                foreach (var option in options)
                {
                    query = query.Where(c => c.Wiazka.Contains(option));
                }
            }
            if (Filter_KodWiazki != null)
            {
                var options = Filter_KodWiazki.Split(separator).Select(c => c.Trim());
                query = query.Where(c => options.Contains(c.KodWiazki));
            }
            if (Filter_PrzewodCiety != null)
            {
                var options = Filter_PrzewodCiety.Split(separator).Select(c => c.Replace("PLC", "").Trim());
                foreach (var option in options)
                {
                    query = query.Where(c => c.PrzewodCiety.Contains(option));
                }
            }
            if (Filter_BIN != null)
            {
                var options = Filter_BIN.Split(separator).Select(c => c.Trim());
                query = query.Where(c => options.Contains(c.BIN));
            }
            if (Filter_LiteraRodziny != null)
            {
                var options = Filter_LiteraRodziny.Split(separator).Select(c => c.Trim());
                query = query.Where(c => options.Contains(c.LiterRodziny));
            }
            if (Filter_Uwagi != null)
            {
                var options = Filter_Uwagi.Split(separator).Select(c => c.Trim());
                foreach (var option in options)
                {
                    query = query.Where(c => c.Uwagi.Contains(option));
                }
            }
            if (Filter_IlePrzedowow != null)
            {
                var options = Filter_IlePrzedowow.Split(separator).Select(c => c.Trim());
                query = query.Where(c => options.Contains(c.IlePrzewodow));
            }
            if (Filter_Kanban != null)
            {
                if (Filter_Kanban == "Prawda")
                {
                    query = query.Where(c => c.KanBan == true);
                }
                else if (Filter_Kanban == "Fałsz")
                {
                    query = query.Where(c => c.KanBan == false);
                }
            }

            string[] sortings =
            {
                "Rodzina",
                "Wiązka",
                "Litera rodziny",
                "Kod wiązki",
                "Przew. Cięty",
                "BIN"
            };
            availableSortings = new SelectList(sortings);

            if (SortColumn != null)
            {
                switch (SortColumn)
                {
                case "Rodzina":
                    if (OrderDescent)
                    {
                        query = query.OrderByDescending(c => c.Rodzina);
                    }
                    else
                    {
                        query = query.OrderBy(c => c.Rodzina);
                    }
                    break;

                case "Wiązka":
                    if (OrderDescent)
                    {
                        query = query.OrderByDescending(c => c.Wiazka);
                    }
                    else
                    {
                        query = query.OrderBy(c => c.Wiazka);
                    }
                    break;

                case "Litera rodziny":
                    if (OrderDescent)
                    {
                        query = query.OrderByDescending(c => c.LiterRodziny);
                    }
                    else
                    {
                        query = query.OrderBy(c => c.LiterRodziny);
                    }
                    break;

                case "Kod wiązki":
                    if (OrderDescent)
                    {
                        query = query.OrderByDescending(c => c.KodWiazki);
                    }
                    else
                    {
                        query = query.OrderBy(c => c.KodWiazki);
                    }
                    break;

                case "Przew. Cięty":
                    if (OrderDescent)
                    {
                        query = query.OrderByDescending(c => c.PrzewodCiety);
                    }
                    else
                    {
                        query = query.OrderBy(c => c.PrzewodCiety);
                    }
                    break;

                case "BIN":
                    if (OrderDescent)
                    {
                        query = query.OrderByDescending(c => c.BIN);
                    }
                    else
                    {
                        query = query.OrderBy(c => c.BIN);
                    }
                    break;
                }
            }

            Data = PaginatedList <Data.Tables.Technical> .CreateAsync(query, CurrentPage, PageSize).Result;
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> About(int?pageNumber)
        {
            int pageSize = 5;

            return(View(await PaginatedList <QAMessage> .CreateAsync(_context.QAMessages.AsNoTracking(), pageNumber ?? 1, pageSize)));
        }
Ejemplo n.º 5
0
        // GET
        public async Task <IActionResult> Index(int?pageNumber)
        {
            var posts = from p in _db.Posts orderby p.Title where p.IsApproved && p.Type.Equals(PostType.Guide.ToString()) select p;

            return(View(await PaginatedList <Post> .CreateAsync(posts.AsNoTracking(), pageNumber ?? 1, 3)));
        }
        // GET: DirectoryClients
        public async Task <IActionResult> Index(
            string sortOrder,
            string currentFilter,
            string searchString,
            int?pageNumber)
        {
            ViewData["CurrentSort"] = sortOrder;
            ViewData["FirstName"]   = String.IsNullOrEmpty(sortOrder) ? "fname_desc" : "";
            ViewData["SecondName"]  = sortOrder == "Sname" ? "sname_desc" : "Sname";
            ViewData["Patronymic"]  = sortOrder == "Patronymic" ? "patronymic_desc" : "Patronymic";
            ViewData["ClientDate"]  = sortOrder == "Date" ? "date_desc" : "Date";
            if (searchString != null)
            {
                pageNumber = 1;
            }
            else
            {
                searchString = currentFilter;
            }
            ViewData["CurrentFilter"] = searchString;
            var clients = from s in _context.Clients
                          select s;

            if (!String.IsNullOrEmpty(searchString))
            {
                clients = clients.Where(s => s.FirstName.Contains(searchString) ||
                                        s.SecondName.Contains(searchString));
            }
            switch (sortOrder)
            {
            case "fname_desc":
                clients = clients.OrderByDescending(s => s.FirstName);
                break;

            case "sname_desc":
                clients = clients.OrderByDescending(s => s.SecondName);
                break;

            case "patronymic_desc":
                clients = clients.OrderByDescending(s => s.Patronymic);
                break;

            case "Sname":
                clients = clients.OrderBy(s => s.SecondName);
                break;

            case "Patronymic":
                clients = clients.OrderBy(s => s.Patronymic);
                break;

            case "Date":
                clients = clients.OrderBy(s => s.ClientDate);
                break;

            case "date_desc":
                clients = clients.OrderByDescending(s => s.ClientDate);
                break;

            default:
                clients = clients.OrderBy(s => s.FirstName);
                break;
            }
            int pageSize = 3;

            return(View(await PaginatedList <DirectoryClients> .CreateAsync(clients.AsNoTracking(), pageNumber ?? 1, pageSize)));
            //return View(await clients.AsNoTracking().ToListAsync());
            //return View(await _context.Clients.ToListAsync());
        }
Ejemplo n.º 7
0
        // GET: Students
        public async Task <IActionResult> Index(
            string sortOrder,
            string currentFilter,
            string searchString,
            int?page)
        {
            ViewData["CurrentSort"] = sortOrder;
            // If sort name is null then set at lastname_desc else empty the string
            ViewData["NameSortParm"] =
                String.IsNullOrEmpty(sortOrder) ? "LastName_desc" : "";
            // If sortorder is equal to enrollment
            ViewData["DateSortParm"] =
                sortOrder == "EnrollmentDate" ? "EnrollmentDate_desc" : "EnrollmentDate";

            // no search string is given -- return page 1 as default
            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewData["CurrentFilter"] = searchString;

            // Set up queryable variable to use in searches
            var students = from s in _context.Students select s;

            if (!String.IsNullOrEmpty(searchString))
            {
                // if last name or first/middle name contains search string then return the query list
                students = students.Where(s => s.LastName.Contains(searchString) || s.FirstMidName.Contains(searchString));
            }

            // Sorted by last name if no sort order given
            if (string.IsNullOrEmpty(sortOrder))
            {
                sortOrder = "LastName";
            }


            bool descending = false;

            if (sortOrder.EndsWith("_desc"))
            {
                sortOrder  = sortOrder.Substring(0, sortOrder.Length - 5);
                descending = true;
            }

            if (descending)
            {
                students = students.OrderByDescending(e => EF.Property <object>(e, sortOrder));
            }
            else
            {
                students = students.OrderBy(e => EF.Property <object>(e, sortOrder));
            }

            // Split the student list into 3 equivalent sizes if possible
            int pageSize = 3;

            return(View(await PaginatedList <Student> .CreateAsync(students.AsNoTracking(),
                                                                   page ?? 1, pageSize)));
        }
Ejemplo n.º 8
0
        // GET: Stores
        public async Task <IActionResult> Index(string sortOrder, string currentFilter, string searchString, int?page)
        {
            // get current user
            ApplicationUser user = await GetCurrentUserAsync();

            // Get the roles for the user
            var roles = await _userManager.GetRolesAsync(user);

            // create a list of stores
            // by default, only retrieve matching stores where current user is the Sales Rep attached to the store
            var stores = _context.Store.Include("SalesRep").Include("State").Include("Status").Where(s => s.SalesRep == user);

            // check if the user is an Administrator
            if (roles.Contains("Administrator"))
            {
                // retrieve all stores to display (for site administrator)
                stores = _context.Store.Include("SalesRep").Include("State").Include("Status");
            }

            if (!String.IsNullOrEmpty(searchString))
            {
                stores = stores.Where(s => s.Name.ToLower().Contains(searchString.ToLower()) || s.Status.Name.ToLower().Contains(searchString.ToLower()));
            }

            ViewData["CurrentSort"]       = sortOrder;
            ViewData["OrderDateSortParm"] = String.IsNullOrEmpty(sortOrder) ? "Date" : "";
            ViewData["NameSortParm"]      = sortOrder == "name" ? "name_desc" : "Name";
            ViewData["StatusSortParm"]    = sortOrder == "Status" ? "status_desc" : "Status";

            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewData["CurrentFilter"] = searchString;

            switch (sortOrder)
            {
            case "Name":
                stores = stores.OrderBy(s => s.Name);
                break;

            case "name_desc":
                stores = stores.OrderByDescending(s => s.Name);
                break;

            case "Date":
                stores = stores.OrderBy(s => s.LastOrderDate);
                break;

            case "date_desc":
                stores = stores.OrderByDescending(s => s.LastOrderDate);
                break;

            case "Status":
                stores = stores.OrderBy(s => s.StatusId);
                break;

            case "status_desc":
                stores = stores.OrderByDescending(s => s.StatusId);
                break;

            default:
                stores = stores.OrderByDescending(s => s.LastOrderDate);
                break;
            }

            // set amount of stores to display per page
            int pageSize = 25;

            return(View(await PaginatedList <Store> .CreateAsync(stores, page ?? 1, pageSize)));
        }
Ejemplo n.º 9
0
        public async Task <ViewResult> Index(
            string sortOrder,
            string searchString,
            string currentFilter,
            int?pageNumber)
        {
            ViewBag.CurrentSort    = sortOrder;
            ViewBag.NameSortParm   = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            ViewBag.StatusSortParm = sortOrder == "Status" ? "status_desc" : "Status";
            ViewBag.DateSortParm   = sortOrder == "Date" ? "date_desc" : "Date";

            if (searchString != null)
            {
                pageNumber = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewBag.CurrentFilter = searchString;

            var tickets = from t in _context.Ticket select t;

            if (!String.IsNullOrEmpty(searchString))
            {
                tickets = tickets.Where(t => t.TicketName.Contains(searchString) ||
                                        t.TicketProjectName.Contains(searchString) ||
                                        t.TicketDescription.Contains(searchString));
            }

            switch (sortOrder)
            {
            case "name_desc":
                tickets = tickets.OrderByDescending(t => t.TicketProjectName);
                break;

            case "Status":
                tickets = tickets.OrderBy(t => t.TicketStatus);
                break;

            case "status_desc":
                tickets = tickets.OrderByDescending(t => t.TicketStatus);
                break;

            case "Date":
                tickets = tickets.OrderBy(t => t.StartDate);
                break;

            case "date_desc":
                tickets = tickets.OrderByDescending(t => t.StartDate);
                break;

            default:
                tickets = tickets.OrderBy(t => t.TicketProjectName);
                break;
            }

            int pageSize = 5;

            return(View(await PaginatedList <TicketModel> .CreateAsync(tickets.AsNoTracking(), pageNumber ?? 1, pageSize)));
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> Index(string sortOrder, string searchString, string currentFilter, int?page)
        {
            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }
            ViewData["CurrentFilter"] = searchString;

            //Sorting
            ViewData["CurrentSort"]      = sortOrder;
            ViewData["NameSortParm"]     = sortOrder == "Name" ? "Name_desc" : "Name";
            ViewData["StatusSortParm"]   = sortOrder == "Status" ? "Status_desc" : "Status";
            ViewData["PreparerSortParm"] = sortOrder == "Preparer" ? "Preparer_desc" : "Preparer";
            var persons = from p in _contextDB.Person
                          select p;

            if (!String.IsNullOrEmpty(searchString))
            {
                persons = persons.Where(p => p.Name.Contains(searchString));
            }

            switch (sortOrder)
            {
            case "Name":
                persons = persons.OrderBy(p => p.Name);
                break;

            case "Name_desc":
                persons = persons.OrderByDescending(p => p.Name);
                break;

            case "Status":
                persons = persons.OrderBy(p => p.Status);
                break;

            case "Status_desc":
                persons = persons.OrderByDescending(p => p.Status);
                break;

            case "Preparer":
                persons = persons.OrderBy(p => p.Preparer);
                break;

            case "Preparer_desc":
                persons = persons.OrderByDescending(p => p.Preparer);
                break;

            default:
                persons = persons.OrderBy(p => p.Number);
                break;
            }

            //Number of items on on page
            int pageSize   = 15;
            int pageNumber = (page ?? 1);

            return(View(await PaginatedList <Person> .CreateAsync(persons.AsNoTracking(), page ?? 1, pageSize)));
        }
Ejemplo n.º 11
0
        // GET: Kendaraan
        public async Task <IActionResult> Index(string ktsd, string searchString, string searchFil, string sortOrder, string currentFilter, int?pageNumber)

        //buat list menyimpan ktersediaan
        {
            var ktsdList  = new List <String>();
            var ktsdQuery = from d in _context.Kendaraan orderby d.Ketersediaan select d.Ketersediaan;

            ktsdList.AddRange(ktsdQuery.Distinct());

            //menampilkan kedalam dropdown ListView di view
            ViewBag.ktsd = new SelectList(ktsdList);


            var menu = from m in _context.Kendaraan.Include(k => k.IdJenisKendaraanNavigation) select m;

            if (!string.IsNullOrEmpty(ktsd))
            {
                menu = menu.Where(x => x.Ketersediaan == ktsd);
            }

            if (!string.IsNullOrEmpty(searchString))
            {
                menu = menu.Where(s => s.NoPolisi.Contains(searchString));
            }

            //var rental_kendaraanContext = _context.Kendaraan.Include(k => k.IdJenisKendaraanNavigation);
            //return View(await rental_kendaraanContext.ToListAsync());

            ViewData["NameSortParm"] = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            ViewData["DateSortParm"] = sortOrder == "Date" ? "date_desc" : "Date";

            switch (sortOrder)
            {
            case "name_desc":
                menu = menu.OrderByDescending(s => s.NamaKendaraan);
                break;

            case "Date":
                menu = menu.OrderBy(s => s.NoPolisi);
                break;

            default:     //name ascending
                menu = menu.OrderBy(s => s.NamaKendaraan);
                break;
            }
            ViewData["CurrentSort"] = sortOrder;

            if (searchString != null)
            {
                pageNumber = 1;
            }
            else
            {
                searchString = currentFilter;
            }
            ViewData["CurrentFilter"] = searchString;

            // return View(await menu.ToListAsync());
            int pageSize = 5;

            return(View(await PaginatedList <Kendaraan> .CreateAsync(menu.AsNoTracking(), pageNumber ?? 1, pageSize)));
        }
Ejemplo n.º 12
0
        // GET: ProductKey
        public async Task <IActionResult> Index(string sortBy, string search, string currentFilter, int?pageNumber, int?pageRow)
        {
            int pageSize = pageRow ?? 10;

            ViewData["totalRow"]    = pageRow;
            ViewData["CurrentSort"] = sortBy;
            ViewData["KeyName"]     = string.IsNullOrEmpty(sortBy) ? "KeyNameDESC" : "";
            ViewData["KeyCode"]     = sortBy == "KeyCode" ? "KeyCodeDESC" : "KeyCode";
            ViewData["KeyStatus"]   = sortBy == "KeyStatus" ? "KeyStatusDESC" : "KeyStatus";
            ViewData["Onwer"]       = sortBy == "Onwer" ? "OnwerDESC" : "Onwer";

            if (search != null)
            {
                pageNumber = 1;
            }
            else
            {
                search = currentFilter;
            }
            ViewData["CurrentFilter"] = search;

            var productKeys = _context.ProductKey.Include(p => p.ProductName).AsQueryable();

            // Search product by the input
            if (!string.IsNullOrEmpty(search))
            {
                productKeys = productKeys.Where(p => p.ProductName.Name.ToLower().Contains(search.ToLower()));
            }

            // Sort the product by name
            switch (sortBy)
            {
            case "KeyNameDESC":
                productKeys = productKeys.OrderByDescending(p => p.ProductName.Name);
                break;

            case "KeyCodeDESC":
                productKeys = productKeys.OrderByDescending(p => p.Key);
                break;

            case "KeyCode":
                productKeys = productKeys.OrderBy(p => p.Key);
                break;

            case "KeyStatusDESC":
                productKeys = productKeys.OrderByDescending(p => p.Status);
                break;

            case "KeyStatus":
                productKeys = productKeys.OrderBy(p => p.Status);
                break;

            case "OnwerDESC":
                productKeys = productKeys.OrderByDescending(p => p.OwnerId);
                break;

            case "Onwer":
                productKeys = productKeys.OrderBy(p => p.OwnerId);
                break;

            default:
                productKeys = productKeys.OrderBy(p => p.ProductName.Name);
                break;
            }

            if (pageRow == -1)
            {
                pageSize             = productKeys.Count();
                ViewData["totalRow"] = pageSize;
            }

            var model = await PaginatedList <ProductKey> .CreateAsync(productKeys.AsNoTracking(), pageNumber ?? 1, pageSize);

            return(View(model));
        }
Ejemplo n.º 13
0
        public async Task <IActionResult> Index(string sortBy, string search, string currentFilter, int?pageNumber, int?pageRow)
        {
            int pageSize = pageRow ?? 10;

            ViewData["totalRow"]    = pageRow;
            ViewData["CurrentSort"] = sortBy;
            ViewData["Product"]     = string.IsNullOrEmpty(sortBy) ? "NameDESC" : "";
            ViewData["TotalKeys"]   = sortBy == "TotalKey" ? "TotalKeyDESC" : "TotalKey";
            ViewData["Limit"]       = sortBy == "QuantityLimit" ? "QuantityLimitDESC" : "QuantityLimit";
            ViewData["Status"]      = sortBy == "ActiveStatus" ? "ActiveStatusDESC" : "ActiveStatus";
            ViewData["Link"]        = sortBy == "DownloadLink" ? "DownloadLinkDESC" : "DownloadLink";

            if (search != null)
            {
                pageNumber = 1;
            }
            else
            {
                search = currentFilter;
            }
            ViewData["CurrentFilter"] = search;

            var products    = _context.Product.AsQueryable();
            var productkeys = _context.ProductKey.AsQueryable();

            //// Count the key number for each product and store the number into database
            //foreach (Product product in products) {
            //    int keyCount = productkeys.Where(k => k.NameId == product.Id).Count();
            //    int usedKeyCount = productkeys.Where(k => k.NameId == product.Id && k.Status == "Used").Count();
            //    // Save the calculated key count number into database
            //    product.KeyCount = keyCount;
            //    _context.Entry(product).Property("KeyCount").IsModified = true;

            //    product.UsedKeyCount = usedKeyCount;
            //    _context.Entry(product).Property("UsedKeyCount").IsModified = true;

            //}
            //_context.SaveChanges();

            // Search product by the input
            if (!string.IsNullOrEmpty(search))
            {
                products = products.Where(p => p.Name.ToLower().Contains(search.ToLower()));
            }

            // Sort the product by name
            switch (sortBy)
            {
            case "NameDESC":
                products = products.OrderByDescending(p => p.Name);
                break;

            case "TotalKeyDESC":
                products = products.OrderByDescending(p => p.KeyCount);
                break;

            case "TotalKey":
                products = products.OrderBy(p => p.KeyCount);
                break;

            case "QuantityLimitDESC":
                products = products.OrderByDescending(p => p.QuantityLimit);
                break;

            case "QuantityLimit":
                products = products.OrderBy(p => p.QuantityLimit);
                break;

            case "ActiveStatusDESC":
                products = products.OrderByDescending(p => p.ActiveStatus);
                break;

            case "ActiveStatus":
                products = products.OrderBy(p => p.ActiveStatus);
                break;

            case "DownloadLinkDESC":
                products = products.OrderByDescending(p => p.DownloadLink);
                break;

            case "DownloadLink":
                products = products.OrderBy(p => p.DownloadLink);
                break;

            default:
                products = products.OrderBy(p => p.Name);
                break;
            }

            if (pageRow == -1)
            {
                pageSize             = products.Count();
                ViewData["totalRow"] = pageSize;
            }

            var model = await PaginatedList <Product> .CreateAsync(products.AsNoTracking(), pageNumber ?? 1, pageSize);

            return(View(model));
        }
Ejemplo n.º 14
0
 public async Task <PaginatedList <Log> > GetPaginatedListAsync(IQueryable <Log> result, int page, int perPage)
 {
     return(await PaginatedList <Log> .CreateAsync(result, page, perPage));
 }
Ejemplo n.º 15
0
        // GET: Events
        public async Task <IActionResult> Index(string sortOrder, string searchString, string currentFilter, int?pageNumber)
        {
            // Sort Parameters
            ViewData["CurrentSort"] = sortOrder;
            ViewData["NameSort"]    = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            ViewData["DateSort"]    = sortOrder == "Date" ? "date_desc" : "Date";
            ViewData["TypeSort"]    = sortOrder == "Type" ? "type_desc" : "Type";
            // Search box filter
            ViewData["CurrentFilter"] = searchString;

            // Page number is 1 unless there's a search string
            if (searchString != null)
            {
                pageNumber = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            // Include related entities
            var events = from e in _context.Events
                         .Include(a => a.EventType)
                         .Include(a => a.Manager)
                         select e;

            // Search function
            if (!string.IsNullOrEmpty(searchString))
            {
                events = events.Where(s => s.Name.Contains(searchString));
            }

            // Switch case for sorting results
            switch (sortOrder)
            {
            case "name_desc":
                events = events.OrderByDescending(s => s.Name);
                break;

            case "Date":
                events = events.OrderBy(s => s.StartTime);
                break;

            case "date_desc":
                events = events.OrderByDescending(s => s.StartTime);
                break;

            case "Type":
                events = events.OrderBy(s => s.EventType.Type);
                break;

            case "type_desc":
                events = events.OrderByDescending(s => s.EventType.Type);
                break;

            default:
                events = events.OrderBy(s => s.EventID);
                break;
            }
            // Number of records per page before paginating
            int pageSize = 10;

            // Return view with parameters
            return(View(await PaginatedList <Event> .CreateAsync(events.AsNoTracking(), pageNumber ?? 1, pageSize)));
        }
Ejemplo n.º 16
0
        public async Task <IActionResult> List(
            string sortOrder,
            string currentFilter,
            string searchString,
            int?page,
            int?status)
        {
            ViewData["CurrentSort"]  = sortOrder;
            ViewData["NameSortParm"] = sortOrder == "name" ? "name_desc" : "name";
            ViewData["DateSortParm"] = String.IsNullOrEmpty(sortOrder) ? "" : "date";
            ViewData["Status"]       = status;

            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewData["CurrentFilter"] = searchString;

            var countItem = (from s in _context.DaftarKajianVideo
                             where s.Status == published
                             select s).Count();
            var countTrash = (from s in _context.DaftarKajianVideo
                              where s.Status == trash
                              select s).Count();

            var kajianVideo = from s in _context.DaftarKajianVideo
                              .Include(ee => ee.Path)
                              .Include(ee => ee.Kategori)
                              select s;

            if (!String.IsNullOrEmpty(searchString))
            {
                kajianVideo = kajianVideo.Where(s => s.Judul.Contains(searchString));
            }

            if (status == null)
            {
                kajianVideo = kajianVideo.Where(s => s.Status == published);
            }
            else if (status == trash)
            {
                kajianVideo = kajianVideo.Where(s => s.Status == trash);
            }

            switch (sortOrder)
            {
            case "name_desc":
                kajianVideo = kajianVideo.OrderByDescending(s => s.Judul);
                break;

            case "name":
                kajianVideo = kajianVideo.OrderBy(s => s.Judul);
                break;

            case "date":
                kajianVideo = kajianVideo.OrderBy(s => s.Tanggal);
                break;

            default:
                kajianVideo = kajianVideo.OrderByDescending(s => s.Tanggal);
                break;
            }

            int pageSize = 20;

            return(View(await PaginatedList <KajianVideo> .CreateAsync(kajianVideo.AsNoTracking(), page ?? 1, pageSize, countItem, countTrash)));
        }
Ejemplo n.º 17
0
        public async Task <IActionResult> Index(
            string sortOrder,
            string currentFilter,
            string filter,
            int pageNumber = 1,
            int pageSize   = 50)
        {
            #region 分页|筛选|排序

            /*
             * 名为 currentFilter 的 ViewData 元素为视图提供当前筛选器字符串。
             * 此值必须包含在分页链接中,以便在分页过程中保持筛选器设置,并且在页面重新显示时必须将其还原到文本框中。
             *
             * 如果在分页过程中搜索字符串发生变化,则页面必须重置为 1,因为新的筛选器会导致显示不同的数据。
             * 在文本框中输入值并按下“提交”按钮时,搜索字符串将被更改。 在这种情况下,filter参数不为 NULL。
             */

            if (!string.IsNullOrWhiteSpace(filter))
            {
                pageNumber = 1;
            }
            else
            {
                filter = currentFilter;
            }

            ViewData["CurrentFilter"] = filter;
            ViewData["CurrentSort"]   = sortOrder;
            ViewData["NameSortParm"]  = string.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            ViewData["DateSortParm"]  = sortOrder == "Date" ? "date_desc" : "Date";

            var datas = from m in _context.PveData
                        select m;

            if (!string.IsNullOrEmpty(filter))
            {
                datas = datas.Where(s => s.VIN.Contains(filter));
            }

            switch (sortOrder)
            {
            case "name_desc":
                datas = datas.OrderByDescending(s => s.SerialNum);
                break;

            case "Date":
                datas = datas.OrderBy(s => s.ReleaseDate);
                break;

            case "date_desc":
                datas = datas.OrderByDescending(s => s.ReleaseDate);
                break;

            default:
                datas = datas.OrderBy(s => s.SerialNum);
                break;
            }

            #endregion

            return(View(await PaginatedList <PveData> .CreateAsync(datas, pageNumber, pageSize)));
        }
        public async Task <IActionResult> Keskin(DateTime Emre)
        {
            var student = _context.Students.Where(s => s.EnrollmentDate.Month == Emre.Month).AsNoTracking();

            return(View("Index", await PaginatedList <Student> .CreateAsync(student, 1, 5)));
        }
Ejemplo n.º 19
0
        public async Task <IActionResult> Index(string sortString, string searchString, string currentFilter, int?page)
        {
            ViewData["SortByName"]    = string.IsNullOrEmpty(sortString) ? "descendName" : "";
            ViewData["SortBySchool"]  = sortString == "school" ? "descendSchool" : "school";
            ViewData["currentFilter"] = searchString;

            ViewData["CurrentSort"] = sortString;

            ViewData["CountAll"]      = _guestsGuestRepository.GetAllGuests().Count();
            ViewData["CountVisitors"] = _guestsGuestRepository
                                        .GetAllGuests()
                                        .Count(guest => guest.Member == "visitor");
            ViewData["CountWorkers"] = _guestsGuestRepository
                                       .GetAllGuests()
                                       .Count(guest => guest.Member == "worker");

            ViewData["CountMembers"] = _guestsGuestRepository
                                       .GetAllGuests()
                                       .Count(guest => guest.Member == "member");

            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            IQueryable <Guest> guests = _guestsGuestRepository.GetAllGuests();

            if (!string.IsNullOrEmpty(searchString))
            {
                guests = _guestsGuestRepository.GeneralSearch(searchString);
            }

            switch (sortString)
            {
            case "descendName":
                guests = guests.OrderBy(guest => guest.FirstName);
                break;

            case "school":
                guests = guests.OrderByDescending(guest => guest.School);
                break;

            default:
                guests = guests.OrderBy(guest => guest.LastName);
                break;
            }

            #region Guest ViewModel
            //var guestVM = guests
            //    .Select(guest => new Guest()
            //    {
            //        Id = guest.Id,
            //        FirstName = guest.FirstName,
            //        LastName = guest.LastName,
            //        AgeGroup = guest.AgeGroup,
            //        Gender = guest.Gender,
            //        MaritalStatus = guest.MaritalStatus,
            //        Phone = guest.Phone,
            //        Email = guest.Email,
            //        School = guest.School,
            //        YearOfStudy = guest.YearOfStudy,
            //        Member = guest.Member,
            //        PrayerRequest = guest.PrayerRequest,



            //    });
            #endregion

            const int pageSize = 10;
            return(View(await PaginatedList <Guest> .CreateAsync(guests.AsNoTracking(), page ?? 1, pageSize)));
        }
Ejemplo n.º 20
0
        public async Task OnGetAsync(
            string currentType,
            string searchType,
            string sortOrder,
            string currentFilter,
            string searchString,
            int?PageIndex)
        {
            CurrentSort = sortOrder;
            DateSort    = String.IsNullOrEmpty(sortOrder) ? "Date" : "";

            IncoinSort = sortOrder == "Incoin" ? "incoin_desc" : "Incoin";
            ViewSort   = sortOrder == "View" ? "view_desc" : "View";

            if (searchType != null || searchString != null)
            {
                PageIndex = 1;
            }
            else
            {
                searchString = currentFilter;
                searchType   = currentType;
            }
            CurrentFilter = searchString;
            CurrentType   = searchType;

            IQueryable <Novel> NovelsIQ = from n in Context.Novels.Include("Profile")
                                          select n;

            if (!String.IsNullOrEmpty(searchString))
            {
                NovelsIQ = NovelsIQ.Where(n => n.Profile.UserName.Contains(searchString) ||
                                          n.Title.Contains(searchString));
            }

            if (!String.IsNullOrEmpty(searchType))
            {
                switch (searchType)
                {
                case "Fantasy":
                    NovelsIQ = NovelsIQ.Where(n => n.Type == Models.NovelModel.Type.Fantasy);
                    break;

                case "History":
                    NovelsIQ = NovelsIQ.Where(n => n.Type == Models.NovelModel.Type.History);
                    break;

                case "Love":
                    NovelsIQ = NovelsIQ.Where(n => n.Type == Models.NovelModel.Type.Love);
                    break;

                case "Real":
                    NovelsIQ = NovelsIQ.Where(n => n.Type == Models.NovelModel.Type.Real);
                    break;

                case "Modern":
                    NovelsIQ = NovelsIQ.Where(n => n.Type == Models.NovelModel.Type.Modern);
                    break;

                case "Science":
                    NovelsIQ = NovelsIQ.Where(n => n.Type == Models.NovelModel.Type.Science);
                    break;

                case "Horror":
                    NovelsIQ = NovelsIQ.Where(n => n.Type == Models.NovelModel.Type.Horror);
                    break;

                case "Detective":
                    NovelsIQ = NovelsIQ.Where(n => n.Type == Models.NovelModel.Type.Detective);
                    break;

                default:
                    break;
                }
            }

            switch (sortOrder)
            {
            case "Date":
                NovelsIQ = NovelsIQ.OrderBy(s => s.UpdateTime);
                break;

            case "incoin_desc":
                NovelsIQ = NovelsIQ.OrderByDescending(s => s.MonthlyCoins);
                break;

            case "Incoin":
                NovelsIQ = NovelsIQ.OrderBy(s => s.MonthlyCoins);
                break;

            case "view_desc":
                NovelsIQ = NovelsIQ.OrderByDescending(s => s.Views);
                break;

            case "View":
                NovelsIQ = NovelsIQ.OrderBy(s => s.Views);
                break;

            default:
                NovelsIQ = NovelsIQ.OrderByDescending(s => s.UpdateTime);
                break;
            }

            var isAuthorized = User.IsInRole(Authorization.Novel.Novels.NovelManagersRole) ||
                               User.IsInRole(Authorization.Novel.Novels.NovelAdministratorsRole);

            var currentUserId = UserManager.GetUserId(User);

            // Only approved contacts are shown UNLESS you're authorized to see them
            // or you are the owner.
            if (!isAuthorized)
            {
                NovelsIQ = NovelsIQ.Where(a => a.Block == false ||
                                          a.ProfileID == currentUserId);
            }

            int PageSize = 5;

            Novels = await PaginatedList <Novel> .CreateAsync(
                NovelsIQ.AsNoTracking(), PageIndex ?? 1, PageSize);
        }
Ejemplo n.º 21
0
        public async Task <PaginatedList <MembershipUser> > GetAll(int pageIndex, int pageSize)
        {
            var query = _context.MembershipUser.OrderBy(x => x.UserName);

            return(await PaginatedList <MembershipUser> .CreateAsync(query.AsNoTracking(), pageIndex, pageSize));
        }
Ejemplo n.º 22
0
        // GET: Studs

        /* public async Task<IActionResult> Index()
         * {
         *   var fakultetContext = _context.Stud.Include(s => s.PbrRodNavigation).Include(s => s.PbrStanNavigation);
         *   return View(await fakultetContext.ToListAsync());
         * } */

        public async Task <IActionResult> Index(string sortOrder, string searchString, string currentFilter, int?pageNumber)
        {
            //var fakultetContext = _context.Stud.Include(s => s.PbrRodNavigation).Include(s => s.PbrStanNavigation);
            //return View(await fakultetContext.ToListAsync());
            ViewData["NameSortParm"]     = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            ViewData["LastNameSortParm"] = sortOrder == "lastname_asc" ? "lastname_desc" : "lastname_asc";
            ViewData["DateSortParm"]     = sortOrder == "Date" ? "date_desc" : "Date";
            //ViewData["CurrentFilter"] = searchString;
            ViewData["CurrentSort"] = sortOrder;
            if (searchString != null)
            {
                pageNumber = 1;
            }
            else
            {
                searchString = currentFilter;
            }
            ViewData["CurrentFilter"] = searchString;
            var students = from s in _context.Stud
                           select s;

            ViewData["Total"] = students.Count();
            if (!String.IsNullOrEmpty(searchString))
            {
                students = students.Where(s => s.PrezStud.Contains(searchString) ||
                                          s.ImeStud.Contains(searchString));
            }
            ViewData["Count"] = students.Count();
            switch (sortOrder)
            {
            case "name_desc":
                students = students.OrderByDescending(s => s.ImeStud).Include(s => s.PbrRodNavigation).Include(s => s.PbrStanNavigation);
                break;

            case "lastname_asc":
                students = students.OrderBy(s => s.PrezStud).Include(s => s.PbrRodNavigation).Include(s => s.PbrStanNavigation);
                break;

            case "Date":
                students = students.OrderBy(s => s.DatRodStud).Include(s => s.PbrRodNavigation).Include(s => s.PbrStanNavigation);
                break;

            case "date_desc":
                students = students.OrderByDescending(s => s.DatRodStud).Include(s => s.PbrRodNavigation).Include(s => s.PbrStanNavigation);
                break;

            case "lastname_desc":
                students = students.OrderByDescending(s => s.PrezStud).Include(s => s.PbrRodNavigation).Include(s => s.PbrStanNavigation);
                break;

            default:
                students = students.OrderBy(s => s.ImeStud).Include(s => s.PbrRodNavigation).Include(s => s.PbrStanNavigation);
                break;
            }
            //return View(await students.AsNoTracking().ToListAsync());
            int pageSize = 20;

            ViewData["CurrentPageNo"] = pageNumber;
            ViewData["TotalPages"]    = Math.Ceiling(students.Count() / (double)20);
            return(View(await PaginatedList <Stud> .CreateAsync(students.AsNoTracking(), pageNumber ?? 1, pageSize)));
        }
Ejemplo n.º 23
0
        // GET: Activities
        public async Task <IActionResult> Index(string sortOrder, string currentFilter, string searchString, int?pageNumber)
        {
            //Get the current user
            var user = await GetCurrentUserAsync();

            ViewData["CurrentSort"] = sortOrder;

            //Start date, County, City, Title, Finish date for the table sorts
            ViewData["StartSortParm"]  = String.IsNullOrEmpty(sortOrder) ? "start_desc" : "";
            ViewData["CountySortParm"] = sortOrder == "county_desc" ? "county_asc" : "county_desc";
            ViewData["CitySortParm"]   = sortOrder == "city_desc" ? "city_asc" : "city_desc";
            ViewData["TitleSortParm"]  = sortOrder == "title_desc" ? "title_asc" : "title_desc";
            ViewData["FinishSortParm"] = sortOrder == "finish_desc" ? "finish_asc" : "finish_desc";

            //Search
            ViewData["CurrentFilter"] = searchString;

            //Get the activies for the logged-in user
            var applicationDbContext = _context.Activity.Include(a => a.Location).Include(a => a.User)
                                       .Where(a => a.UserId == user.Id);

            //Paging
            if (searchString != null)
            {
                pageNumber = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            if (!String.IsNullOrEmpty(searchString))
            {
                applicationDbContext = applicationDbContext.Where(a => a.Location.County.Contains(searchString));
            }

            //Table sorts
            switch (sortOrder)
            {
            case "county_asc":
                applicationDbContext = applicationDbContext.OrderBy(g => g.Location.County);
                break;

            case "county_desc":
                applicationDbContext = applicationDbContext.OrderByDescending(g => g.Location.County);
                break;

            case "city_asc":
                applicationDbContext = applicationDbContext.OrderBy(g => g.City);
                break;

            case "city_desc":
                applicationDbContext = applicationDbContext.OrderByDescending(g => g.City);
                break;

            case "title_asc":
                applicationDbContext = applicationDbContext.OrderBy(g => g.Title);
                break;

            case "title_desc":
                applicationDbContext = applicationDbContext.OrderByDescending(g => g.Title);
                break;

            case "start_desc":
                applicationDbContext = applicationDbContext.OrderByDescending(g => g.StartTime);
                break;

            case "finish_asc":
                applicationDbContext = applicationDbContext.OrderBy(g => g.EndTime);
                break;

            case "finish_desc":
                applicationDbContext = applicationDbContext.OrderByDescending(g => g.EndTime);
                break;

            default:
                applicationDbContext = applicationDbContext = applicationDbContext.OrderBy(g => g.StartTime);
                break;
            }
            //Prints 5 activites per page
            int pageSize = 5;

            return(View(await PaginatedList <Activity> .CreateAsync(applicationDbContext.AsNoTracking(), pageNumber ?? 1, pageSize)));
        }
Ejemplo n.º 24
0
        public async Task <IActionResult> ListadeCausas(
            string sortOrder,
            string currentFilter,
            string searchString,
            int?pageNumber)
        {
            #region -ListaUsuarios-
            var user = await userManager.FindByNameAsync(User.Identity.Name);

            var roles = await userManager.GetRolesAsync(user);

            List <string> rolUsuario = new List <string>();

            for (int i = 0; i < roles.Count; i++)
            {
                rolUsuario.Add(roles[i]);
            }

            ViewBag.RolesUsuario = rolUsuario;
            #endregion


            ViewData["CurrentSort"]  = sortOrder;
            ViewData["NameSortParm"] = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            ViewData["DateSortParm"] = sortOrder == "Date" ? "date_desc" : "Date";


            if (searchString != null)
            {
                pageNumber = 1;
            }
            else
            {
                searchString = currentFilter;
            }


            ViewData["CurrentFilter"] = searchString;

            var causa = from p in _context.Causapenal
                        select p;

            if (!String.IsNullOrEmpty(searchString))
            {
                causa = causa.Where(p => p.CausaPenal.Contains(searchString) ||
                                    p.Juez.Contains(searchString) ||
                                    p.Cambio.Contains(searchString) ||
                                    p.Distrito.Contains(searchString) ||
                                    p.Cnpp.Contains(searchString));
            }

            switch (sortOrder)
            {
            case "name_desc":
                causa = causa.OrderByDescending(p => p.CausaPenal);
                break;

            case "Date":
                causa = causa.OrderBy(p => p.CausaPenal);
                break;

            case "date_desc":
                causa = causa.OrderByDescending(p => p.CausaPenal);
                break;

            default:
                causa = causa.OrderBy(p => p.CausaPenal);
                break;
            }

            int pageSize = 10;
            return(View(await PaginatedList <Causapenal> .CreateAsync(causa.AsNoTracking(), pageNumber ?? 1, pageSize)));
        }
Ejemplo n.º 25
0
        public async Task <ActionResult <IEnumerable <User> > > Get(int?page = 1, int?pageSize = 10)
        {
            var paginatedList = await PaginatedList <User> .CreateAsync(_db.Users, page.Value, pageSize.Value);

            return(paginatedList);
        }
        public async Task <IActionResult> ListLeaveType(string sortOrder,
                                                        string currentFilter,
                                                        string searchString,
                                                        int?pageNumber)
        {
            ViewData["CurrentSort"]          = sortOrder;
            ViewData["LeaveTypeSortParm"]    = String.IsNullOrEmpty(sortOrder) ? "LeaveType_desc" : "";
            ViewData["noofdaySortParm"]      = String.IsNullOrEmpty(sortOrder) ? "noofday_desc" : "";
            ViewData["allcatoToAllSortParm"] = String.IsNullOrEmpty(sortOrder) ? "allcatoToAll_desc" : "";
            ViewData["itispersonalSortParm"] = String.IsNullOrEmpty(sortOrder) ? "itispersonal_desc" : "";

            ViewData["CurrentFilter"] = searchString;

            if (searchString != null)
            {
                pageNumber = 1;
            }
            else
            {
                //searchString = "Enter some value";
                searchString = currentFilter;
            }



            var allusers = from s in _context.leaveType select s;

            if (!String.IsNullOrEmpty(searchString))
            {
                allusers = allusers.Where(s => s.LeaveType.Contains(searchString) ||
                                          s.noofday.ToString().Contains(searchString)
                                          );
            }

            switch (sortOrder)
            {
            case "LeaveType_desc":
                allusers = allusers.OrderByDescending(s => s.LeaveType);
                break;

            case "noofday_desc":
                allusers = allusers.OrderByDescending(s => s.noofday);
                break;

            case "allcatoToAll_desc":
                allusers = allusers.OrderByDescending(s => s.allcatoToAll);
                break;

            case "itispersonal_desc":
                allusers = allusers.OrderByDescending(s => s.itispersonal);
                break;


            default:
                allusers = allusers.OrderBy(s => s.LeaveType);
                break;
            }
            //return View(await allusers.AsNoTracking().ToListAsync());
            int pageSize = 5;

            return(View(await PaginatedList <leaveType> .CreateAsync(allusers.AsNoTracking(), pageNumber ?? 1, pageSize)));
        }
        // GET: KondisiKendaraans
        public async Task <IActionResult> Index(string ktsd, string searchString, string sortOrder, string currentFilter, int?pageNumber)
        {
            //buat list menyimpan ketersediaan
            var ktsdList = new List <string>();
            //Query mengambil data
            var ktsdQuery = from d in _context.KondisiKendaraan orderby d.NamaKondisi select d.NamaKondisi;

            ktsdList.AddRange(ktsdQuery.Distinct());

            //untuk menampilkan di view
            ViewBag.ktsd = new SelectList(ktsdList);

            //panggil db context
            var menu = from m in _context.KondisiKendaraan select m;

            //untuk memilih dropdownlist ketersediaan
            if (!string.IsNullOrEmpty(ktsd))
            {
                menu = menu.Where(x => x.NamaKondisi == ktsd);
            }

            //untuk search data
            if (!string.IsNullOrEmpty(searchString))
            {
                menu = menu.Where(s => s.NamaKondisi.Contains(searchString));
            }

            //untuk sorting
            ViewData["NameSortParm"] = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";

            switch (sortOrder)
            {
            case "name_desc":
                menu = menu.OrderByDescending(s => s.NamaKondisi);
                break;

            default:
                menu = menu.OrderBy(s => s.NamaKondisi);
                break;
            }

            //membuat pagedList
            ViewData["CurrentSort"] = sortOrder;
            if (searchString != null)
            {
                pageNumber = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewData["CurrentFilter"] = searchString;

            //definisi jumlah data pada halaman
            int pageSize = 5;

            return(View(await PaginatedList <KondisiKendaraan> .CreateAsync(menu.AsNoTracking(), pageNumber ?? 1, pageSize)));

            //return View(await menu.ToListAsync());
        }
        // ~/Invoice
        public async Task <IActionResult> Index(string sortOrder, string searchString, string currentFilter, int?pageNumber)
        {
            // default sort in ascending order by Invoice CreatedDate
            ViewData["CurrentSort"]   = sortOrder;
            ViewData["DateSortParam"] = string.IsNullOrEmpty(sortOrder) ? "date_desc" : "";
            ViewData["IDParam"]       = sortOrder == "InvoiceID" ? "ID_desc" : "InvoiceID";
            ViewData["NameParam"]     = sortOrder == "InvoiceName" ? "name_desc" : "InvoiceName";
            ViewData["UserParam"]     = sortOrder == "UserName" ? "user_desc" : "UserName";

            if (searchString != null)
            {
                pageNumber = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewData["CurrentFilter"] = searchString;

            var invoices = _context.Invoices
                           .Include(i => i.InvoiceLineitems)
                           .ThenInclude(i => i.Lineitem)
                           .AsNoTracking();

            if (!string.IsNullOrEmpty(searchString)) // search by invoicename
            {
                invoices = invoices.Where(i => i.InvoiceName.Contains(searchString));
            }

            switch (sortOrder)
            {
            case "date_desc":
                invoices = invoices.OrderByDescending(i => i.CreatedDate);
                break;

            case "InvoiceID":
                invoices = invoices.OrderBy(i => i.InvoiceID);
                break;

            case "ID_desc":
                invoices = invoices.OrderByDescending(i => i.InvoiceID);
                break;

            case "InvoiceName":
                invoices = invoices.OrderBy(i => i.InvoiceName);
                break;

            case "name_desc":
                invoices = invoices.OrderByDescending(i => i.InvoiceName);
                break;

            case "UserName":
                invoices = invoices.OrderBy(i => i.UserName);
                break;

            case "user_desc":
                invoices = invoices.OrderByDescending(i => i.UserName);
                break;

            default:
                invoices = invoices.OrderBy(i => i.CreatedDate);
                break;
            }

            return(View("Index", await PaginatedList <Invoice> .CreateAsync(invoices, pageNumber ?? 1, InvoiceListPageSize)));
        }
Ejemplo n.º 29
0
        public async Task <PaginatedList <User> > GetUsersAsync(int loggedUser, int pag, int perPag, string sortOrder, int statusFilter, string search)
        {
            var user = await _uow.UserRepository.GetAsync(loggedUser);

            if (user.Role == RoleEnum.NORMAL)
            {
                throw new NotAllowedException("User");
            }

            var result = _uow.UserRepository.GetAll()
                         .Where(u => u.Role == RoleEnum.NORMAL)
                         .AsQueryable();

            if (!string.IsNullOrWhiteSpace(search))
            {
                result = result.Where(
                    i => i.FullName.ToLower().Contains(search.ToLower()) ||
                    i.Email.ToLower().Contains(search.ToLower()) ||
                    i.Phone.ToLower().Contains(search.ToLower()));
            }

            // define status filter
            if (statusFilter > -1)
            {
                result = result.Where(i => (StatusEnum)statusFilter == i.Status);
            }

            // define sort order
            if (!string.IsNullOrWhiteSpace(sortOrder))
            {
                // sort order section
                switch (sortOrder)
                {
                case "fullName_desc":
                    result = result.OrderByDescending(i => i.FullName);
                    break;

                case "fullName_asc":
                    result = result.OrderBy(i => i.FullName);
                    break;

                case "email_desc":
                    result = result.OrderByDescending(i => i.Email);
                    break;

                case "email_asc":
                    result = result.OrderBy(i => i.Email);
                    break;

                case "phone_desc":
                    result = result.OrderByDescending(i => i.Phone);
                    break;

                case "phone_asc":
                    result = result.OrderBy(i => i.Phone);
                    break;

                case "status_desc":
                    result = result.OrderByDescending(i => i.Status);
                    break;

                case "status_asc":
                    result = result.OrderBy(i => i.Status);
                    break;

                default:
                    break;
                }
            }

            return(await PaginatedList <User> .CreateAsync(result, pag, perPag));
        }
        // GET: Genders
        public async Task <IActionResult> Index(string ktsd, string sortOrder, string searchString, string currentFilter, int?pageNumber)
        {
            //buat list menyimpan ketersediaaan
            var ktsdList = new List <string>();
            //query mengambil data
            var ktsdQuery = from d in _context.Gender orderby d.NamaGender select d.NamaGender;

            ktsdList.AddRange(ktsdQuery.Distinct());

            //untuk menampilkan di view
            ViewBag.ktsd = new SelectList(ktsdList);

            //panggil db context
            var menu = from m in _context.Gender.Include(k => k.IdGender) select m;

            //untuk memilih dropdownlist ketersediaan
            if (!string.IsNullOrEmpty(ktsd))
            {
                menu = menu.Where(x => x.IdGender.ToString() == ktsd);
            }

            //untuk search data
            if (!string.IsNullOrEmpty(searchString))
            {
                menu = menu.Where(s => s.NamaGender.Contains(searchString));
            }
            ViewData["CurrentSort"] = sortOrder;
            if (searchString != null)
            {
                pageNumber = 1;
            }
            else
            {
                searchString = currentFilter;
            }
            ViewData["CurrentFilter"] = searchString;
            int pageSize = 5;

            //untuk sorting
            ViewData["NameSortParm"] = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            ViewData["DateSortParm"] = sortOrder == "Date" ? "date_desc" : "Date";
            switch (sortOrder)
            {
            case "name_desc":
                menu = menu.OrderByDescending(s => s.NamaGender);
                break;

            case "Date":
                menu = menu.OrderBy(s => s.IdGender.ToString());
                break;

            case "date_desc":
                menu = menu.OrderByDescending(s => s.IdGender.ToString());
                break;

            default:     //nama ascending
                menu = menu.OrderBy(s => s.NamaGender);
                break;
            }
            return(View(await PaginatedList <Gender> .CreateAsync(menu.AsNoTracking(), pageNumber ?? 1, pageSize)));
        }