Example #1
0
        public IActionResult Index(int page, SortState sortOrder)
        {
            Genre  sessionGenre     = HttpContext.Session.GetObject <Genre>("Genre");
            string sessionSortState = HttpContext.Session.GetString("SortStateGenre");

            if (sessionGenre != null)
            {
                _genre = sessionGenre;
            }

            if (sessionSortState != null)
            {
                if (sortOrder == SortState.No)
                {
                    sortOrder = (SortState)Enum.Parse(typeof(SortState), sessionSortState);
                }
            }
            ViewData["NameSort"] = sortOrder == SortState.NameDesc ? SortState.NameAsc : SortState.NameDesc;
            HttpContext.Session.SetString("SortStateGenre", sortOrder.ToString());

            IQueryable <Genre> genres = Sort(_context.Genres, sortOrder,
                                             _genre.NameGenre, (int)page);
            PageViewModel pageViewModel = new PageViewModel(NoteCount(_context.Genres,
                                                                      _genre.NameGenre), page, pageSize);
            GenresViewModel genresView = new GenresViewModel
            {
                GenreViewModel = _genre,
                PageViewModel  = genres,
                Pages          = pageViewModel
            };

            return(View(genresView));
        }
Example #2
0
        public IActionResult Index(SortState sortOrder = SortState.No, int index = 0)
        {
            Worker sessionWorker    = HttpContext.Session.GetObject <Worker>("Worker");
            string sessionSortState = HttpContext.Session.GetString("SortState");
            int?   page             = HttpContext.Session.GetInt32("Page");

            if (page == null)
            {
                page = 0;
                HttpContext.Session.SetInt32("Page", 0);
            }
            else
            {
                if (!(page < 1 && index < 0))
                {
                    page += index;
                }
                HttpContext.Session.SetInt32("Page", (int)page);
            }

            if (sessionWorker != null)
            {
                _worker = sessionWorker;
            }

            if (sessionSortState != null)
            {
                if (sortOrder == SortState.No)
                {
                    sortOrder = (SortState)Enum.Parse(typeof(SortState), sessionSortState);
                }
            }

            ViewData["SurnameSort"] = sortOrder == SortState.FioWorkerDesc ? SortState.FioWorkerAsc : SortState.FioWorkerDesc;
            ViewData["SalarySort"]  = sortOrder == SortState.SalaryDesc ? SortState.SalaryAsc : SortState.SalaryDesc;

            HttpContext.Session.SetString("SortState", sortOrder.ToString());
            IQueryable <Worker> workers = Sort(db.Workers, sortOrder,
                                               _worker.FioWorker, _worker.Salary, (int)page);
            WorkersViewModel workersView = new WorkersViewModel
            {
                WorkerViewModel = _worker,
                PageViewModel   = workers,
                PageNumber      = (int)page
            };

            return(View(workersView));
        }
Example #3
0
        public IActionResult Index(SortState sortOrder = SortState.No, int index = 0)
        {
            TVShow sessionTVShow    = HttpContext.Session.GetObject <TVShow>("TVShow");
            string sessionSortState = HttpContext.Session.GetString("SortStateTVShow");
            int?   page             = HttpContext.Session.GetInt32("Page");

            if (page == null)
            {
                page = 0;
                HttpContext.Session.SetInt32("Page", 0);
            }
            else
            {
                if (!(page < 1 && index < 0))
                {
                    page += index;
                }
                HttpContext.Session.SetInt32("Page", (int)page);
            }

            if (sessionTVShow != null)
            {
                _tvShow = sessionTVShow;
            }

            if (sessionSortState != null)
            {
                if (sortOrder == SortState.No)
                {
                    sortOrder = (SortState)Enum.Parse(typeof(SortState), sessionSortState);
                }
            }

            ViewData["NameSort"] = sortOrder == SortState.NameDesc ? SortState.NameAsc : SortState.NameDesc;
            HttpContext.Session.SetString("SortStateTVShow", sortOrder.ToString());

            IQueryable <TVShow> tvShows = Sort(db.TVShows, sortOrder,
                                               _tvShow.NameShow, (int)page);
            TVShowsViewModel tvShowsView = new TVShowsViewModel
            {
                TVShowViewModel = _tvShow,
                PageViewModel   = tvShows,
                PageNumber      = (int)page
            };

            return(View(tvShowsView));
        }
