public IActionResult Add(AddKittenViewModel model) { if (!this.IsValidModel(model)) { this.ShowError(IncorrectData); return(this.View()); } bool createCat = this._kitten.Create(model.Name, model.Age, model.Breed); if (createCat) { return(this.RedirectToAction("/kittens/all")); } this.ShowError(IncorrectData); return(this.View()); }
public IActionResult Add(AddKittenViewModel model) { if (!this.IsValidModel(model)) { this.ShowError("Invalid kitten details."); return(this.View()); } var name = model.Name; var age = model.Age; var breed = model.Breed; var success = this.kittens.Add(name, age, breed); if (!success) { this.ShowError("Invalid breed."); return(this.View()); } return(this.RedirectToAction("/kittens/all")); }