Пример #1
0
        // GET: Pets
        public ActionResult Index(string kind, string male, string age, int?page)
        {
            //int pageSize = 3;
            //int pageNumber = (page ?? 1);
            IEnumerable <Pet> pets  = UOW.PetRepository.FilterPets(kind, male, age).ToList();
            List <KindOfPet>  kinds = UOW.KindOfPetPepository.AllKinds.ToList();

            // устанавливаем начальный элемент, который позволит выбрать всех
            kinds.Insert(0, new KindOfPet {
                Kind = "Все", KindOfPetId = 10
            });
            PetsListViewModel plvm = new PetsListViewModel
            {
                Pets = pets.ToList(),
                //Pets = pets.ToPagedList(pageNumber, pageSize),
                Kinds = new SelectList(kinds, "KindOfPetId", "Kind"),
                Males = new SelectList(new List <string>()
                {
                    "Все",
                    "Мальчик",
                    "Девочка"
                }),
                Ages = new SelectList(new List <string>()
                {
                    "Все",
                    "Младше года",
                    "Старше года"
                })
            };

            return(View(plvm));
        }
Пример #2
0
        public IActionResult All(int id = 1)
        {
            if (id <= 0)
            {
                return(this.NotFound());
            }

            const int ItemsPerPage = 8;
            var       viewModel    = new PetsListViewModel
            {
                ItemsPerPage = ItemsPerPage,
                PageNumber   = id,
                PetsCount    = this.petsService.GetCount(),
                Pets         = this.petsService.GetAll <PetsInListViewModel>(id, ItemsPerPage),
            };

            return(this.View(viewModel));
        }
Пример #3
0
        public IActionResult MyPets(string addedByUserId, int id = 1)
        {
            if (id <= 0)
            {
                return(this.NotFound());
            }

            var       userName     = this.userManager.FindByIdAsync(addedByUserId).Result.UserName;
            const int ItemsPerPage = 8;
            var       viewModel    = new PetsListViewModel
            {
                ItemsPerPage = ItemsPerPage,
                PageNumber   = id,
                PetsCount    = this.petsService.GetCount(),
                Pets         = this.petsService.GetMine <PetsInListViewModel>(id, addedByUserId, ItemsPerPage),
                UserName     = userName,
            };

            return(this.View(viewModel));
        }
Пример #4
0
        public ViewResult Index(string city, string category, int petPage = 1)
        {
            var userId          = userManager.GetUserId(HttpContext.User);
            var currentUserPets = repository.Pets.Where(x => x.User.Id == userId);

            var Pets = new PetsListViewModel
            {
                Pets       = currentUserPets,
                PagingInfo = new PagingInfo
                {
                    CurrentPage  = petPage,
                    ItemsPerPage = PageBigSize,
                    TotalItems   = category == null
                        ? repository.Pets.Count()
                        : repository.Pets.Where(e => e.Category == category).Count()
                },
                CurrentCategory = category
            };

            return(View(Pets));
        }