コード例 #1
0
 public static string AddOrEdit(Proizvod proiz)
 {
     using (ZadatakDBEntities db = new ZadatakDBEntities())
     {
         try
         {
             if (proiz.id == 0)
             {
                 db.Proizvods.Add(proiz);
                 db.SaveChanges();
                 return("Saved Successfully");
             }
             else
             {
                 db.Entry(proiz).State = EntityState.Modified;
                 db.SaveChanges();
                 return("Updated Successfully");
             }
         }
         catch (Exception ex)
         {
             return(ex.Message);
         }
     }
 }
コード例 #2
0
 public ActionResult AddOrEdit(Proizvod proiz)
 {
     using (ZadatakDBEntities db = new ZadatakDBEntities())
     {
         if (proiz.id == 0)
         {
             db.Proizvods.Add(proiz);
             db.SaveChanges();
             return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             db.Entry(proiz).State = EntityState.Modified;
             db.SaveChanges();
             return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet));
         }
     }
 }