Esempio n. 1
0
        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();
        }
Esempio n. 2
0
        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();
 }