示例#1
0
        public ActionResult Edit(long id)
        {
            var contentCategory = new ContentCategoryDao().GetByID(id);

            SetParentIDViewBag(contentCategory.ParentID);
            return(View(contentCategory));
        }
示例#2
0
 //[HasCredential(RoleID = "ADD_USER")]
 public ActionResult Create(ContentCategory contentCategory)
 {
     if (ModelState.IsValid)
     {
         var dao = new ContentCategoryDao();
         var a   = new ContentCategory();
         a.Name       = contentCategory.Name;
         a.CreateDate = Convert.ToDateTime(DateTime.UtcNow.ToLocalTime());
         a.MetaTitle  = StringHelper.ToUnsignString(a.Name);
         a.Status     = Convert.ToBoolean(true);
         var id = dao.Insert(a);
         if (id > 0)
         {
             SetAlert("Thêm thành công", "success");
             ViewBag.Success = "Thêm thành công";
             contentCategory = new ContentCategory();
             return(RedirectToAction("Index", "ContentCategory"));
         }
         else
         {
             ModelState.AddModelError("", "Thêm user ko thành công");
         }
     }
     return(View(contentCategory));
 }
示例#3
0
        public ActionResult Create(ContentCategory contentCategory)
        {
            if (ModelState.IsValid)
            {
                //Xử lý MetaTitle
                if (!string.IsNullOrEmpty(contentCategory.Name))
                {
                    contentCategory.MetaTitle = StringHelper.ToUnsignString(contentCategory.Name);
                }

                var  dao = new ContentCategoryDao();
                long id  = dao.Insert(contentCategory);
                if (id > 0)
                {
                    SetAlert("Create a new content category successfully.", "success");
                    return(RedirectToAction("Index", "ContentCategory"));
                }
                else
                {
                    ModelState.AddModelError("", "Create a new Content category failed.");
                    return(RedirectToAction("Create", "ContentCategory"));
                }
            }
            SetParentIDViewBag();
            return(View(contentCategory));
        }
示例#4
0
        public ActionResult Index()
        {
            var dao   = new ContentCategoryDao();
            var model = dao.ListAllContentCategory();

            return(View(model));
        }
示例#5
0
        /// <summary>
        /// để hiện thị tên danh mục sản phẩm và danh mục đang chọn
        /// </summary>
        /// <param name="selectedID"></param>
        public void setViewBag(long?selectedID = null)
        {
            var dao = new ContentCategoryDao();

            //để thay giá trị id bằng name , selectId dùng để lấy vị trí đang chọn
            ViewBag.ContentCategoryID = new SelectList(dao.GetAllContentCategory(), "ID", "Name", selectedID);
        }
示例#6
0
        ////Display, create, edit, delete ContentCategory
        //Index page of ContentCategory management
        public ActionResult Index(string searchString, int page = 1, int pageSize = 10)
        {
            var dao   = new ContentCategoryDao();
            var model = dao.ListAllPaging(searchString, page, pageSize);

            ViewBag.SearchString = searchString;
            ViewBag.PageSize     = pageSize;
            return(View(model));
        }
示例#7
0
        public ActionResult ContentCategory(long cateid, int page = 1 /*, int pageSize = 2*/)
        {
            var contentcategory = new ContentCategoryDao().ViewDetail(cateid);

            ViewBag.ContentCategory = contentcategory;

            var model = new ContentDao().ListContentByContentCategoryId(cateid);


            return(View(model.ToPagedList(page, 8)));
        }
示例#8
0
        public ActionResult Category(long id, int?page)
        {
            var contentCategory = new ContentCategoryDao().ViewDetail(id);
            int pageSize        = 10;
            int pageNumber      = (page ?? 1);

            ViewBag.metaTitle = contentCategory.MetaTitle;
            ViewBag.id        = contentCategory.ID;
            ViewBag.name      = contentCategory.Name;
            var model = db.GetAllContentCategory(id);

            return(View(model.ToPagedList(pageNumber, pageSize)));
        }
