Esempio n. 1
0
        public string UpdateDog(Dog Dog)
        {
            string jsonResponse;

            try
            {
                _dogService.UpdateDog(Dog);
                jsonResponse = $"Dog updated sucessfully. Details: {Dog.Name}, {Dog.FavouriteThing}, {Dog.WouldLike}";
            }
            catch (Exception e)
            {
                jsonResponse = $"Error updating dog: {e.Message}";
            }

            return(jsonResponse);
        }
Esempio n. 2
0
        public ActionResult Edit(int id, DogEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.DogId != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var service = new DogService();

            if (service.UpdateDog(model))
            {
                TempData["SaveResult"] = "Your dog was updated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your dog could not be updated.");
            return(View(model));
        }
Esempio n. 3
0
 public IActionResult Edit(Dog dog)
 {
     service.UpdateDog(dog);
     return(RedirectToAction(nameof(Index)));
 }