public ActionResult DetailCategory(int?Id)
        {
            modelCategories entity;
            string          cookieLanguage = "1";

            if (Request.Cookies["cookieLanguage"] != null)
            {
                cookieLanguage = Request.Cookies["cookieLanguage"].Value.ToString();
            }
            int.TryParse(cookieLanguage, out int _languageId);
            if (Id.HasValue && Id > 0)
            {
                Content model = _services.GetById(Id.Value);
                entity = new modelCategories
                {
                    Id              = model.contentId,
                    Alias           = model.contentAlias,
                    Img             = model.contentThumbnail,
                    LanguageId      = model.languageId,
                    MetaDescription = model.contentDescription,
                    MetaKeywords    = model.contentKeywords,
                    MetaTitle       = model.contentTitle,
                    Name            = model.contentName,
                    Note            = model.note,
                    ParentId        = model.parentId,
                    IsHome          = (model.isHome ?? false)
                };
                if (model.isHome.HasValue)
                {
                    entity.IsHome = model.isHome.Value;
                }
                else
                {
                    entity.IsHome = false;
                }

                entity.No     = model.isSort;
                ViewBag.Title = "Cập nhật chuyên mục ấn phẩm tài liệu";
            }
            else
            {
                entity = new modelCategories
                {
                    LanguageId = _languageId
                };
                ViewBag.Title = "Thêm mới chuyên mục ấn phẩm tài liệu";
            }
            IEnumerable <DropdownModel> category = _services.Dropdownlist(0, entity.Id, "cdisanvanhoa", _languageId);

            ViewBag.ParentId = category.Select(x => new SelectListItem {
                Text = x.Text, Value = x.Value.ToString()
            });
            return(View(entity));
        }
        public ActionResult DetailCategory(int?Id)
        {
            string cookieLanguage = "1";

            if (Request.Cookies["cookieLanguage"] != null)
            {
                cookieLanguage = Request.Cookies["cookieLanguage"].Value.ToString();
            }
            int.TryParse(cookieLanguage, out _languageId);
            modelCategories entity;

            if (Id.HasValue && Id > 0)
            {
                var model = _services.GetById(Id.Value);
                entity                 = new modelCategories();
                entity.Id              = model.contentId;
                entity.Alias           = model.contentAlias;
                entity.Img             = model.contentThumbnail;
                entity.LanguageId      = model.languageId;
                entity.MetaDescription = model.contentDescription;
                entity.MetaKeywords    = model.contentKeywords;
                entity.MetaTitle       = model.contentTitle;
                entity.Name            = model.contentName;
                entity.Note            = model.note;
                entity.ParentId        = model.parentId;
                if (model.isHome.HasValue)
                {
                    entity.IsHome = model.isHome.Value;
                }
                else
                {
                    entity.IsHome = false;
                }
                entity.No     = model.isSort;
                ViewBag.Title = "Cập nhật chuyên mục ấn phẩm tài liệu";
            }
            else
            {
                entity = new modelCategories
                {
                    LanguageId = _languageId
                };
                ViewBag.Title = "Thêm mới chuyên mục ấn phẩm tài liệu";
            }
            var category = _services.Dropdownlist(0, entity.Id, "canphamtailieu", _languageId);

            ViewBag.ParentId = category.Select(x => new SelectListItem {
                Text = x.Text, Value = x.Value.ToString()
            });
            return(View(entity));
        }
        public ActionResult DetailCategory(int?Id)
        {
            modelCategories entity;
            int             _languageId = 1;

            if (Id.HasValue && Id > 0)
            {
                Content model = _services.GetById(Id.Value);
                entity = new modelCategories
                {
                    Id              = model.contentId,
                    Alias           = model.contentAlias,
                    Img             = model.contentThumbnail,
                    LanguageId      = model.languageId,
                    MetaDescription = model.contentDescription,
                    MetaKeywords    = model.contentKeywords,
                    MetaTitle       = model.contentTitle,
                    Name            = model.contentName,
                    Note            = model.note,
                    ParentId        = model.parentId
                };
                if (model.isHome.HasValue)
                {
                    entity.IsHome = model.isHome.Value;
                }
                else
                {
                    entity.IsHome = false;
                }

                entity.No     = model.isSort;
                ViewBag.Title = "Cập nhật chuyên mục thông tin di sản văn hóa";
            }
            else
            {
                entity = new modelCategories
                {
                    LanguageId = _languageId
                };
                ViewBag.Title = "Thêm mới chuyên mục thông tin di sản văn hóa";
            }
            IEnumerable <DropdownModel> category = _services.Dropdownlist(0, entity.Id, "cthongtindisanvanhoa", _languageId);

            ViewBag.ParentId = category.Select(x => new SelectListItem {
                Text = x.Text, Value = x.Value.ToString()
            });
            return(View(entity));
        }
