Exemplo n.º 1
0
        public ActionResult Delete(CatModel model)
        {
            using (var db = new PetDbContext())
            {
                var cat = db.Cats.FirstOrDefault(x => x.Id == model.Id);

                db.Cats.Remove(cat);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
        }
Exemplo n.º 2
0
        public ActionResult Edit(CatModel model)
        {
            using (var db = new PetDbContext())
            {
                var cat = db.Cats.FirstOrDefault(x => x.Id == model.Id);

                cat.FeetCount  = model.FeetCount;
                cat.IsLikeFish = model.IsLikeFish;
                cat.Name       = model.Name;

                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
        }
Exemplo n.º 3
0
 public HomeController(PetDbContext c)
 {
     this._context = c;
 }
Exemplo n.º 4
0
 public PetRepositoryManager(string dbPath)
 {
     dbContext = new PetDbContext(dbPath);
     mapper    = new MapperConfiguration(c => c.AddProfile <KutyAppLocalRepositoryProfile>()).CreateMapper();
 }
 public void CreatePet(Pet newPet)
 {
     using var db = new PetDbContext();
     db.Add(newPet);
     db.SaveChanges();
 }