public ActionResult Details(long id) { var model = newRepository.GetNewById(id); if (model != null && model.DanhMucTinTuc.ThuTuHienThi < 1000) { GetViewBagNewCategory(); GetViewBagRecentNew(); GetViewBagRelateNew(model.NewCategoryID); model.LuotXem += 1; newRepository.SaveNew(model); return(View(model)); } if (model != null && model.DanhMucTinTuc.ThuTuHienThi >= 1000) { GetViewBagNewCategory(2); GetViewBagRecentNew(2); GetViewBagRelateNew(model.NewCategoryID, 2); model.LuotXem += 1; newRepository.SaveNew(model); return(View(model)); } else { return(View()); } }
public ActionResult Create(TinTuc model) { if (string.IsNullOrWhiteSpace(model.Ten)) { ModelState.AddModelError("", "Vui lòng nhập tên danh mục"); } if (ModelState.IsValid) { model.NguoiTao = User.Identity.GetUserName(); newRepository.SaveNew(model); return RedirectToAction("Index"); } return View(); }