Example #1
0
 public ActionResult UpdateCategorys(CategorysPost category)
 {
     using (DataContext db = new DataContext())
     {
         Category c = db.Categories.Where(x => x.Category_ID == category.category_id).FirstOrDefault();
         if (c != null)
         {
             c.categoryName        = category.categoryTV;
             c.categoryNameForeign = category.categoryTA;
             c.theme_id            = category.theme_id;
             db.SaveChanges();
             return(Json(new { mess_ = 1 }));
         }
         return(Json(new { mess_ = 0 }));
     }
 }
Example #2
0
 public ActionResult AddCategorys(CategorysPost category)
 {
     using (DataContext db = new DataContext())
     {
         ViewBag.GetThemes = (from t in db.Themes select t).ToList();
         if (ModelState.IsValid)
         {
             Category c = new Category();
             c.theme_id            = category.theme_id;
             c.categoryName        = category.categoryTV;
             c.categoryNameForeign = category.categoryTA;
             db.Categories.Add(c);
             db.SaveChanges();
             return(Json(new { mess_ = 1 }));
         }
         else
         {
             return(Json(new { mess_ = 0 }));
         }
     }
 }