public ActionResult Edit(Content content) { if (ModelState.IsValid) { //Xử lý MetaTitle, sau đó update content đã được xử lý vào database if (!string.IsNullOrEmpty(content.Name)) { content.MetaTitle = StringHelper.ToUnsignString(content.Name); } var result = new ContentDao().Update(content); //Xử lý bảng Tag, ContentTag var contentTagDao = new ContentTagDao(); contentTagDao.RemoveAllContentTag(content.ID); if (!string.IsNullOrEmpty(content.Tags)) { string[] tags = content.Tags.Split(','); foreach (var tag in tags) { var tagId = StringHelper.ToUnsignString(tag); var tagDao = new TagDao(); var existedTag = tagDao.CheckTag(tagId); //insert vào bảng Tag trong database if (!existedTag) { tagDao.Insert(tagId, tag); } //insert vào bảng ContentTag contentTagDao.Insert(content.ID, tagId); } } if (result) { SetAlert("Edit this content successfully.", "success"); } else { ModelState.AddModelError("", "Edit this content failed."); } } SetContentCategoryIDViewBag(content.ContentCategoryID); return(View(content)); }