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

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