public ActionResult Edit(Ps_Interesse_Lead data, bool continueAdd, bool isDelete) { if (!isDelete) { if (ModelState.IsValid) { db.Entry(data).State = EntityState.Modified; db.SaveChanges(); return(continueAdd ? RedirectToAction("Edit", new { id = data.cod_interesse }) : RedirectToAction("List")); } return(View(data)); } else { try { Ps_Interesse_Lead dataDelete = db.Ps_Interesse_Lead.Find(data.cod_interesse); db.Ps_Interesse_Lead.Remove(dataDelete); db.SaveChanges(); RedirectToAction("List"); } catch (DbEntityValidationException e) { //foreach (var result in e.EntityValidationErrors) // { // foreach (var error in result.ValidationErrors) // { ModelState.AddModelError("", e.Message); //} // } return(RedirectToAction("Edit", new { id = data.cod_interesse })); } return(RedirectToAction("List")); } }
// // GET: /TipoLead/Edit/5 public ActionResult Edit(int id) { Ps_Interesse_Lead data = db.Ps_Interesse_Lead.Find(id); if (data == null) { return(InvokeHttpNotFound()); } return(View(data)); }
public ActionResult Create(Ps_Interesse_Lead data, bool continueAdd, FormCollection form) { ModelState.Clear(); data.cod_interesse = db.Database.SqlQuery <Int32>("select Ps_Interesse_Lead_Seq.NextVal from dual ").FirstOrDefault <Int32>(); TryValidateModel(data); if (ModelState.IsValid) { db.Ps_Interesse_Lead.Add(data); db.SaveChanges(); return(continueAdd ? RedirectToAction("Create") : RedirectToAction("List")); } return(View(data)); }