public ActionResult DeleteNews(News newsToDelete) { libRepo.NewsRepo.Remove(newsToDelete); libRepo.Save(); TempData["SuccessNoti"] = "Delete news successfully."; UpdateLatestNews(); return RedirectToAction("Index"); }
public ActionResult AddNews(News newsToAdd) { if (ModelState.IsValid) { newsToAdd.PostTime = DateTime.Now; libRepo.NewsRepo.Add(newsToAdd); libRepo.Save(); TempData["SuccessNoti"] = "Add news successfully."; UpdateLatestNews(); return RedirectToAction("Index"); } return View(newsToAdd); }
public ActionResult EditNews(News newsToEdit) { if (ModelState.IsValid) { libRepo.NewsRepo.Update(newsToEdit); libRepo.Save(); TempData["SuccessNoti"] = "Edit news successfully."; UpdateLatestNews(); return RedirectToAction("Index"); } return View(newsToEdit); }