public ActionResult Addnew(ThemTinTucModel model) { if (ModelState.IsValid) { DetailMenu tintuc = new DetailMenu() { sDate = DateTime.Now, Name = RejectMarks(model.Name), Note = model.Note, Img = (model.Img).Replace("/files/", ""), 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 = false, ShowIconNew = false, TinhTrangSP = false, SEODescription = model.SEODescription, SEOtitle = model.SEOtitle }; _detailMenuRepository.Add(tintuc); _unitOfWork.Commit(); } else { return(View("Create", model)); } return(RedirectToAction("Index")); }
public ActionResult AddNew(DetailMenu model) { model.Name = model.Name; model.Img = model.Img; model.Link = model.Link; model.id_Menu = 1462; model.Ma_Hang = ""; model.NameAdwords = ""; model.ok = true; model.Number = 0; model.ShowMenu = true; model.ShowKhuyenMai = false; model.ShowIconHot = false; model.ShowIconNew = false; model.TinhTrangSP = false; model.idUser = 15; model.idUserOk = 15; model.sDate = DateTime.Now; model.sDateOk = DateTime.Now; model.SEODescription = model.SEODescription; _detailMenuRepository.Add(model); _unitOfWork.Commit(); return(RedirectToAction("TinBaoChi", "TinTuc")); }
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")); }