public ActionResult Index() { blogLogics = new BlogLogics(); categoryLogics = new CategoryLogics(); var data = categoryLogics.GetCategories(); if (data == null || data.Count == 0) { return(RedirectToAction("Index", "Category")); } var obj = blogLogics.GetBlogs(); return(View(obj)); }
public ActionResult Edit(int?Blog_Id, string Blog_Headline, string Blog_Description, int?Category_Id) { blogLogics = new BlogLogics(); if (!String.IsNullOrWhiteSpace(Blog_Headline) && !String.IsNullOrWhiteSpace(Blog_Description) && (Category_Id != null) && (Blog_Id != null)) { var data = blogLogics.EditBlog(Blog_Id, Blog_Headline, Blog_Description, Category_Id); if (data == null) { ViewBag.Msg = "Internal error occured while updating the blog"; } return(RedirectToAction("Index")); } else { ViewBag.Msg = "Fields can't be left empty"; return(View()); } }
public ActionResult Delete(int?Id) { blogLogics = new BlogLogics(); if (Id == null) { return(View("Error")); } BlogLogics blg = new BlogLogics(); var data = blg.DeleteBlog(Id); if (data) { ViewBag.Msg = "Blog deleted successfully"; return(RedirectToAction("Index")); } else { ViewBag.Msg = "Error occured while deleting"; return(View("Error")); } }
public ActionResult Edit(int?Id) { blogLogics = new BlogLogics(); categoryLogics = new CategoryLogics(); if (Id == null) { return(View("Error")); } var data = blogLogics.GetBlog(Id); var CategoryList = categoryLogics.GetCategories(); if (data == null) { ViewBag.Msg = "No Blog found with this Blog-Id"; return(View("Error")); } ViewBag.Blog_Id = data.Id; ViewBag.Blog_Headline = data.Blog_Headline; ViewBag.Blog_Description = data.Blog_Description; return(View(CategoryList)); }