예제 #1
0
        public void AddNews(News newsToAdd)
        {

            newsToAdd.Date = DateTime.Now;

            news.Add(newsToAdd);

            WriteJson();


        }
예제 #2
0
        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();


        }
예제 #3
0
        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();
        }
예제 #4
0
        public ActionResult Add(Guid id)
        {
            News newArticle = new News();
            newArticle.Id = id;

            return View(newArticle);
        }
예제 #5
0
 public ActionResult Article(News changedArticle)
 {
     changedArticle.AuthorsID = User.Identity.Name;
     newsManagement.ChangeNews(changedArticle);
     return Redirect("/");
 }
예제 #6
0
 public ActionResult Add(News newArticle)
 {
     newArticle.AuthorsID = User.Identity.Name;
     newsManagement.AddNews(newArticle);
     return Redirect("/");
 }