Example #4
0
        public IActionResult Index(SortState sortOrder = SortState.No, int index = 0)
        {
            Genre  sessionGenres    = HttpContext.Session.GetObject <Genre>("Genres");
            string sessionSortState = HttpContext.Session.GetString("SortState");
            int?   page             = HttpContext.Session.GetInt32("Page");

            if (page == null)
            {
                page = 0;
                HttpContext.Session.SetInt32("Page", 0);
            }
            else
            {
                if (!(page < 1 && index < 0))
                {
                    page += index;
                }
                HttpContext.Session.SetInt32("Page", (int)page);
            }

            if (sessionGenres != null)
            {
                _genre = sessionGenres;
            }

            if (sessionSortState != null)
            {
                if (sortOrder == SortState.No)
                {
                    sortOrder = (SortState)Enum.Parse(typeof(SortState), sessionSortState);
                }
            }

            ViewData["NameSort"] = sortOrder == SortState.NameDesc ? SortState.NameAsc : SortState.NameDesc;

            HttpContext.Session.SetString("SortState", sortOrder.ToString());
            IQueryable <Genre> genre = Sort(db.Genres, sortOrder,
                                            _genre.NameGenre, (int)page);
            GenresViewModel genresView = new GenresViewModel
            {
                GenreViewModel = _genre,
                PageViewModel  = genre,
                PageNumber     = (int)page
            };

            return(View(genresView));
        }
        public IActionResult Index(SortState sortOrder = SortState.No, int index = 0)
        {
            CitizensAppeal sessionCitizensAppeal = HttpContext.Session.GetObject <CitizensAppeal>("Treatment");
            string         sessionSortState      = HttpContext.Session.GetString("SortStateCitizensAppeal");
            int?           page = HttpContext.Session.GetInt32("Page");

            if (page == null)
            {
                page = 0;
                HttpContext.Session.SetInt32("Page", 0);
            }
            else
            {
                if (!(page < 1 && index < 0))
                {
                    page += index;
                }
                HttpContext.Session.SetInt32("Page", (int)page);
            }

            if (sessionCitizensAppeal != null)
            {
                _citizensAppeal = sessionCitizensAppeal;
            }

            if (sessionSortState != null)
            {
                if (sortOrder == SortState.No)
                {
                    sortOrder = (SortState)Enum.Parse(typeof(SortState), sessionSortState);
                }
            }

            ViewData["NameSort"] = sortOrder == SortState.NameDesc ? SortState.NameAsc : SortState.NameDesc;
            HttpContext.Session.SetString("SortState", sortOrder.ToString());
            IQueryable <CitizensAppeal> CitizensAppeals = Sort(db.CitizensAppeals, sortOrder,
                                                               _citizensAppeal.LFO, (int)page);
            CitizensAppealsViewModel CitizensAppealsView = new CitizensAppealsViewModel
            {
                CitizensAppealViewModel = _citizensAppeal,
                PageViewModel           = CitizensAppeals,
                PageNumber = (int)page
            };

            return(View(CitizensAppealsView));
        }
        public IActionResult Index(SortState sortOrder = SortState.No, int index = 0)
        {
            ScheduleForWeek sessionScheduleForWeek = HttpContext.Session.GetObject <ScheduleForWeek>("Patient");
            string          sessionSortState       = HttpContext.Session.GetString("SortStatePatient");
            int?            page = HttpContext.Session.GetInt32("Page");

            if (page == null)
            {
                page = 0;
                HttpContext.Session.SetInt32("Page", 0);
            }
            else
            {
                if (!(page < 1 && index < 0))
                {
                    page += index;
                }
                HttpContext.Session.SetInt32("Page", (int)page);
            }

            if (sessionScheduleForWeek != null)
            {
                _scheduleForWeek = sessionScheduleForWeek;
            }

            if (sessionSortState != null)
            {
                if (sortOrder == SortState.No)
                {
                    sortOrder = (SortState)Enum.Parse(typeof(SortState), sessionSortState);
                }
            }

            ViewData["NameSort"] = sortOrder == SortState.NameDesc ? SortState.NameAsc : SortState.NameDesc;
            HttpContext.Session.SetString("SortState", sortOrder.ToString());
            IQueryable <ScheduleForWeek> ScheduleForWeeks = Sort(db.SchedulesForWeek, sortOrder,
                                                                 _scheduleForWeek.StartTime, (int)page);
            ScheduleForWeeksViewModel scheduleForWeeksView = new ScheduleForWeeksViewModel
            {
                ScheduleForWeekViewModel = _scheduleForWeek,
                PageViewModel            = ScheduleForWeeks,
                PageNumber = (int)page
            };

            return(View(scheduleForWeeksView));
        }
        public IActionResult Index(SortState sortOrder)
        {
            ScheduleForWeek sessionScheduleForWeek = HttpContext.Session.GetObject <ScheduleForWeek>("ScheduleForWeek");
            string          sessionSortState       = HttpContext.Session.GetString("SortStateScheduleForWeek");
            int?            page = HttpContext.Session.GetInt32("ScheduleForWeekPage");

            if (page == null)
            {
                page = 0;
                HttpContext.Session.SetInt32("ScheduleForWeekPage", 0);
            }

            if (sessionScheduleForWeek != null)
            {
                _scheduleForWeek = sessionScheduleForWeek;
            }

            if (sessionSortState != null)
            {
                if (sortOrder == SortState.No)
                {
                    sortOrder = (SortState)Enum.Parse(typeof(SortState), sessionSortState);
                }
            }

            ViewData["NameSort"] = sortOrder == SortState.NameDesc ? SortState.NameAsc : SortState.NameDesc;
            HttpContext.Session.SetString("SortState", sortOrder.ToString());
            IQueryable <ScheduleForWeek> SchedulesForWeek = Sort(_context.SchedulesForWeek, sortOrder,
                                                                 _scheduleForWeek.StartTime, (int)page);

            foreach (var item in SchedulesForWeek)
            {
                item.TVShow = _context.TVShows.Where(o => o.TVShowID == item.TVShowID).FirstOrDefault();
            }

            ScheduleForWeeksViewModel SchedulesForWeekView = new ScheduleForWeeksViewModel
            {
                ScheduleForWeekViewModel = _scheduleForWeek,
                PageViewModel            = SchedulesForWeek,
                PageNumber = (int)page
            };

            return(View(SchedulesForWeekView));
        }
