public ActionResult Registrar(Factura.Models.empresas empresaModel) { try { if (ModelState.IsValid) { using ( ffeEntitiesEmpresa db = new ffeEntitiesEmpresa()) { DateTime now = DateTime.Now; empresaModel.created_at = now; empresaModel.active = 1; db.empresas.Add(empresaModel); db.SaveChanges(); } } return(RedirectToAction("Index", "Empresa")); } catch (DbUpdateException /* ex */) { //Log the error (uncomment ex variable name and write a log. ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists " + "see your system administrator."); return(null); } /*catch (Exception e) * { * if (e.Source != null) * Console.WriteLine("IOException source: {0}", e.Source); * throw; * }*/ }
public ActionResult Actualizar(Factura.Models.empresas empresaModel) { try { if (ModelState.IsValid) { using (ffeEntitiesEmpresa db = new ffeEntitiesEmpresa()) { var empresaDetails = db.empresas.Find(empresaModel.id); if (TryUpdateModel(empresaDetails)) { db.SaveChanges(); } } } return(RedirectToAction("Index", "Empresa")); } catch (Exception e) { if (e.Source != null) { Console.WriteLine("IOException source: {0}", e.Source); } throw; } }
// GET: Login public ActionResult List(Factura.Models.empresas empresaModel) { using (ffeEntities db = new ffeEntities()) { var usuarios = db.users.Select(row => row).ToList(); ViewBag.Data = usuarios; return(View("List")); } }
// GET: Empresa public ActionResult Index(Factura.Models.empresas empresaModel) { using ( ffeEntitiesEmpresa db = new ffeEntitiesEmpresa()) { var empresaDetails = db.empresas.Where(x => x.active == 1).Select(row => row).ToList(); ViewBag.Data = empresaDetails; return(View("Index")); } }