public ActionResult EditCategory(Guid? categoryID)
        {
            if (Request["Delete"] != null)
            {
                if (categoryID.HasValue && !categoryID.Value.Equals(Guid.Empty))
                {
                    _nguyenHiepService.DeleteCategory((Guid)categoryID);
                    return RedirectToAction("IndexForProduct");
                }
            }
            if (categoryID.HasValue && !categoryID.Value.Equals(Guid.Empty))
            {
                tblCategory tblCategory = new tblCategory();
                if (Request.Cookies["Culture"] != null && Request.Cookies["Culture"].Value == "en-US")
                {
                    tblCategory = _nguyenHiepService.GetCategoryByID((Guid)categoryID, true);
                }
                else
                {
                    tblCategory = _nguyenHiepService.GetCategoryByID((Guid)categoryID, false);
                }

                ViewData["NameVN"] = tblCategory.CategoryNameVN;
                ViewData["NameEN"] = tblCategory.CategoryNameVN;
                ViewData["DescriptionVN"] = tblCategory.DescriptionVN;
                ViewData["DescriptionEN"] = tblCategory.DescriptionEN;
                ViewData["command"] = "upload";
                return View(tblCategory);
            }
            else
            {
                ViewData["AddNews"] = true;
                tblCategory tblCategory = new tblCategory();
                return View(tblCategory);
            }
        }
 public void UpdateCategory(tblCategory tblnew)
 {
     _da.UpdateCategory(tblnew);
 }
 public void InsertCategory(tblCategory tblnew)
 {
     _da.InsertCategory(tblnew);
 }
 partial void DeletetblCategory(tblCategory instance);
 partial void UpdatetblCategory(tblCategory instance);
 partial void InserttblCategory(tblCategory instance);
 public void UpdateCategory(tblCategory tblcategory)
 {
     if (tblcategory != null && tblcategory.ID != null && !tblcategory.ID.Equals(Guid.Empty))
     {
         var query = _dataContext.tblCategories.Where("ID.ToString()=@0", tblcategory.ID.ToString());
         if (query != null && query.ToList().Count > 0)
         {
             query.First().CategoryNameVN = tblcategory.CategoryNameVN;
             query.First().CategoryNameEN = tblcategory.CategoryNameEN;
             query.First().DescriptionVN = tblcategory.DescriptionVN;
             query.First().DescriptionEN = tblcategory.DescriptionEN;
             query.First().UpdatedDate = DateTime.Now;
             _dataContext.SubmitChanges();
         }
     }
 }
 public void InsertCategory(tblCategory tblnew)
 {
     if (tblnew != null && tblnew.ID != null && !tblnew.ID.Equals(Guid.Empty))
     {
         tblnew.CreatedDate = DateTime.Now;
         //todo: auto increment catagoryNo
         tblnew.CategoryNo = "1";
         _dataContext.tblCategories.InsertOnSubmit(tblnew);
         _dataContext.SubmitChanges();
     }
 }