Esempio n. 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);
         }
     }
 }
Esempio n. 2
0
 public ActionResult GetData()
 {
     using (ZadatakDBEntities db = new ZadatakDBEntities())
     {
         List <Proizvod> proizList = db.Proizvods.ToList();
         return(Json(new { data = proizList }, JsonRequestBehavior.AllowGet));
     }
 }
Esempio n. 3
0
 public ActionResult Delete(int id)
 {
     using (ZadatakDBEntities db = new ZadatakDBEntities())
     {
         Proizvod proiz = db.Proizvods.Where(x => x.id == id).FirstOrDefault();
         db.Proizvods.Remove(proiz);
         db.SaveChanges();
         return(Json(new { success = true, message = "Deleted Successfully" }, JsonRequestBehavior.AllowGet));
     }
 }
Esempio n. 4
0
 public ActionResult AddOrEdit(int id = 0)
 {
     if (id == 0)
     {
         return(View(new Proizvod()));
     }
     else
     {
         using (ZadatakDBEntities db = new ZadatakDBEntities())
         {
             return(View(db.Proizvods.Where(x => x.id == id).FirstOrDefault()));
         }
     }
 }
Esempio n. 5
0
 public static Proizvod AddOrEdit(int id)
 {
     if (id == 0)
     {
         return(new Proizvod());
     }
     else
     {
         using (ZadatakDBEntities db = new ZadatakDBEntities())
         {
             return(db.Proizvods.Where(x => x.id == id).FirstOrDefault());
         }
     }
 }
Esempio n. 6
0
 public static List <Proizvod> GetData()
 {
     try
     {
         using (ZadatakDBEntities db = new ZadatakDBEntities())
         {
             proizList = db.Proizvods.ToList();
             return(proizList);
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.Message);
         return(null);
     }
 }
Esempio n. 7
0
 public static string Delete(int id)
 {
     using (ZadatakDBEntities db = new ZadatakDBEntities())
     {
         try
         {
             Proizvod proiz = db.Proizvods.Where(x => x.id == id).FirstOrDefault();
             db.Proizvods.Remove(proiz);
             db.SaveChanges();
             return("Deleted Successfully");
         }
         catch (Exception ex)
         {
             return(ex.Message);
         }
     }
 }
Esempio n. 8
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));
         }
     }
 }