Example #8
0
        public IActionResult Index(SortState sortOrder)
        {
            Car    sessionCar       = HttpContext.Session.GetObject <Car>("Car");
            string sessionSortState = HttpContext.Session.GetString("SortStateCar");
            int?   page             = HttpContext.Session.GetInt32("CarPage");

            if (page == null)
            {
                page = 0;
                HttpContext.Session.SetInt32("CarPage", 0);
            }

            if (sessionCar != null)
            {
                _car = sessionCar;
            }

            if (sessionSortState != null)
            {
                if (sortOrder == SortState.No)
                {
                    sortOrder = (SortState)Enum.Parse(typeof(SortState), sessionSortState);
                }
            }

            ViewData["ModelSort"]  = sortOrder == SortState.ModelDesc ? SortState.ModelAsc : SortState.ModelDesc;
            ViewData["ColourSort"] = sortOrder == SortState.ColourDesc ? SortState.ColourAsc : SortState.ColourDesc;

            HttpContext.Session.SetString("SortState", sortOrder.ToString());
            IQueryable <Car> Cars = Sort(db.Cars, sortOrder,
                                         _car.Model, _car.Colour,
                                         _car.StateNumber, (int)page);

            CarsViewModel CarsView = new CarsViewModel
            {
                CarViewModel  = _car,
                PageViewModel = Cars,
                PageNumber    = (int)page
            };

            return(View(CarsView));
        }
Example #9
0
        public IActionResult Index(SortState sortOrder)
        {
            Order  sessionOrder     = HttpContext.Session.GetObject <Order>("Order");
            string sessionSortState = HttpContext.Session.GetString("SortStateOrder");
            int?   page             = HttpContext.Session.GetInt32("OrderPage");

            if (page == null)
            {
                page = 0;
                HttpContext.Session.SetInt32("OrderPage", 0);
            }

            if (sessionOrder != null)
            {
                _order = sessionOrder;
                //_order = JsonConvert.DeserializeObject<Order>(sessionOrder);
            }

            if (sessionSortState != null)
            {
                if (sortOrder == SortState.No)
                {
                    sortOrder = (SortState)Enum.Parse(typeof(SortState), sessionSortState);
                }
            }

            ViewData["NameSort"]  = sortOrder == SortState.DateReceiptDesc ? SortState.DateReceiptAsc : SortState.DateReceiptDesc;
            ViewData["PriceSort"] = sortOrder == SortState.DateCompletionDesc ? SortState.DateCompletionAsc : SortState.DateCompletionDesc;

            HttpContext.Session.SetString("SortState", sortOrder.ToString());
            IQueryable <Order> Orders = Sort(db.Orders, sortOrder,
                                             _order.DateReceipt, _order.DateCompletion, (int)page);
            OrdersViewModel OrdersView = new OrdersViewModel
            {
                OrderViewModel = _order,
                PageViewModel  = Orders,
                PageNumber     = (int)page
            };

            return(View(OrdersView));
        }
