Ejemplo n.º 1
0
        public ActionResult Category(int?_parentId)
        {
            string cookieLanguage = "1";

            if (Request.Cookies["cookieLanguage"] != null)
            {
                cookieLanguage = Request.Cookies["cookieLanguage"].Value.ToString();
            }
            int.TryParse(cookieLanguage, out int _languageId);
            var result = _services.GetCategoryAdmin(_parentId, "cdisanvanhoa", _languageId, false);
            IEnumerable <DropdownModel> category = _services.Dropdownlist(0, null, "cdisanvanhoa", _languageId);

            ViewBag._parentId = category.Select(x => new SelectListItem {
                Text = x.Text, Value = x.Value.ToString()
            });
            if (result != null && result.Count() > 0)
            {
                IEnumerable <modelCategories> model = result.Select(x => new modelCategories
                {
                    Alias           = x.contentAlias,
                    Id              = x.contentId,
                    Img             = x.contentThumbnail,
                    LanguageId      = x.languageId,
                    LanguageName    = _languageService.GetNameById(x.languageId),
                    MetaDescription = x.contentDescription,
                    MetaKeywords    = x.contentKeywords,
                    MetaTitle       = x.contentTitle,
                    Name            = x.contentName,
                    Note            = x.note,
                    ParentId        = x.parentId,
                    ParentName      = _services.GetNameById(x.parentId)
                });
                return(View(model));
            }
            else
            {
                List <modelCategories> model = new List <modelCategories>();
                return(View(model));
            }
        }