Exemplo n.º 1
0
        public IActionResult ConfirmDelete(int id, AdoptionCatFormModel model)
        {
            var catExists = this.adoptionCats.Exists(id);

            if (!catExists)
            {
                return(RedirectToAction("Adoption", "Cats", new { area = "" }));
            }

            var result = this.adoptionCats.Remove(id);

            return(RedirectToAction("Adoption", "Cats", new { area = "" }));
        }
Exemplo n.º 2
0
        public IActionResult Add(AdoptionCatFormModel model)
        {
            var success = this.adoptionCats.Add(
                model.Name, model.Image, model.Age, model.Location, model.Description, model.Gender);

            if (!success)
            {
                return(this.BadRequest());
            }

            this.TempData.AddSuccessMessage($"The cat {model.Name} was added successfully!");

            return(RedirectToAction("Adoption", "Cats", new { area = "" }));
        }
Exemplo n.º 3
0
        public IActionResult Edit(int id, AdoptionCatFormModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(model));
            }

            var catExists = this.adoptionCats.Exists(id);

            if (!catExists)
            {
                return(this.NotFound());
            }

            this.adoptionCats.Edit(
                model.Id, model.Name, model.Age, model.Image, model.Description, model.Gender, "");

            return(RedirectToAction("Adoption", "Cats", new { area = "" }));
        }