Пример #1
0
        // GET:Workout
        public IActionResult Index(string sortOrder, string filter, string currentFilter, int?page)
        {
            ViewData["CurrentSort"]   = sortOrder;
            ViewData["NameSortParam"] = string.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            if (filter != null)
            {
                page = 1;
            }
            else
            {
                filter = currentFilter;
            }
            ViewData["CurrentFilter"] = filter;
            var collWorkouts = _workoutRepository.WorkoutsByFilter(filter);

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

            default:
                collWorkouts = collWorkouts.OrderBy(s => s.Name);
                break;
            }
            var pageSize = 6;

            return(View(PagerList <Workout> .Create(collWorkouts, page ?? 1, pageSize)));
        }
Пример #2
0
        public ActionResult List(string sortOrder, string filterTag, string curentTag, string filter, string pageSize,
                                 string currentFilter, int?page)
        {
            ViewData["CurrentSort"]   = sortOrder;
            ViewData["NameSortParam"] = string.IsNullOrEmpty(sortOrder) ? "name_desc" : "";

            if (!string.IsNullOrEmpty(pageSize))
            {
                ViewData["SizePage"] = pageSize;
            }
            else if (string.IsNullOrEmpty(pageSize) & string.IsNullOrEmpty((string)ViewData["SizePage"]))
            {
                pageSize = (string)ViewData["SizePage"];
            }

            ViewData["AllTags"] = _tagRepository.Tags.ToList();
            int sizeOfPage;

            if (int.TryParse(pageSize, out sizeOfPage) == false)
            {
                sizeOfPage = 12;
            }
            if (filter != null)
            {
                page = 1;
            }
            else
            {
                filter = currentFilter;
            }
            ViewData["CurrentFilter"] = filter;

            IEnumerable <Workout> collworkout;

            if (filterTag == null)
            {
                filterTag   = curentTag;
                collworkout = _workoutRepository.WorkoutsByFilter(filter).Where(t => t.PersonWorkout == false);
            }
            else
            {
                collworkout = _workoutRepository.WorkoutsByFilter(filter).Where(t => t.Tag.Name == filterTag);
            }
            ViewData["FilterTagParam"] = filterTag;
            switch (sortOrder)
            {
            case "name_desc":
                collworkout = collworkout.OrderByDescending(s => s.Name);
                break;

            default:
                collworkout = collworkout.OrderBy(s => s.Name);
                break;
            }

            return(View(PagerList <Workout> .Create(collworkout, page ?? 1, sizeOfPage)));
        }
Пример #3
0
        // GET: /<controller>/
        public ActionResult List(string sortOrder, string filter, string pageSize, string currentFilter, int?page)
        {
            ViewData["CurrentSort"]   = sortOrder;
            ViewData["NameSortParam"] = string.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            if (!string.IsNullOrEmpty(pageSize))
            {
                ViewData["SizePage"] = pageSize;
            }
            else if (string.IsNullOrEmpty(pageSize) & string.IsNullOrEmpty((string)ViewData["SizePage"]))
            {
                pageSize = (string)ViewData["SizePage"];
            }


            int sizeOfPage;

            if (int.TryParse(pageSize, out sizeOfPage) == false)
            {
                sizeOfPage = 6;
            }
            if (filter != null)
            {
                page = 1;
            }
            else
            {
                filter = currentFilter;
            }
            ViewData["CurrentFilter"] = filter;
            var collnews = _newsRepository.NewsByFilter(filter);
            var coll     = new List <NewsViewModel>();

            foreach (var collnew in collnews)
            {
                var view = new NewsViewModel();

                view.Name       = collnew.Name;
                view.ImagePath  = collnew.ImagePath;
                view.Annatation = System.IO.File.ReadAllLines(@"../BeFit/wwwroot" + collnew.Path).First();
                view.Tag        = collnew.Tag;
                coll.Add(view);
            }
            switch (sortOrder)
            {
            case "name_desc":
                collnews = collnews.OrderByDescending(s => s.Name);
                break;

            default:
                collnews = collnews.OrderBy(s => s.Name);
                break;
            }

            return(View(PagerList <NewsViewModel> .Create(coll, page ?? 1, sizeOfPage)));
        }
