public ActionResult Deleprod(int id) { using (FinaEntities db = new FinaEntities()) { db.Products.Remove(db.Products.FirstOrDefault(x => x.ID == id)); db.SaveChanges(); } return(RedirectToAction("Index")); }
public JsonResult DeletCategory(int id) { using (FinaEntities db = new FinaEntities()) { db.Products.RemoveRange(db.Products.Where(x => x.CategoryId == id)); db.categories.Remove(db.categories.FirstOrDefault(x => x.ID == id)); db.SaveChanges(); return(Json(new { success = true, result = "saved", }, JsonRequestBehavior.AllowGet)); } }
public JsonResult Delete(string id) { int a = Convert.ToInt32(id); using (FinaEntities db = new FinaEntities()) { db.categories.RemoveRange(db.categories.Where(x => x.GrupID == a)); db.Grups.Remove(db.Grups.FirstOrDefault(x => x.ID == a)); db.SaveChanges(); return(Json(new { success = true, result = "saved", }, JsonRequestBehavior.AllowGet)); } }
public JsonResult AddCategory(string id, string name) { var intid = Convert.ToInt32(id); using (FinaEntities db = new FinaEntities()) { db.categories.Add(new category() { categoryName = name, GrupID = intid, }); db.SaveChanges(); } return(Json(new { success = true, result = "saved", name }, JsonRequestBehavior.AllowGet)); }
public ActionResult Editproducticon(ProsuctListmodel pr) { using (FinaEntities db = new FinaEntities()) { var dp = db.Products.FirstOrDefault(x => x.ID == pr.ID); dp.Name = pr.Name; dp.Price = pr.Price; dp.startDate = pr.StartDate; dp.country = pr.Country; dp.CompletionDate = pr.CompletionDate; dp.Code = pr.Code; db.SaveChanges(); } return(RedirectToAction("index")); }
public ActionResult Addproduct(ProductModel product) { var intid = Convert.ToInt32(product.CategoryId); using (FinaEntities db = new FinaEntities()) { _ = db.Products.Add(new Product() { Name = product.Name, CategoryId = intid, Code = product.Code, country = product.Country, Price = product.Price, startDate = product.StartDate, CompletionDate = product.CompletionDate }); db.SaveChanges(); } return(RedirectToAction("index")); }
public JsonResult AddGrup(string name) { if (name == null) { string error = "ველი ცარიელია"; return(Json(new { success = false, result = "nosaved", error })); } else { using (FinaEntities db = new FinaEntities()) { db.Grups.Add(new Grup() { Name = name, }); db.SaveChanges(); } return(Json(new { success = true, result = "saved", name })); } }