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); }
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)); }
public IActionResult Edit(Dog dog) { service.UpdateDog(dog); return(RedirectToAction(nameof(Index))); }