Пример #4
0
        // GET: /Cardio/
        public IActionResult Index(string sortOrder, string pageSize, string filter, string currentFilter, int?page)
        {
            ViewData["CurrentSort"]   = sortOrder;
            ViewData["NameSortParam"] = string.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            ViewData["CalSortParam"]  = string.IsNullOrEmpty(sortOrder) ? "cal_desc" : "cal";

            if (!string.IsNullOrEmpty(pageSize))
            {
                ViewData["SizePage"] = pageSize;
            }
            else if (string.IsNullOrEmpty(pageSize) & string.IsNullOrEmpty((string)ViewData["SizePage"]))
            {
                pageSize = (string)ViewData["SizePage"];
            }


            int sizeOfPage;

            if (int.TryParse(pageSize, out sizeOfPage) == false)
            {
                sizeOfPage = 12;
            }
            if (filter != null)
            {
                page = 1;
            }
            else
            {
                filter = currentFilter;
            }
            ViewData["CurrentFilter"] = filter;
            var collTag = _cardioRepository.CardiosByFilter(filter);

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

            case "cal_desc":
                collTag = collTag.OrderByDescending(s => s.CalPerHour);
                break;

            case "cal":
                collTag = collTag.OrderBy(s => s.CalPerHour);
                break;

            default:
                collTag = collTag.OrderBy(s => s.Name);
                break;
            }

            return(View(PagerList <Cardio> .Create(collTag, page ?? 1, sizeOfPage)));
        }
Пример #5
0
        public ActionResult List(string sortOrder, string filter, string pageSize, string currentFilter, int?page)
        {
            ViewData["CurrentSort"]   = sortOrder;
            ViewData["NameSortParam"] = string.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            if (!string.IsNullOrEmpty(pageSize))
            {
                ViewData["SizePage"] = pageSize;
            }
            else if (string.IsNullOrEmpty(pageSize) & string.IsNullOrEmpty((string)ViewData["SizePage"]))
            {
                pageSize = (string)ViewData["SizePage"];
            }


            int sizeOfPage;

            if (int.TryParse(pageSize, out sizeOfPage) == false)
            {
                sizeOfPage = 12;
            }
            if (filter != null)
            {
                page = 1;
            }
            else
            {
                filter = currentFilter;
            }
            ViewData["CurrentFilter"] = filter;
            var collExercises = _repository.ExercisesByFilter(filter);

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

            default:
                collExercises = collExercises.OrderBy(s => s.Name);
                break;
            }

            return(View(PagerList <Exercise> .Create(collExercises, page ?? 1, sizeOfPage)));
        }
Пример #6
0
        // GET: User
        public IActionResult Index(string sortOrder, string filter, string currentFilter, int?page)
        {
            ViewData["CurrentSort"]         = sortOrder;
            ViewData["NameSortParam"]       = string.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            ViewData["SecondNameSortParam"] = string.IsNullOrEmpty(sortOrder) ? "Second_name_desc" : "Second_name";
            if (filter != null)
            {
                page = 1;
            }
            else
            {
                filter = currentFilter;
            }
            ViewData["CurrentFilter"] = filter;
            var collTag = _appUserRepository.UserProfileByFilter(filter);

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

            case "Second_name_desc":
                collTag = collTag.OrderByDescending(s => s.FirstName);
                break;

            case "Second_name":
                collTag = collTag.OrderBy(s => s.FirstName);
                break;

            default:
                collTag = collTag.OrderBy(s => s.FirstName);
                break;
            }
            var pageSize = 10;

            return(View(PagerList <AppUser> .Create(collTag, page ?? 1, pageSize)));
        }