public IActionResult Index()
        {
            AnimalCategoriesViewModel animalCategoriesViewModel = new AnimalCategoriesViewModel()
            {
                Categories = _context.Categories.ToList(),
                Animals    = _context.Animals.ToList()
            };

            return(View(animalCategoriesViewModel));
        }
        public IActionResult CatalogByCategory(Category category)
        {
            var animalSorted = _context.Animals.Where(a => a.CategoryId == category.CategoryId); //Saving all the animals by the input category

            AnimalCategoriesViewModel animalCategoriesViewModel = new AnimalCategoriesViewModel()
            {
                Categories = _context.Categories.ToList(),
                Animals    = animalSorted.ToList()
            };

            return(View("Index", animalCategoriesViewModel));
        }
Example #3
0
        public IActionResult Index(bool isSucceed = false, bool isDeleted = false)
        {
            AnimalCategoriesViewModel animalCategoriesViewModel = new AnimalCategoriesViewModel()
            {
                Categories = _context.Categories.ToList(),
                Animals    = _context.Animals.ToList()
            };

            ViewBag.isSucceed = isSucceed; //For alerting the user if the update/add operation succeeded
            ViewBag.isDeleted = isDeleted; //For alerting the user if the delete operation succeeded

            return(View(animalCategoriesViewModel));
        }