Пример #1
0
 public bool Add(ProductCategory category)
 {
     try
     {
         db.ProductCategories.Add(category);
         db.SaveChanges();
         return true;
     }
     catch
     {
         return false;
     }
 }
 public ActionResult Edit(int id, ProductCategory Object, string ParentName)
 {
     try
     {
         if (ParentName == "Khong Co")
             Object.ParentID = 0;
         Object.EditBy = new Shop.Models.DataModel.AdminModels().GetIdByUserName(Session[Shop.Models.SupportModel.SessionKey.LogIn] as string);
         Object.EditDate = DateTime.Now;
         bool check = new ProductCategoryModels().UpDate(id,Object);
         if (check)
             return RedirectToAction("Index");
         else
             return View();
     }
     catch
     {
         return View();
     }
 }
Пример #3
0
 public bool UpDate(int id,ProductCategory category)
 {
     try
     {
         var Object = db.ProductCategories.Find(id);
         Object.Name = category.Name;
         Object.OrderDisplay = category.OrderDisplay;
         Object.ParentID = category.OrderDisplay;
         Object.State = category.State;
         Object.Title = category.Title;
         Object.EditBy = category.EditBy;
         Object.EditDate = DateTime.Now;
         db.SaveChanges();
         return true;
     }
     catch
     {
         return false;
     }
 }