Example #10
0
        public IActionResult Index(int page, SortState sortOrder)
        {
            CitizensAppeal sessionCitizensAppeal = HttpContext.Session.GetObject <CitizensAppeal>("CitizensAppeal");
            string         sessionSortState      = HttpContext.Session.GetString("SortStateCitizensAppeal");

            if (sessionCitizensAppeal != null)
            {
                _citizensAppeal = sessionCitizensAppeal;
            }

            if (sessionSortState != null)
            {
                if (sortOrder == SortState.No)
                {
                    sortOrder = (SortState)Enum.Parse(typeof(SortState), sessionSortState);
                }
            }

            ViewData["NameSort"] = sortOrder == SortState.NameDesc ? SortState.NameAsc : SortState.NameDesc;
            HttpContext.Session.SetString("SortState", sortOrder.ToString());
            IQueryable <CitizensAppeal> CitizensAppeals = Sort(db.CitizensAppeals, sortOrder,
                                                               _citizensAppeal.LFO, (int)page);

            PageViewModel pageViewModel = new PageViewModel(NoteCount(db.CitizensAppeals,
                                                                      _citizensAppeal.LFO), page, pageSize);

            foreach (var item in CitizensAppeals)
            {
                item.ScheduleForWeek = db.SchedulesForWeek.Where(o => o.ScheduleForWeekID == item.ScheduleForWeekID).FirstOrDefault();
            }
            CitizensAppealsViewModel CitizensAppealsView = new CitizensAppealsViewModel
            {
                CitizensAppealViewModel = _citizensAppeal,
                PageViewModel           = CitizensAppeals,
                PageNumber = (int)page
            };

            return(View(CitizensAppealsView));
        }
Example #11
0
        public IActionResult Index(int page, SortState sortOrder)
        {
            TVShow sessionTVShow    = HttpContext.Session.GetObject <TVShow>("TVShow");
            string sessionSortState = HttpContext.Session.GetString("SortStateTVShow");

            if (sessionTVShow != null)
            {
                _tvShow = sessionTVShow;
            }

            if (sessionSortState != null)
            {
                if (sortOrder == SortState.No)
                {
                    sortOrder = (SortState)Enum.Parse(typeof(SortState), sessionSortState);
                }
            }
            ViewData["NameSort"] = sortOrder == SortState.NameDesc ? SortState.NameAsc : SortState.NameDesc;
            HttpContext.Session.SetString("SortStateTVShow", sortOrder.ToString());

            IQueryable <TVShow> tvShows = Sort(_context.TVShows, sortOrder,
                                               _tvShow.NameShow, (int)page);
            PageViewModel pageViewModel = new PageViewModel(NoteCount(_context.TVShows,
                                                                      _tvShow.NameShow), page, pageSize);

            foreach (var item in tvShows)
            {
                item.Genre = _context.Genres.Where(o => o.GenreID == item.GenreID).FirstOrDefault();
            }

            TVShowsViewModel tvShowsView = new TVShowsViewModel
            {
                TVShowViewModel = _tvShow,
                PageViewModel   = tvShows,
                Pages           = pageViewModel
            };

            return(View(tvShowsView));
        }
Example #12
0
        public IActionResult Index(SortState sortOrder)
        {
            Owner  sessionOwner     = HttpContext.Session.GetObject <Owner>("Owner");
            string sessionSortState = HttpContext.Session.GetString("SortStateClient");
            int?   page             = HttpContext.Session.GetInt32("OwnerPage");

            if (page == null)
            {
                page = 0;
                HttpContext.Session.SetInt32("OwnerPage", 0);
            }

            if (sessionOwner != null)
            {
                _owner = sessionOwner;
            }

            if (sessionSortState != null)
            {
                if (sortOrder == SortState.No)
                {
                    sortOrder = (SortState)Enum.Parse(typeof(SortState), sessionSortState);
                }
            }

            ViewData["FioOwnerSort"] = sortOrder == SortState.FioOwnerDesc ? SortState.FioOwnerAsc : SortState.FioOwnerDesc;
            HttpContext.Session.SetString("SortStateOwner", sortOrder.ToString());

            IQueryable <Owner> owners = Sort(db.Owners, sortOrder,
                                             _owner.FioOwner, (int)page);
            OwnersViewModel employeesView = new OwnersViewModel
            {
                OwnerViewModel = _owner,
                PageViewModel  = owners,
                PageNumber     = (int)page
            };

            return(View(employeesView));
        }
Example #13
0
        public ItemSort(SortState[] order, SortState defaultState, string storageName)
        {
            // Store the order and get the current state from persistent storage
            SortOrder = order;

            StorageName = storageName + "sortOrder";

            CurrentOrder = ( SortState )Enum.Parse(typeof(SortState), PersistentStorage.GetStringItem(StorageName, defaultState.ToString()));

            // if this order is not in the allowed states then set the current order to the first item in the states
            if (Array.Exists(SortOrder, element => (element == CurrentOrder)) == false)
            {
                CurrentOrder = SortOrder[0];
            }
        }