public ActionResult Create([Bind(Include = "REG_ID,REG_NOMBRE")] REGION rEGION) { if (ModelState.IsValid) { db.REGION.Add(rEGION); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(rEGION)); }
public ActionResult Create([Bind(Include = "DIRECCION_DIR_ID,EMP_ID,EMP_NOMBRE,EMP_RUT")] EMPRESA eMPRESA) { if (ModelState.IsValid) { db.EMPRESA.Add(eMPRESA); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DIRECCION_DIR_ID = new SelectList(db.DIRECCION, "DIR_ID", "CALLE", eMPRESA.DIRECCION_DIR_ID); return(View(eMPRESA)); }
public static bool crear(Producto producto) { try { using (OfertasEntities contexto = new OfertasEntities()) { Producto productoExistente = contexto.Producto.Where(x => x.codigo == producto.codigo).FirstOrDefault(); if (productoExistente != null) { return(false); } contexto.Producto.Add(producto); contexto.SaveChanges(); } } catch (Exception ex) { throw ex; } return(true); }