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; } }
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 Desactivar(int?id) { using ( ffeEntitiesEmpresa db = new ffeEntitiesEmpresa()) { var empresaDetails = db.empresas.Find(id); empresaDetails.active = 0; if (TryUpdateModel(empresaDetails)) { db.SaveChanges(); } return(RedirectToAction("Index", "Empresa")); } }