Beispiel #1
0
        public ActionResult AddAction(Category c)
        {
            CategoryDao cDao = new CategoryDao();

            cDao.InsertCategory(c.Name, c.Position, c.Descriptions, c.Actives);
            return(RedirectToAction("List"));
        }
Beispiel #2
0
 public ActionResult Create(Category category)
 {
     if (!String.IsNullOrWhiteSpace(category.Name))
     {
         var categories = new CategoryDao().GetCategoryByName(category.Name);
         if (categories != null)
         {
             ModelState.AddModelError("", "Name Category is already registered");
         }
     }
     if (ModelState.IsValid)
     {
         var  dao = new CategoryDao();
         long id  = dao.InsertCategory(category);
         if (id > 0)
         {
             SetNotification("Thêm mới danh mục thành công .", "success");
             return(RedirectToAction("Index", "Category"));
         }
         else
         {
             ModelState.AddModelError("", "Thêm mới danh mục không thành công .");
         }
     }
     SetViewBag();
     return(View());
 }
Beispiel #3
0
        public ActionResult Create(Category cate)
        {
            var dao = new CategoryDao();
            int id  = dao.InsertCategory(cate);

            if (id > 0)
            {
                return(RedirectToAction("Index", "Category"));
            }
            else
            {
                ModelState.AddModelError("", "Them khong thanh cong");
            }
            return(View("Index", "Home"));
        }
Beispiel #4
0
        private static void DoCategoryjson(List <Category> listCategory, JObject jObjectData)
        {
            if (jObjectData.ContainsKey("category")) //处理dm
            {
                JArray jObjectCate = (JArray)jObjectData["category"];
                foreach (JToken jToken in jObjectCate.Children())
                {
                    Category category = new Category();
                    category.category_id = int.Parse(jToken["category_id"].ToString());
                    category.name        = jToken["name"].ToString();

                    Category oldCategory = CategoryDao.GetCategoryBycatId(category.category_id);
                    if (oldCategory == null)
                    {
                        CategoryDao.InsertCategory(category);
                        listCategory.Add(category);
                    }
                }
            }
        }
Beispiel #5
0
 /// <summary>
 /// InsertCategory - them thông tin category
 /// </summary>
 /// <param name="category"></param>
 /// <returns></returns>
 public bool InsertCategory(Category category)
 {
     return(categoryDao.InsertCategory(category));
 }