public ActionResult Addnew(ReviewModel model) { //if (ModelState.IsValid) //{ Review tintuc = new Review() { Sdate = DateTime.Now, TieuDe = RejectMarks(model.TieuDe), Mota = model.Mota, HinhAnh = (model.HinhAnh).Replace("/files/", ""), ChiTiet = ChangeImageSEO(model.ChiTiet, model.TieuDe, ConvertFont(model.TieuDe)), //ChiTiet = model.ChiTiet, Ok = false, Sapxep = model.Sapxep, Link = ConvertFont(model.TieuDe), SEODescription = model.SEODescription, SEOtitle = model.SEOtitle, NguoiTao = User.Identity.Name }; _reviewRepository.Add(tintuc); _unitOfWork.Commit(); if (model.mySingleField != null) { #region thêm mới tag string[] separators = { "," }; var taglist = model.mySingleField.Split(separators, StringSplitOptions.RemoveEmptyEntries); //check null: nếu tồn tại thêm mới bình thường if (taglist.Any()) { foreach (var tag in taglist) { TagTinTuc _tag = new TagTinTuc() { NgayTao = DateTime.Now, IdMenu = tintuc.id_, // id cua tin moi vua them TenTag = tag.Trim(), Link = ConvertFont(tag.Trim()), Code = RejectMarks(tag.Trim()) }; _tagTinTucRepository.Add(_tag); _unitOfWork.Commit(); } } #endregion } //} //else //{ // return View("Create", model); //} return(RedirectToAction("Index")); }
public ActionResult Addnew(ThemTinTucModel model) { //if (ModelState.IsValid) //{ #region them moi tin tuc DetailMenu tintuc = new DetailMenu() { sDate = DateTime.Now, Name = RejectMarks(model.Name), Note = model.Note, Img = (model.Img).Replace("/files/", ""), Content = ChangeImageSEO(model.Content, model.Name, ConvertFont(model.Name)), //Content = model.Content, id_Menu = 20, Link = ConvertFont(model.Name), idUser = 15, idUserOk = 15, sDateOk = DateTime.Now, ok = true, Ma_Hang = "", NameAdwords = "", Number = 0, ShowMenu = true, ShowIconHot = false, ShowKhuyenMai = true, ShowIconNew = false, TinhTrangSP = false, sPosition = model.sPosition, SEODescription = model.SEODescription, SEOtitle = model.SEOtitle, CodeName = ConvertFont(model.Name).Replace("-", " "), IdSalePage = model.IdSalePage, NguoiTao = User.Identity.Name }; _detailMenuRepository.Add(tintuc); _unitOfWork.Commit(); #endregion if (model.mySingleField != null) { #region them moi tag string[] separators = { "," }; var taglist = model.mySingleField.Split(separators, StringSplitOptions.RemoveEmptyEntries); //check null: nếu tồn tại thêm mới bình thường if (taglist.Any()) { foreach (var tag in taglist) { TagTinTuc _tag = new TagTinTuc() { NgayTao = DateTime.Now, IdMenu = tintuc.id_, // id cua tin moi vua them TenTag = tag.Trim(), Link = ConvertFont(tag.Trim()), Code = RejectMarks(tag.Trim()) }; _tagTinTucRepository.Add(_tag); _unitOfWork.Commit(); } } #endregion } //} //else //{ // return View("Create", model); //} return(RedirectToAction("Index")); }