예제 #1
0
        // GET: Lulu
        public ActionResult Index()
        {
            LuluVM vm = new LuluVM()
            {
                PostLibrary = getPosts()
            };

            return(View(vm));
        }
예제 #2
0
        public ActionResult addPost(LuluVM vm)
        {
            Post newPost = new Post()
            {
                Date    = DateTime.Now.ToShortDateString(),
                Message = vm.NewPost
            };

            XDocument doc     = XDocument.Load(Server.MapPath("~/App_Data/LuluPosts.xml"));
            XElement  library = doc.Element("PostLibrary");
            XElement  posts   = library.Element("Posts");
            XElement  post    = new XElement("Post");

            post.Add(new XElement("Date", newPost.Date));
            post.Add(new XElement("Message", newPost.Message));
            posts.Add(post);
            doc.Save(Server.MapPath("~/App_Data/LuluPosts.xml"));

            return(RedirectToAction("index"));
        }