示例#9
0
        public JsonResult DeleteSelected(string ids)
        {
            var  model = new ContentCategoryDao();
            var  lstID = ids.Split(',');
            bool res   = true;

            foreach (var id in lstID)
            {
                long cv = Convert.ToInt64(id);
                res = model.ChangeStatus(cv);
            }
            return(Json(new
            {
                status = res
            }));
        }
示例#10
0
        public ActionResult ContentCategory(long cateid, int page = 1 /*, int pageSize = 2*/)
        {
            var contentcategory = new ContentCategoryDao().ViewDetail(cateid);

            ViewBag.ContentCategory = contentcategory;
            ViewBag.Cate            = new ContentCategoryDao().ListAllContentCategory();
            var model = new ContentDao().ListContentByContentCategoryId(cateid);
            //--
            var mContent = new ContentCategoryDao().ViewDetail(cateid);

            ViewBag.Mcontent = mContent;


            var abc = new ContentDao();

            ViewBag.Content = abc.ListContent(5);
            var cont = new ContentCategoryDao().GetByID(cateid);

            ViewBag.Cont = cont;
            //--
            return(View(model.ToPagedList(page, 8)));
        }
示例#11
0
        public ActionResult Edit(ContentCategory contentCategory)
        {
            if (ModelState.IsValid)
            {
                if (!string.IsNullOrEmpty(contentCategory.Name))
                {
                    contentCategory.MetaTitle = StringHelper.ToUnsignString(contentCategory.Name);
                }

                var result = new ContentCategoryDao().Update(contentCategory);
                if (result)
                {
                    SetAlert("Edit this content category successfully.", "success");
                }
                else
                {
                    ModelState.AddModelError("", "Edit this content category failed.");
                }
            }
            SetParentIDViewBag(contentCategory.ParentID);
            return(View(contentCategory));
        }
 public ActionResult Create(ContentCategory contentCategory)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var dao = new ContentCategoryDao();
             contentCategory.Name       = contentCategory.Name;
             contentCategory.MetaTitle  = contentCategory.MetaTitle;
             contentCategory.CreateDate = Convert.ToDateTime(DateTime.UtcNow.ToLocalTime());
             contentCategory.Status     = Convert.ToBoolean(true);
             contentCategory.ParentID   = contentCategory.ParentID;
             contentCategory.SeoTitle   = contentCategory.SeoTitle;
             var id = dao.Insert(contentCategory);
             if (id > 0)
             {
                 SetAlert("Thêm mới thành thành công", "success");
                 ViewBag.Success = "Thêm thành công";
                 contentCategory = new ContentCategory();
                 return(RedirectToAction("Index", "Content"));
             }
             else
             {
                 ModelState.AddModelError("", "Thêm mới ko thành công");
             }
         }
     }
     catch (DbEntityValidationException e)
     {
         throw e;
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(View(contentCategory));
 }
示例#13
0
 public ActionResult Edit([Bind(Include = "ID,Name,MetaTitle,CreateDate,Status")] ContentCategory model)
 {
     if (ModelState.IsValid)
     {
         var dao = new ContentCategoryDao();
         var a   = new ContentCategory();
         model.Name      = model.Name;
         model.MetaTitle = StringHelper.ToUnsignString(model.Name);
         model.Status    = Convert.ToBoolean(true);
         var result = dao.Update(model);
         if (result)
         {
             SetAlert("Sửa thành công", "success");
             ViewBag.Success = "Cập nhật thành công";
             model           = new ContentCategory();
             return(RedirectToAction("Index", "ContentCategory"));
         }
         else
         {
             ModelState.AddModelError("", "Cập nhật ko thành công");
         }
     }
     return(View());
 }
        ////Other methods
        //Set ViewBag for ContentCategoryID options
        public void SetContentCategoryIDViewBag(long?selectedId = null)
        {
            var dao = new ContentCategoryDao();

            ViewBag.ContentCategoryID = new SelectList(dao.ListAll(), "ID", "Name");
        }
示例#15
0
        public ActionResult CategoryContent()
        {
            var listCategory = new ContentCategoryDao().GetAll("");

            return(PartialView(listCategory));
        }
示例#16
0
        public ActionResult Edit(int id)
        {
            var contentCategory = new ContentCategoryDao().ViewDetail(id);

            return(View(contentCategory));
        }