Пример #1
0
        public ActionResult Delete(Centro model)
        {
            try
            {
                model = contexto.Centros.Find(model.Id);
                contexto.Centros.Remove(model);
                contexto.SaveChanges();

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Пример #2
0
        public ActionResult Create(Centro model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    contexto.Centros.Add(model);
                    contexto.SaveChanges();

                    return RedirectToAction("Index");
                }

                return View(model);
            }
            catch
            {
                return View();
            }
        }
Пример #3
0
        public ActionResult Edit(Centro model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    contexto.Entry(model).State = System.Data.EntityState.Modified;
                    contexto.Entry(model.Endereco).State = System.Data.EntityState.Modified;
                    contexto.SaveChanges();

                    return RedirectToAction("Index");
                }

                return View();
            }
            catch
            {
                return View();
            }
        }
Пример #4
0
 public ActionResult Create()
 {
     Centro model = new Centro();
     model.Endereco = new Endereco();
     return View(model);
 }