// GET: Empresa/Details/5 public ActionResult Details(int id) { var emp = new Empresa(); using (var ctx = new GDentalContext()) { emp = ctx.Empresas.Find(id); } return View(emp); }
// GET: Empresa/Edit/5 public ActionResult Edit(int id) { try { var emp = new Empresa(); using (var ctx = new GDentalContext()) { emp = ctx.Empresas.Find(id); } return View(emp); } catch { return View(); } }
public ActionResult Create(Empresa model) { try { using (var ctx = new GDentalContext()) { ctx.Empresas.Add(model); ctx.SaveChanges(); } return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Edit(int id, Empresa model) { try { var emp = new Empresa(); using (var ctx = new GDentalContext()) { var original = ctx.Empresas.Find(id); if (original != null) { ctx.Entry(original).CurrentValues.SetValues(model); ctx.SaveChanges(); } } return RedirectToAction("Index"); } catch { return View(); } }
public Form1() { InitializeComponent(); using (var ctx = new GDentalContext()) { Empresa emp = new Empresa() { ChaveApi = "", Cnpj = "83.756.386/0001-93", CroResponsavel = "123456", FimExpediente = "18:00", InicioExpediente = "08:00", NomeFantasia = "Dentitas SA", RazaoSocial = "Dentistas SA" }; ctx.Empresas.Add(emp); ctx.SaveChanges(); } }