public ActionResult Login(Get_Post_List model) { Services.Post_Service services = new Services.Post_Service(); Get_Post_List list = new Get_Post_List(); var session = Session["username"]; if (session == null) { list = services.LoginService(model.UserDetails); if (list.message == "valid") { Session["username"] = model.UserDetails.username; Session["attempt"] = "success"; } else { Session["attempt"] = "failed"; } } else { list.message = "valid"; } ViewBag.User = Session["username"]; ViewBag.Login = list.message; return(RedirectToAction("Index")); }
public ActionResult ViewCategoryItems(string category, int id) { Services.Post_Service services = new Services.Post_Service(); Get_Post_List result = services.PostGetByCategoryId(id); return(View("ViewCategoryItems", result)); }
public JsonResult Search(Search_Model input) { Get_Post_List model = new Get_Post_List(); Services.Post_Service services = new Services.Post_Service(); model = services.SearchService(input.searchStr); return(Json(model, JsonRequestBehavior.AllowGet)); }
public ActionResult Delete(string id) { Services.Post_Service services = new Services.Post_Service(); Get_Post_List list = services.PostDeleteContent(id); //ViewBag.Title = list.list[0].seoTitle; return(RedirectToAction("Index", "Home")); }
public ActionResult Show_Post(string categoryid, string id) { Services.Post_Service services = new Services.Post_Service(); Get_Post_List list = services.PostGetContent(id); var session = Session["username"]; if (session != null) { ViewBag.User = session.ToString(); } //ViewBag.Title = list.list[0].seoTitle; return(View("Show_Post", list)); }
public ActionResult Edit(string categoryid, string id) { try { Services.Post_Service services = new Services.Post_Service(); Get_Post_List list = services.PostGetContent(id); // TODO: Add update logic here return(View("CustomPostIndex", list)); } catch { return(View()); } }
public ActionResult Index() { Get_Post_List list = new Get_Post_List();; var session = Session["username"]; ViewBag.attempt = Session["attempt"]; if (session != null) { ViewBag.Login = "******"; } else { ViewBag.Login = "******"; } return(View(list)); }
public ActionResult FAQ() { validate(); Get_Post_List list = null; Services.Post_Service postService = new Services.Post_Service(); if (ModelState.IsValid) { list = new Get_Post_List(); list.FaqList = postService.FaqGetAll(); } else { list.message = "PostDataError"; } return(View("FAQ", list)); }
public Get_Post_List LoginService(Login_model user) { string status = "failed"; Get_Post_List list = new Get_Post_List(); try { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["PortalConnectionString"].ToString())) { DataSet ds = new DataSet(); con.Open(); SqlParameter[] param = new SqlParameter[4]; param[0] = new SqlParameter("@username", user.username); param[1] = new SqlParameter("@password", user.password); param[2] = new SqlParameter("@IsValid", SqlDbType.Int); param[2].Direction = ParameterDirection.Output; ds = SqlHelper.ExecuteDataset(con, CommandType.StoredProcedure, "tmpprclogin", param); int OutParam = 0; if (!String.IsNullOrEmpty(Convert.ToString(param[2].Value))) { OutParam = Convert.ToInt32(param[2].Value); } if (OutParam == 1) { list.message = "valid"; } else if (OutParam == 0) { list.message = "invalid"; } } } catch (Exception ex) { list.message = ex.Message; } return(list); }
public Get_Post_List PostGetLatestPosts(int start, int pageIndex) { string status = "failed"; Get_Post_List list = new Get_Post_List(); try { SqlParameter[] param = new SqlParameter[3]; param[0] = new SqlParameter("@start", start); param[1] = new SqlParameter("@pageIndex", pageIndex); param[2] = new SqlParameter("@isAll", 1); using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["PortalConnectionString"].ToString())) { DataSet ds = new DataSet(); con.Open(); ds = SqlHelper.ExecuteDataset(con, CommandType.StoredProcedure, "tmp_prc_getPostData", param); foreach (DataTable dt in ds.Tables) { foreach (DataRow dr in dt.Rows) { Post_Model obj = new Post_Model(); if (!string.IsNullOrEmpty(dr["post_id"].ToString())) { obj.postId = Convert.ToInt32(dr["post_id"].ToString()); } else { obj.postId = 0; } if (!string.IsNullOrEmpty(dr["post_url"].ToString())) { obj.postUrl = dr["post_url"].ToString(); } else { obj.postUrl = ""; } if (!string.IsNullOrEmpty(dr["seo_url"].ToString())) { obj.seoUrl = dr["seo_url"].ToString(); } else { obj.seoUrl = ""; } if (!string.IsNullOrEmpty(dr["category_name"].ToString())) { obj.category = dr["category_name"].ToString(); } else { obj.category = ""; } list.list.Add(obj); } } } list.message = "fetched"; } catch (Exception ex) { list.message = ex.Message; } return(list); }
public Get_Post_List PostDeleteContent(string id) { string status = "failed"; Get_Post_List list = new Get_Post_List(); try { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["PortalConnectionString"].ToString())) { DataSet ds = new DataSet(); con.Open(); SqlParameter[] param = new SqlParameter[2]; param[0] = new SqlParameter("@seo_url", id); ds = SqlHelper.ExecuteDataset(con, CommandType.StoredProcedure, "tmp_prc_deletePostData", param); //foreach (DataTable dt in ds.Tables) //{ // foreach (DataRow dr in dt.Rows) // { // Post_Model obj = new Post_Model(); // if (!string.IsNullOrEmpty(dr["post_id"].ToString())) // { // obj.postId = Convert.ToInt32(dr["post_id"].ToString()); // } // else // { // obj.postId = 0; // } // if (!string.IsNullOrEmpty(dr["post_url"].ToString())) // { // obj.postUrl = dr["post_url"].ToString(); // } // else // { // obj.postUrl = ""; // } // if (!string.IsNullOrEmpty(dr["file_name"].ToString())) // { // obj.postIconImage = dr["file_name"].ToString(); // } // else // { // obj.postIconImage = ""; // } // if (!string.IsNullOrEmpty(dr["file_path"].ToString())) // { // obj.postIconImagePath = dr["file_path"].ToString(); // } // else // { // obj.postIconImagePath = ""; // } // if (!string.IsNullOrEmpty(dr["post_category"].ToString())) // { // obj.category = dr["post_category"].ToString(); // } // else // { // obj.category = ""; // } // if (!string.IsNullOrEmpty(dr["post_content"].ToString())) // { // obj.postContent = dr["post_content"].ToString(); // } // else // { // obj.postContent = ""; // } // if (!string.IsNullOrEmpty(dr["seo_url"].ToString())) // { // obj.seoUrl = dr["seo_url"].ToString(); // } // else // { // obj.seoUrl = ""; // } // if (!string.IsNullOrEmpty(dr["seo_title"].ToString())) // { // obj.seoTitle = dr["seo_title"].ToString(); // } // else // { // obj.seoTitle = ""; // } // if (!string.IsNullOrEmpty(dr["seo_description"].ToString())) // { // obj.seoDescription = dr["seo_description"].ToString(); // } // else // { // obj.seoDescription = ""; // } // list.list.Add(obj); // } //} } list.message = "Deleted"; } catch (Exception ex) { list.message = ex.Message; } return(list); }
public Get_Post_List PostGetContent(string id) { string status = "failed"; Get_Post_List list = new Get_Post_List(); try { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["PortalConnectionString"].ToString())) { DataSet ds = new DataSet(); Post_Model obj = new Post_Model(); con.Open(); SqlParameter[] param = new SqlParameter[2]; param[0] = new SqlParameter("@seo_url", id); ds = SqlHelper.ExecuteDataset(con, CommandType.StoredProcedure, "tmp_prc_getPostData", param); using (DataTable dt = ds.Tables[0]) { foreach (DataRow dr in dt.Rows) { //if (!string.IsNullOrEmpty(dr["post_id"].ToString())) //{ // obj.postId = Convert.ToInt32(dr["post_id"].ToString()); //} //else //{ // obj.postId = 0; //} if (!string.IsNullOrEmpty(dr["post_url"].ToString())) { obj.postUrl = dr["post_url"].ToString(); } else { obj.postUrl = ""; } if (!string.IsNullOrEmpty(dr["file_name"].ToString())) { obj.postIconImage = dr["file_name"].ToString(); } else { obj.postIconImage = ""; } if (!string.IsNullOrEmpty(dr["file_path"].ToString())) { obj.postIconImagePath = dr["file_path"].ToString(); } else { obj.postIconImagePath = ""; } //if (!string.IsNullOrEmpty(dr["post_category"].ToString())) //{ // obj.category = dr["post_category"].ToString(); //} //else //{ // obj.category = ""; //} if (!string.IsNullOrEmpty(dr["post_content"].ToString())) { obj.postContent = dr["post_content"].ToString(); } else { obj.postContent = ""; } if (!string.IsNullOrEmpty(dr["seo_url"].ToString())) { obj.seoUrl = dr["seo_url"].ToString(); } else { obj.seoUrl = ""; } if (!string.IsNullOrEmpty(dr["seo_title"].ToString())) { obj.seoTitle = dr["seo_title"].ToString(); } else { obj.seoTitle = ""; } if (!string.IsNullOrEmpty(dr["seo_description"].ToString())) { obj.seoDescription = dr["seo_description"].ToString(); } else { obj.seoDescription = ""; } if (!string.IsNullOrEmpty(dr["shortname"].ToString())) { obj.shortName = dr["shortname"].ToString(); } else { obj.shortName = ""; } //if (!string.IsNullOrEmpty(dr["categorycaption"].ToString())) //{ // obj.categoryName = dr["categorycaption"].ToString(); //} //else //{ // obj.categoryName = ""; //} if (!string.IsNullOrEmpty(dr["file_attachment_code"].ToString())) { obj.fileAttachmentCode = dr["file_attachment_code"].ToString(); } else { obj.fileAttachmentCode = ""; } list.list.Add(obj); } } using (DataTable dt = ds.Tables[1]) { foreach (DataRow dr in dt.Rows) { Category_Model model = new Category_Model(); if (!string.IsNullOrEmpty(dr["category_name"].ToString())) { model.categoryName = dr["category_name"].ToString(); } else { model.categoryName = ""; } if (!string.IsNullOrEmpty(dr["category_desc"].ToString())) { model.categoryDesc = dr["category_desc"].ToString(); } else { model.categoryDesc = ""; } if (!string.IsNullOrEmpty(dr["category_id"].ToString())) { model.categoryId = Convert.ToInt32(dr["category_id"]); } else { model.categoryId = 0; } list.categoryList.Add(model); } } } list.message = "fetched"; } catch (Exception ex) { list.message = ex.Message; } return(list); }
public Get_Post_List SearchService(string searchStr) { string status = "failed"; Get_Post_List list = new Get_Post_List(); try { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["PortalConnectionString"].ToString())) { DataSet ds = new DataSet(); con.Open(); SqlParameter[] param = new SqlParameter[3]; param[0] = new SqlParameter("@strSearch", searchStr); ds = SqlHelper.ExecuteDataset(con, CommandType.StoredProcedure, "tmpprcsearch", param); foreach (DataTable dt in ds.Tables) { foreach (DataRow dr in dt.Rows) { Post_Model obj = new Post_Model(); if (!string.IsNullOrEmpty(dr["post_id"].ToString())) { obj.postId = Convert.ToInt32(dr["post_id"].ToString()); } else { obj.postId = 0; } if (!string.IsNullOrEmpty(dr["post_url"].ToString())) { obj.postUrl = dr["post_url"].ToString(); } else { obj.postUrl = ""; } if (!string.IsNullOrEmpty(dr["file_name"].ToString())) { obj.postIconImage = dr["file_name"].ToString(); } else { obj.postIconImage = ""; } if (!string.IsNullOrEmpty(dr["file_path"].ToString())) { obj.postIconImagePath = dr["file_path"].ToString(); } else { obj.postIconImagePath = ""; } if (!string.IsNullOrEmpty(dr["category_name"].ToString())) { obj.category = dr["category_name"].ToString(); } else { obj.category = ""; } if (!string.IsNullOrEmpty(dr["seo_url"].ToString())) { obj.seoUrl = dr["seo_url"].ToString(); } else { obj.seoUrl = ""; } if (!string.IsNullOrEmpty(dr["post_category"].ToString())) { obj.categoryName = dr["post_category"].ToString(); } else { obj.categoryName = ""; } list.list.Add(obj); } } } list.message = "fetched"; } catch (Exception ex) { list.message = ex.Message; } return(list); }
public Get_Post_List PostGetAll(int pageIndex) { string status = "failed"; Get_Post_List list = new Get_Post_List(); try { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["PortalConnectionString"].ToString())) { DataSet dset = new DataSet(); con.Open(); SqlParameter[] param = new SqlParameter[3]; dset = SqlHelper.ExecuteDataset(con, CommandType.StoredProcedure, "tmp_prc_getPostData", param); DataTable dtable = Post_Service.SetPgination(dset, pageIndex); //DataTable dtable = dset.Tables[0]; using (DataTable dt = dtable) { foreach (DataRow dr in dt.Rows) { Post_Model obj = new Post_Model(); if (!string.IsNullOrEmpty(dr["post_id"].ToString())) { obj.postId = Convert.ToInt32(dr["post_id"].ToString()); } else { obj.postId = 0; } if (!string.IsNullOrEmpty(dr["post_url"].ToString())) { obj.postUrl = dr["post_url"].ToString(); } else { obj.postUrl = ""; } if (!string.IsNullOrEmpty(dr["file_name"].ToString())) { obj.postIconImage = dr["file_name"].ToString(); } else { obj.postIconImage = ""; } if (!string.IsNullOrEmpty(dr["file_path"].ToString())) { obj.postIconImagePath = dr["file_path"].ToString(); } else { obj.postIconImagePath = ""; } if (!string.IsNullOrEmpty(dr["category_name"].ToString())) { obj.category = dr["category_name"].ToString(); } else { obj.category = ""; } if (!string.IsNullOrEmpty(dr["seo_url"].ToString())) { obj.seoUrl = dr["seo_url"].ToString(); } else { obj.seoUrl = ""; } if (!string.IsNullOrEmpty(dr["post_category"].ToString())) { obj.categoryName = dr["post_category"].ToString(); } else { obj.categoryName = ""; } list.list.Add(obj); } } using (DataTable dt = dset.Tables[1]) { foreach (DataRow dr in dt.Rows) { PostCount_Model countObj = new PostCount_Model(); if (!string.IsNullOrEmpty(dr["category_id"].ToString())) { countObj.categoryId = Convert.ToInt32(dr["category_id"]); } else { countObj.categoryId = 0; } if (!string.IsNullOrEmpty(dr["category"].ToString())) { countObj.category = dr["category"].ToString(); } else { countObj.category = ""; } if (!string.IsNullOrEmpty(dr["no_of_posts"].ToString())) { countObj.noOfPosts = Convert.ToInt32(dr["no_of_posts"]); } else { countObj.noOfPosts = 0; } list.postCountList.Add(countObj); } } } list.message = "fetched"; } catch (Exception ex) { list.message = ex.Message; } return(list); }