public ActionResult Registrar(Factura.Models.impresoras impresoraModel) { try { if (ModelState.IsValid) { using ( ffeEntitiesImpresora db = new ffeEntitiesImpresora()) { DateTime now = DateTime.Now; impresoraModel.created_at = now; impresoraModel.estatus = 1; db.impresoras.Add(impresoraModel); db.SaveChanges(); } } return(RedirectToAction("Index", "Impresoras")); } catch (Exception e) { if (e.Source != null) { Console.WriteLine("IOException source: {0}", e.Source); } throw; } }
public ActionResult Index(Factura.Models.impresoras impresoraModel) { using (ffeEntitiesImpresora db = new ffeEntitiesImpresora() ) { var impresoras = db.impresoras.Where(x => x.estatus != 0).Select(row => row).ToList(); ViewBag.Data = impresoras; return(View("Index")); } }