public virtual ActionResult GameNews_Archive() { INewsPostRepository repo = new EFNewsPostRepository(); var output = repo.NewsPosts.Where(n => n.ViewState == 2).OrderByDescending(n => n.Timestamp);; // 2 == Archived return(View(MVC.Info.Views.GameNews_Archive, output)); }
/// <summary> /// Make changes to an existing or new NewsPost /// </summary> /// <param name="Id">Id of the news post to make changes to. -1 indicates a new post.</param> /// <returns></returns> public virtual ActionResult EditNewsPost(int id = -1) { INewsPostRepository repo = new EFNewsPostRepository(); var output = repo.NewsPosts.FirstOrDefault(f => f.Id == id) ?? new NewsPost(); return(View(MVC.Moderator.Views.EditNewsPost, output)); }
/// <summary> /// Deletes a news post /// </summary> /// <param name="Id"></param> /// <returns></returns> public virtual ActionResult DeleteNewsPost(int Id) { INewsPostRepository repo = new EFNewsPostRepository(); repo.DeleteNewsPost(Id); TempData["Result"] = "News Post " + Id + " deleted successfully!"; return(RedirectToAction(MVC.Moderator.ListNewsPosts())); }
public virtual ActionResult GameNews() { INewsPostRepository repo = new EFNewsPostRepository(); var output = new NewsPageViewModel { NewsPosts = repo.NewsPosts.Where(n => n.ViewState == 1).OrderByDescending(n => n.Timestamp) // 1 == Live }; return(View(MVC.Info.Views.GameNews, output)); }
/// <summary> /// List all of the News posts available for admins to edit /// </summary> /// <returns></returns> public virtual ActionResult ListNewsPosts() { INewsPostRepository repo = new EFNewsPostRepository(); var output = repo.NewsPosts.OrderByDescending(a => a.Timestamp); ViewBag.ErrorMessage = TempData["Error"]; ViewBag.SubErrorMessage = TempData["SubError"]; ViewBag.Result = TempData["Result"]; return(View(MVC.Moderator.Views.ListNewsPosts, output)); }
public virtual ActionResult EditNewsPostSend(NewsPost input) { INewsPostRepository repo = new EFNewsPostRepository(); var saveMe = repo.NewsPosts.FirstOrDefault(f => f.Id == input.Id) ?? new NewsPost(); saveMe.Timestamp = input.Timestamp; saveMe.Text = input.Text; saveMe.ViewState = input.ViewState; repo.SaveNewsPost(saveMe); TempData["Result"] = "News Post " + input.Id + " saved successfully!"; return(RedirectToAction(MVC.Moderator.ListNewsPosts())); }