// GET: Laboratories
        public IActionResult Index(int?numberlaboratory, string nameequipment, int page = 1, LaboratoriesSortState sortOrder = LaboratoriesSortState.NumberLaboratoryAsc)
        {
            int pageSize = 10;
            IQueryable <Laboratories> source = _context.Laboratories.Include(l => l.IdEquipmentNavigation);

            if (numberlaboratory != null && numberlaboratory != 0)
            {
                source = source.Where(x => x.NumberLaboratory == numberlaboratory);
            }
            if (nameequipment != null)
            {
                source = source.Where(x => x.IdEquipmentNavigation.NameEquipment == nameequipment);
            }

            switch (sortOrder)
            {
            case LaboratoriesSortState.NumberLaboratoryAsc:
                source = source.OrderBy(x => x.NumberLaboratory);
                break;

            case LaboratoriesSortState.NumberLaboratoryDesc:
                source = source.OrderByDescending(x => x.NumberLaboratory);
                break;

            case LaboratoriesSortState.IdEquipmentAsc:
                source = source.OrderBy(x => x.IdEquipment);
                break;

            case LaboratoriesSortState.IdEquipmentDesc:
                source = source.OrderByDescending(x => x.IdEquipment);
                break;
            }

            var                   count    = source.Count();
            var                   items    = source.Skip((page - 1) * pageSize).Take(pageSize);
            PageViewModel         pageView = new PageViewModel(count, page, pageSize);
            LaboratoriesViewModel ivm      = new LaboratoriesViewModel
            {
                PageViewModel   = pageView,
                SortViewModel   = new SortLaboratoriesViewModel(sortOrder),
                FilterViewModel = new FilterLaboratoriesViewModel(numberlaboratory, nameequipment),
                Laboratories    = items
            };

            return(View(ivm));
        }
 public SortLaboratoriesViewModel(LaboratoriesSortState sortOrder)
 {
     NumberLaboratoryAscSort = sortOrder == LaboratoriesSortState.NumberLaboratoryAsc ? LaboratoriesSortState.NumberLaboratoryDesc : LaboratoriesSortState.NumberLaboratoryAsc;
     IdEquipmentAscSort      = sortOrder == LaboratoriesSortState.IdEquipmentAsc ? LaboratoriesSortState.IdEquipmentDesc : LaboratoriesSortState.IdEquipmentAsc;
     Current = sortOrder;
 }