Exemplo n.º 1
0
 public ActionResult Create(Category cate)
 {
     if (ModelState.IsValid)
     {
         var dao = new CategoryDAO();
         cate.MetaTitle = ConvertToUnSign.utf8Convert(cate.CategoryName);
         long id = dao.Insert(cate);
         if (id > 0)
         {
             return(RedirectToAction("Index", "Category"));
         }
         else
         {
             ModelState.AddModelError("", "Thêm không thành công");
         }
     }
     return(View(cate));
 }
Exemplo n.º 2
0
        public ActionResult Create(Post post)
        {
            if (ModelState.IsValid)
            {
                var dao = new PostDAO();
                post.MetaTitle      = ConvertToUnSign.utf8Convert(post.Title);
                post.DatetimeCreate = DateTime.Now;

                long id = dao.Insert(post);
                if (id > 0)
                {
                    return(RedirectToAction("Index", "Post"));
                }
                else
                {
                    ModelState.AddModelError("", "Thêm không thành công");
                }
            }
            SetViewBag();
            return(View(post));
        }
Exemplo n.º 3
0
        public ActionResult Edit(Category cate)
        {
            if (ModelState.IsValid)
            {
                var dao = new CategoryDAO();

                // chuyen thanh chuoi khong dau
                // gan cho field Metatile
                cate.MetaTitle = ConvertToUnSign.utf8Convert(cate.CategoryName);

                var result = dao.Update(cate);
                if (result)
                {
                    return(RedirectToAction("Index", "Category"));
                }
                else
                {
                    ModelState.AddModelError("", "Cập nhật không thành công");
                }
            }
            return(View(cate));
        }
Exemplo n.º 4
0
        public ActionResult Edit(Post post)
        {
            if (ModelState.IsValid)
            {
                var dao = new PostDAO();

                // chuyen sang chuoi khong dau
                // gan vao cho metatitle
                post.MetaTitle = ConvertToUnSign.utf8Convert(post.Title);

                var result = dao.Update(post);
                if (result)
                {
                    return(RedirectToAction("Index", "Post"));
                }
                else
                {
                    ModelState.AddModelError("", "Cập nhật không thành công");
                }
            }
            SetViewBag(post.CategoryID);
            return(View(post));
        }