//get method public ActionResult UpdatePost(string postId, string error) { PostService postService = new PostService(); JOB_POST post = postService.findById(postId); if (DateTime.Compare(post.END_DATE, DateTime.Now) < 0) { return(RedirectToAction("ShowPosts", "Manager", new { error = "Can't update post that passed the End time" })); } else { TempData["Post"] = post; ViewBag.error = error; return(View()); } }
//post method public ActionResult UpdatePostDB(JOB_POST p) { PostService postService = new PostService(); if (DateTime.Compare(p.END_DATE, DateTime.Now) < 0) { return(RedirectToAction("UpdatePost", "Manager", new { postId = p.POST_ID, error = "Can't update post that passed the End time" })); } if (postService.update(p)) { return(RedirectToAction("ShowPosts", "Manager")); } else { return(RedirectToAction("ShowPosts", "Manager")); } }
//Post method public ActionResult CreatePostDB(JOB_POST p) { PostService postService = new PostService(); p.CREATED = DateTime.Now; if (DateTime.Compare(p.CREATED, p.END_DATE) < 0) { if (postService.create(p)) { return(RedirectToAction("ShowPosts")); } else { return(RedirectToAction("CreatePost", new { error = "There's something wrong. Please create again" })); } } else { return(RedirectToAction("CreatePost", new { error = "End Date must be after Now" })); } }