Exemplo n.º 1
0
        // *** GET: All Posts ***
        public ActionResult Index()
        {
            ViewBag.Posts = "Posts";
            PostsDBHandler PHandler = new PostsDBHandler();

            ModelState.Clear();

            return(View(PHandler.GetPostItem()));
        }
Exemplo n.º 2
0
 public ActionResult Edit(int id, PostsViewModels iPost)
 {
     try
     {
         PostsDBHandler PHandler = new PostsDBHandler();
         PHandler.UpdateItem(iPost);
         return(RedirectToAction("Index"));
     }
     catch { return(View()); }
 }
Exemplo n.º 3
0
 // *** Delete Item Details ***
 public ActionResult Delete(int id)
 {
     try
     {
         PostsDBHandler PHandler = new PostsDBHandler();
         if (PHandler.DeletePostItem(id))
         {
             ViewBag.AlertMsg = "Item Deleted Successfully";
         }
         return(RedirectToAction("Index"));
     }
     catch { return(View()); }
 }
Exemplo n.º 4
0
 public ActionResult Create(PostsViewModels iPost)
 {
     if (ModelState.IsValid)
     {
         PostsDBHandler PHandler = new PostsDBHandler();
         if (PHandler.PostItem(iPost))
         {
             ViewBag.Message = "Item Added Successfully";
             ModelState.Clear();
         }
     }
     return(View());
 }
Exemplo n.º 5
0
        public ActionResult Details(int id)
        {
            PostsDBHandler PHandler = new PostsDBHandler();

            return(View(PHandler.GetPostItem().Find(itemmodel => itemmodel.Id == id)));
        }