示例#4
0
        public ActionResult DetailCategory(modelCategories entity)
        {
            if (ModelState.IsValid)
            {
                if (entity.Id > 0)
                {
                    Content model = _services.GetById(entity.Id);
                    if (entity.Alias.Contains("-" + entity.Id))
                    {
                        model.contentAlias = entity.Alias;
                    }
                    else
                    {
                        model.contentAlias = entity.Alias + "-" + entity.Id;
                    }
                    model.contentDescription = entity.MetaDescription;
                    model.contentId          = entity.Id;
                    model.contentThumbnail   = entity.Img;
                    model.contentTitle       = entity.MetaTitle;
                    model.updateTime         = DateTime.Now;
                    model.parentId           = entity.ParentId;
                    model.note        = entity.Note;
                    model.isHome      = entity.IsHome;
                    model.contentName = entity.Name;
                    model.isSort      = entity.No.Value;
                    model.isTrash     = false;
                    model.contentKey  = "cnews";
                    model.isSort      = entity.No.GetValueOrDefault();
                    _services.Update(model);
                    _services.Save();
                    _serviceLog.Add(new ActionLog {
                        actionLogStatus = 1, actionLogTime = DateTime.Now, actionLogType = 1, actionNote = "Cập nhật chuyên mục tin tức Id:" + model.contentId + ":" + model.contentName, userIp = "", userName = User.Identity.Name
                    });
                    _serviceLog.Save();
                }
                else
                {
                    Content model = new Content
                    {
                        contentAlias       = entity.Alias,
                        contentDescription = entity.MetaDescription,
                        contentId          = entity.Id,
                        contentThumbnail   = entity.Img,
                        contentTitle       = entity.MetaTitle,
                        updateTime         = DateTime.Now,
                        parentId           = entity.ParentId,
                        note        = entity.Note,
                        contentName = entity.Name,
                        createTime  = DateTime.Now,
                        ngayBanHanh = DateTime.Now,
                        isSort      = entity.No.GetValueOrDefault(),
                        isHome      = entity.IsHome,
                        isTrash     = false,
                        isView      = 0,
                        languageId  = entity.LanguageId,
                        contentKey  = "cnews"
                    };
                    _services.Add(model);
                    _services.Save();
                    model.contentAlias = model.contentAlias + "-" + model.contentId;
                    _services.Update(model);
                    _services.Save();
                    _serviceLog.Add(new ActionLog {
                        actionLogStatus = 1, actionLogTime = DateTime.Now, actionLogType = 1, actionNote = "Thêm mới chuyên mục tin tức Id:" + model.contentId + ":" + model.contentName, userIp = "", userName = User.Identity.Name
                    });
                    _serviceLog.Save();
                }
                return(RedirectToAction("Category", new { _parentId = entity.ParentId }));
            }
            IEnumerable <DropdownModel> category = _services.Dropdownlist(0, entity.Id, "cnews", entity.LanguageId);

            ViewBag.ParentId = category.Select(x => new SelectListItem {
                Text = x.Text, Value = x.Value.ToString()
            });
            return(View(entity));
        }