Ejemplo n.º 1
0
        public ActionResult Add(PostModel post)
        {
            try
            {
                if (ModelState.IsValid) {
                    post.Created = DateTime.Now;
                    post.LastModified = DateTime.Now;
                    post.Author = User.Identity.Name;

                    postService.AddPost(post.ThePost);

                    return RedirectToAction("Index");
                }
                else
                {
                    return View();
                }
            }
            catch
            {
                return View();
            }
        }
Ejemplo n.º 2
0
        public ActionResult Delete(int id, PostModel post)
        {
            try
            {
                postService.DeletePost(post.ThePost);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Ejemplo n.º 3
0
        public ActionResult Edit(int id, PostModel post)
        {
            try
            {
                post.LastModified = DateTime.Now;
                post.Id = id;
                postService.UpdatePost(post.ThePost);

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