public void AddNews(News newsToAdd) { newsToAdd.Date = DateTime.Now; news.Add(newsToAdd); WriteJson(); }
public void ChangeNews(News newsToChange) { newsToChange.Date = DateTime.Now; for(int i=0; i < news.Count; i++) { if (news[i].Id == newsToChange.Id) news[i] = newsToChange; } WriteJson(); }
public void DeleteNews(Guid id) { News[] newContext = new News[news.Count - 1]; int index = 0; foreach (News item in news) { if (item.Id == id) { id = Guid.Empty; continue; } else { newContext[index] = item; index++; } } news = newContext.ToList<News>(); WriteJson(); }
public ActionResult Add(Guid id) { News newArticle = new News(); newArticle.Id = id; return View(newArticle); }
public ActionResult Article(News changedArticle) { changedArticle.AuthorsID = User.Identity.Name; newsManagement.ChangeNews(changedArticle); return Redirect("/"); }
public ActionResult Add(News newArticle) { newArticle.AuthorsID = User.Identity.Name; newsManagement.AddNews(newArticle); return Redirect("/"); }