コード例 #1
0
 public ActionResult Delete(int id)
 {
     using (agriviDBEntities db = new agriviDBEntities())
     {
         Spojevi compound = db.Spojevi.Where(x => x.idSpoja == id).FirstOrDefault <Spojevi>();
         db.Spojevi.Remove(compound);
         db.SaveChanges();
         return(Json(new { succes = true, message = "Deleted!", JsonRequestBehavior.AllowGet }));
     }
 }
コード例 #2
0
 public ActionResult AddOrEdit(Spojevi compound)
 {
     using (agriviDBEntities db = new agriviDBEntities())
     {
         if (compound.idSpoja == 0)
         {
             List <Spojevi> list = db.Spojevi.ToList <Spojevi>();
             if (list.Count > 0)
             {
                 compound.idSpoja = list.Last().idSpoja + 1;
             }
             db.Spojevi.Add(compound);
             db.SaveChanges();
             return(Json(new { success = true, message = "Added!", JsonRequestBehavior.AllowGet }));
         }
         else
         {
             db.Entry(compound).State = EntityState.Modified;
             db.SaveChanges();
             return(Json(new { success = true, message = "Updated!", JsonRequestBehavior.AllowGet }));
         }
     }
 }