Example #1
0
 public ActionResult Edit(PS_Situacao_Sac 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_situacao }) : RedirectToAction("List"));
         }
         return(View(data));
     }
     else
     {
         try
         {
             PS_Situacao_Sac dataDelete = db.PS_Situacao_Sac.Find(data.cod_situacao);
             db.PS_Situacao_Sac.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_situacao }));
         }
         return(RedirectToAction("List"));
     }
 }
Example #2
0
      //
      // GET: /TipoLead/Edit/5
      public ActionResult Edit(int id)
      {
          PS_Situacao_Sac data = db.PS_Situacao_Sac.Find(id);

          if (data == null)
          {
              return(InvokeHttpNotFound());
          }
          return(View(data));
      }
Example #3
0
 public ActionResult Create(PS_Situacao_Sac data, bool continueAdd, FormCollection form)
 {
     ModelState.Clear();
     data.cod_situacao = db.Database.SqlQuery <Int32>("select PS_Situacao_Sac_Seq.NextVal from dual ").FirstOrDefault <Int32>();
     TryValidateModel(data);
     if (ModelState.IsValid)
     {
         db.PS_Situacao_Sac.Add(data);
         db.SaveChanges();
         return(continueAdd ? RedirectToAction("Create") : RedirectToAction("List"));
     }
     return(View(data));
 }