Exemplo n.º 1
0
        public IActionResult Index()
        {
            using (var db = new BabyDbContext())
            {
                var babies = db.Babies.ToList();

                return(View(babies));
            }
        }
Exemplo n.º 2
0
        public IActionResult Edit(Baby baby)
        {
            using (var db = new BabyDbContext())
            {
                db.Babies.Update(baby);
                db.SaveChanges();
            }

            return(RedirectToAction("Index", "Baby"));
        }
Exemplo n.º 3
0
        public IActionResult Delete(int id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index", "Baby"));
            }

            using (var db = new BabyDbContext())
            {
                var baby = db.Babies.Find(id);

                if (baby == null)
                {
                    return(RedirectToAction("Index", "Baby"));
                }

                return(View(baby));
            }
        }
 public BabyController(BabyDbContext dbContext)
 {
     this.dbContext = dbContext;
 }