public void AddCat(CatViewModel model) { Cat cat = new Cat { Name = model.Name, Age = model.Age, Breed = model.Breed, Url = model.Url }; _db.Cats.Add(cat); _db.SaveChanges(); }
public IActionResult Add(CatAddBindingModel model) { if (this.ModelState.IsValid) { var cat = new Cat() { Name = model.Name, Breed = model.Breed, ImageUrl = model.ImageUrl }; this.context.Cats.Add(cat); context.SaveChanges(); return(RedirectToAction("Details", "Cats", new { id = cat.Id })); } return(this.View()); }
public void Add(Cat entity) { this.context.Cats.Add(entity); context.SaveChanges(); }