public void AddPost(Post p)
        {
            var posts = GetPosts();

            p.Id = posts.Max(x => x.Id) + 1;

            posts.Add(p);

            SavePosts(posts);
        }
        public ActionResult Create(Post newPost)
        {
            if (!ModelState.IsValid)
            {
                return View(newPost);
            }
            try
            {
                // TODO: Add insert logic here
                newPost.DatePosted = DateTime.Now;
                AddPost(newPost);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
        public ActionResult Edit(Post edittedPost)
        {
            try
            {
                // TODO: Add update logic here
                if (ModelState.IsValid)
                {
                    //do the update with edittedpost
                    var posts = GetPosts();
                    var post = posts.FirstOrDefault(x => x.Id == edittedPost.Id);
                    posts.Remove(post);
                    posts.Add(edittedPost);
                    SavePosts(posts);

                    return RedirectToAction("Index");
                }
                else
                {
                    return View(edittedPost);
                }
            }
            catch
            {
                return View();
            }
        }