Exemplo n.º 1
0
        public string FaqSave(Faq_model faq)
        {
            string status = "failed";

            try
            {
                using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["PortalConnectionString"].ToString()))
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand();
                    cmd.Connection  = con;
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "tmpprcpostfaq";
                    cmd.Parameters.AddWithValue("@question", faq.questions);
                    cmd.Parameters.AddWithValue("@answer", faq.answer);

                    cmd.ExecuteNonQuery();
                }
                status = "saved";
            }
            catch (Exception ex)
            {
                status = ex.Message;
            }
            return(status);
        }
Exemplo n.º 2
0
 public ActionResult Create(FormCollection collection)
 {
     try
     {
         // TODO: Add insert logic here
         string status = "";
         Services.Post_Service postService = new Services.Post_Service();
         if (ModelState.IsValid)
         {
             Faq_model model = new Faq_model();
             model.answer    = Request.Form["answer"].ToString();
             model.questions = Request.Form["query"].ToString();
             status          = postService.FaqSave(model);
         }
         else
         {
             status = "PostDataError";
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Exemplo n.º 3
0
        public Faq_model_list FaqGetAll()
        {
            string         status = "failed";
            Faq_model_list list   = new Faq_model_list();

            try
            {
                using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["PortalConnectionString"].ToString()))
                {
                    DataSet ds = new DataSet();
                    con.Open();
                    ds = SqlHelper.ExecuteDataset(con, CommandType.StoredProcedure, "tmpprcgetfaq");
                    foreach (DataTable dt in ds.Tables)
                    {
                        foreach (DataRow dr in dt.Rows)
                        {
                            Faq_model obj = new Faq_model();
                            if (!string.IsNullOrEmpty(dr["question"].ToString()))
                            {
                                obj.questions = dr["question"].ToString();
                            }
                            else
                            {
                                obj.questions = "";
                            }
                            if (!string.IsNullOrEmpty(dr["answer"].ToString()))
                            {
                                obj.answer = dr["answer"].ToString();
                            }
                            else
                            {
                                obj.answer = "";
                            }

                            list.list.Add(obj);
                        }
                    }
                }
                list.message = "fetched";
            }
            catch (Exception ex)
            {
                list.message = ex.Message;
            }
            return(list);
        }