public ActionResult CapNhat(ModelChuyenMuc model) { if (ModelState.IsValid) { Content entity = _services.GetById((int)model.Id); entity.contentAlias = model.Link; entity.contentDescription = model.Note; entity.contentThumbnail = model.Thumbnail; entity.contentMetaTitle = model.MetaTitle; entity.contentUpdateTime = DateTime.Now; entity.contentParentId = model.ParentId; entity.contentMetaDescription = model.MetaDescription; entity.contentName = model.Name; entity.isSort = model.Isort; entity.contentMetaKeywords = model.MetaKeywords; entity.contentUpdateUser = User.Identity.Name; _services.Update(entity); _services.Save(); return(RedirectToAction("Index", new { _parentId = entity.contentParentId })); } IEnumerable <DropdownModel> category = _services.Dropdownlist(0, (int)model.Id, "CHUYENMUCTINTUC", 1); ViewBag.ParentId = category.Select(x => new SelectListItem { Text = x.Text, Value = x.Value.ToString() }); return(View(model)); }
public ActionResult CapNhat(int Id) { if (Id > 0) { var entity = _services.GetById(Id); var model = new ModelChuyenMuc { Id = entity.contentId, Link = entity.contentAlias, MetaDescription = entity.contentMetaDescription, MetaKeywords = entity.contentMetaKeywords, MetaTitle = entity.contentMetaTitle, Name = entity.contentName, Note = entity.contentDescription, Isort = entity.isSort, ParentId = entity.contentParentId, Thumbnail = entity.contentThumbnail }; IEnumerable <DropdownModel> category = _services.Dropdownlist(0, (int)model.Id, "CHUYENMUCTINTUC", 1); ViewBag.ParentId = category.Select(x => new SelectListItem { Text = x.Text, Value = x.Value.ToString() }); return(View(model)); } else { return(View()); } }
public ActionResult DetailCategory(ModelChuyenMuc entity) { if (ModelState.IsValid) { if (entity.Id > 0) { Content model = _services.GetById((int)entity.Id); model.contentAlias = entity.Link; model.contentDescription = entity.Note; model.contentThumbnail = entity.Thumbnail; model.contentMetaTitle = entity.MetaTitle; model.contentUpdateTime = DateTime.Now; model.contentParentId = entity.ParentId; model.contentMetaDescription = entity.MetaDescription; model.contentName = entity.Name; model.isSort = entity.Isort; model.contentMetaKeywords = entity.MetaKeywords; model.contentUpdateUser = User.Identity.Name; _services.Update(model); _services.Save(); } else { Content model = new Content { contentAlias = entity.Link, contentDescription = entity.Note, contentThumbnail = entity.Thumbnail, contentMetaTitle = entity.MetaTitle, contentUpdateTime = DateTime.Now, contentParentId = entity.ParentId, contentMetaDescription = entity.MetaDescription, contentName = entity.Name, contentCreateTime = DateTime.Now, isSort = entity.Isort, isTrash = false, contentView = 0, contentLanguageId = 1, contentKey = "CHUYENMUCMEDIA", contentCreateUser = User.Identity.Name, contentMetaKeywords = entity.MetaKeywords, contentUpdateUser = User.Identity.Name }; _services.Add(model); _services.Save(); model.contentAlias = model.contentAlias + "-" + model.contentId; _services.Update(model); _services.Save(); } return(RedirectToAction("Category", new { _parentId = entity.ParentId })); } IEnumerable <DropdownModel> category = _services.Dropdownlist(0, (int)entity.Id, "CHUYENMUCMEDIA", 1); ViewBag.ParentId = category.Select(x => new SelectListItem { Text = x.Text, Value = x.Value.ToString() }); return(View(entity)); }
public ActionResult ThemMoi() { IEnumerable <DropdownModel> category = _services.Dropdownlist(0, null, "CHUYENMUCTINTUC", 1); ViewBag.ParentId = category.Select(x => new SelectListItem { Text = x.Text, Value = x.Value.ToString() }); ModelChuyenMuc model = new ModelChuyenMuc { Id = 0 }; return(View(model)); }
public ActionResult ThemMoi(ModelChuyenMuc model) { if (ModelState.IsValid) { Content entity = new Content { contentAlias = model.Link, contentDescription = model.Note, contentThumbnail = model.Thumbnail, contentMetaTitle = model.MetaTitle, contentUpdateTime = DateTime.Now, contentParentId = model.ParentId, contentMetaDescription = model.MetaDescription, contentName = model.Name, contentCreateTime = DateTime.Now, isSort = model.Isort, isTrash = false, contentView = 0, contentLanguageId = 1, contentKey = "CHUYENMUCTINTUC", contentCreateUser = User.Identity.Name, contentMetaKeywords = model.MetaKeywords, contentUpdateUser = User.Identity.Name }; _services.Add(entity); _services.Save(); entity.contentAlias = entity.contentAlias + "-" + entity.contentId; _services.Update(entity); _services.Save(); return(RedirectToAction("Index", new { _parentId = entity.contentParentId })); } IEnumerable <DropdownModel> category = _services.Dropdownlist(0, (int)model.Id, "CHUYENMUCTINTUC", 1); ViewBag.ParentId = category.Select(x => new SelectListItem { Text = x.Text, Value = x.Value.ToString() }); return(View(model)); }
public ActionResult DetailCategory(int?Id, int?ParentId) { ModelChuyenMuc entity; if (Id.HasValue && Id > 0) { Content model = _services.GetById(Id.Value); entity = new ModelChuyenMuc { Id = model.contentId, Link = model.contentAlias, MetaDescription = model.contentMetaDescription, MetaKeywords = model.contentMetaKeywords, MetaTitle = model.contentMetaTitle, Isort = model.isSort, Name = model.contentName, Note = model.contentDescription, ParentId = model.contentParentId, Thumbnail = model.contentThumbnail }; ViewBag.Title = "Cập nhật chuyên mục media"; } else { entity = new ModelChuyenMuc { Id = 0, ParentId = ParentId }; ViewBag.Title = "Thêm mới chuyên mục media"; } IEnumerable <DropdownModel> category = _services.Dropdownlist(0, (int)entity.Id, "CHUYENMUCMEDIA", 1); ViewBag.ParentId = category.Select(x => new SelectListItem { Text = x.Text, Value = x.Value.ToString() }); return(View(entity)); }