public ActionResult Create(Company company) { db.Database.Connection.ConnectionString = Suma2Lealtad.Modules.AppModule.ConnectionString("SumaLealtad"); if (ModelState.IsValid) { if (db.Companies.Count() > 0) { company.id = db.Companies.Max(c => c.id) + 1; } else { company.id = 1; } company.userid = 1; //provisional sesion company.creationdate = System.DateTime.Now; db.Companies.Add(company); db.SaveChanges(); return RedirectToAction("Index"); } return View(company); }
public bool SaveChanges(Company company) { using (LealtadEntities db = new LealtadEntities()) { Company Company = db.Companies.FirstOrDefault(c => c.id == company.id); if (Company != null) { Company.name = company.name; Company.phone = company.phone; Company.rif = company.rif; Company.ALIAS = company.ALIAS; Company.address = company.address; Company.email = company.email; } db.SaveChanges(); return true; } }
public bool Save(Company company) { using (LealtadEntities db = new LealtadEntities()) { var Company = new Company() { id = CompanyID(), name = company.name, phone = company.phone, rif = company.rif, ALIAS = company.ALIAS, address = company.address, email = company.email, creationdate = DateTime.Now, userid = (int)HttpContext.Current.Session["userid"] }; db.Companies.Add(Company); db.SaveChanges(); return true; } }
public ActionResult Edit(Company company) { db.Database.Connection.ConnectionString = Suma2Lealtad.Modules.AppModule.ConnectionString("SumaLealtad"); if (ModelState.IsValid) { company.userid = 1; //provisional sesion company.creationdate = System.DateTime.Now; db.Entry(company).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(company); }
public ActionResult Edit(Company company) { ViewModel viewmodel = new ViewModel(); if (!rep.SaveChanges(company)) { viewmodel.Title = "Prepago / Compañia / Editar Compañia"; viewmodel.Message = "Existen campos que son requeridos para procesar el formulario."; viewmodel.ControllerName = "CompanyPrepago"; viewmodel.ActionName = "Index"; viewmodel.RouteValues = company.rif; } else { viewmodel.Title = "Prepago / Compañia / Editar Compañia"; viewmodel.Message = "La información de la Compañia ha sido actualizada satisfactoriamente."; viewmodel.ControllerName = "CompanyPrepago"; viewmodel.ActionName = "Index"; viewmodel.RouteValues = company.rif; } return RedirectToAction("GenericView", viewmodel); }
public ActionResult Create(Company company) { ViewModel viewmodel = new ViewModel(); if (rep.Save(company)) { viewmodel.Title = "Prepago / Compañia / Crear Compañia"; viewmodel.Message = "Compañia creada exitosamente."; viewmodel.ControllerName = "CompanyPrepago"; viewmodel.ActionName = "Index"; viewmodel.RouteValues = company.rif; } else { viewmodel.Title = "Prepago / Compañia / Crear Compañia"; viewmodel.Message = "Error de aplicacion: No se pudo crear Compañia."; viewmodel.ControllerName = "CompanyPrepago"; viewmodel.ActionName = "FilterCompany"; } return RedirectToAction("GenericView", viewmodel); }