public ActionResult GetData()
 {
     using (DBModelll db = new DBModelll())
     {
         List <Product> empList = db.Products.ToList <Product>();
         return(Json(new { data = empList }, JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult Delete(int id)
 {
     using (DBModelll db = new DBModelll())
     {
         Product emp = db.Products.Where(x => x.ProductID == id).FirstOrDefault <Product>();
         db.Products.Remove(emp);
         db.SaveChanges();
         return(Json(new { success = true, message = "Ürün Başarıyla Silindi" }, JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult Add(int id = 0)
 {
     if (id == 0)
     {
         return(View(new Product()));
     }
     else
     {
         using (DBModelll db = new DBModelll())
         {
             return(View(db.Products.Where(x => x.ProductID == id).FirstOrDefault <Product>()));
         }
     }
 }
 public ActionResult AddOrEdit(Product emp)
 {
     using (DBModelll db = new DBModelll())
     {
         if (emp.ProductID == 0)
         {
             db.Products.Add(emp);
             db.SaveChanges();
             return(Json(new { success = true, message = "Başarıyla Kaydedildi" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             db.Entry(emp).State = EntityState.Modified;
             db.SaveChanges();
             return(Json(new { success = true, message = "Başarıyla Güncellendi" }, JsonRequestBehavior.AllowGet));
         }
     }
 }