Example #1
0
 public ActionResult Add(tbl_LoaiSanPhams item)
 {
     using (ModelEntities ctx = new ModelEntities())
     {
         tbl_LoaiSanPhams itemAdd = new tbl_LoaiSanPhams();
         itemAdd.TenLoaiSanPham = item.TenLoaiSanPham;
         itemAdd.DaXoa          = !item.DaXoa;
         ctx.tbl_LoaiSanPhams.Add(itemAdd);
         ctx.SaveChanges();
         return(View());
     }
 }
Example #2
0
 public ActionResult RestoreCat(int?id)
 {
     using (ModelEntities ctx = new ModelEntities())
     {
         tbl_LoaiSanPhams item2 = ctx.tbl_LoaiSanPhams.Where(p => p.LoaiSanPhamID == id).FirstOrDefault();
         if (item2 != null)
         {
             item2.DaXoa = false;
             ctx.SaveChanges();
             return(RedirectToAction("Edit", new { id = id }));
         }
         return(RedirectToAction("Index"));
     }
 }
Example #3
0
 public ActionResult Edit(tbl_LoaiSanPhams item)
 {
     using (ModelEntities ctx = new ModelEntities())
     {
         tbl_LoaiSanPhams item2 = ctx.tbl_LoaiSanPhams.Where(p => p.LoaiSanPhamID == item.LoaiSanPhamID).FirstOrDefault();
         if (item2 != null)
         {
             item2.TenLoaiSanPham = item.TenLoaiSanPham;
             ctx.SaveChanges();
             return(View(item2));
         }
         return(RedirectToAction("Index"));
     }
 }
Example #4
0
 // GET: Admin/Edit
 public ActionResult Edit(int?id)
 {
     if (!id.HasValue)
     {
         return(RedirectToAction("Index"));
     }
     using (ModelEntities ctx = new ModelEntities())
     {
         tbl_LoaiSanPhams item = ctx.tbl_LoaiSanPhams.Where(p => p.LoaiSanPhamID == id.Value).FirstOrDefault();
         if (item != null)
         {
             return(View(item));
         }
         return(RedirectToAction("Index"));
     }
 }