Exemple #1
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            //returns the animal to be delete by looping through the database to match it will the ID passed through the parameter
            AnimalExperience = await _context.AnimalExperience
                               .Include(a => a.Sitter).FirstOrDefaultAsync(m => m.ExperienceID == id);

            if (AnimalExperience == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Exemple #2
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            //finds the animal in the database by looking for the ID passed through the parameter and removes in and saves the database
            AnimalExperience = await _context.AnimalExperience.FindAsync(id);

            if (AnimalExperience != null)
            {
                _context.AnimalExperience.Remove(AnimalExperience);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }