コード例 #1
0
ファイル: FAQ.cs プロジェクト: haimon74/Easy-Fixup
		/// <summary>
		/// Fetches all.
		/// </summary>
		/// <returns></returns>
        public static FAQ[] FetchAll(int categoryId)
        {
            string cacheKey = String.Format("FAQ_FetchAll_{0}",categoryId);
			if(HttpContext.Current != null && HttpContext.Current.Cache[cacheKey] != null) {
                //return HttpContext.Current.Cache[cacheKey] as FAQ[];
			}

			//using (var conn = Config.DB.Open()) 
            {
                List<FAQ> lQuestions = new List<FAQ>();

                using (var reader = SqlHelper.GetDB().ExecuteReader("FetchFAQs", categoryId))
                {
                    while (reader.Read())
                    {
                        FAQ aQuestion = new FAQ();
                        aQuestion.id = (int) reader["Id"];
                        aQuestion.name = (string) reader["Name"];
                        aQuestion.active = (bool) reader["Active"];
                        aQuestion.question = (string) reader["QuestionDisplay"];
                        aQuestion.answer = (string) reader["AnswerDisplay"];
                        aQuestion.categoryId = (int) reader["CategoryId"];
                        aQuestion.order = (int) reader["OrderId"];
                        lQuestions.Add(aQuestion);
                    }
                    reader.Close();
                }
                FAQ[] questions = lQuestions.ToArray();

				if(HttpContext.Current != null) {
                    //Global.AddCacheItem("FAQs", cacheKey, questions);
					HttpContext.Current.Cache.Insert(cacheKey, questions, null, DateTime.Now.AddMinutes(30),
							Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null);
				}
				return questions;
			}
		}
コード例 #2
0
ファイル: FAQ.cs プロジェクト: haimon74/Easy-Fixup
        private static FAQ[] Fetch(int id, string name)
        {
            List<FAQ> lFAQ = new List<FAQ>();

			//using (var conn = Config.DB.Open()) 
            {
                using (var reader = SqlHelper.GetDB().ExecuteReader("FetchFAQ", id, name))
                {

                    while (reader.Read())
                    {
                        FAQ aQuestion = new FAQ();
                        aQuestion.id = (int) reader["Id"];
                        aQuestion.name = (string) reader["Name"];
                        aQuestion.question = (string) reader["QuestionDisplay"];
                        aQuestion.answer = (string) reader["AnswerDisplay"];
                        aQuestion.active = (bool) reader["Active"];
                        aQuestion.categoryId = (int) reader["CategoryId"];
                        aQuestion.order = (int) reader["OrderId"];
                        lFAQ.Add(aQuestion);
                    }
                    reader.Close();
                }
            }
            return lFAQ.ToArray();
		}
コード例 #3
0
ファイル: FAQ.cs プロジェクト: haimon74/Easy-Fixup
		/// <summary>
		/// Creates the specified name.
		/// </summary>
		/// <param name="name">The name.</param>
		/// <param name="active">if set to <c>true</c> [active].</param>
		/// <returns></returns>
        public static FAQ Create(string name,string question, string answer, bool active, int categoryId)
        {
            FAQ newQuestion = new FAQ();
            newQuestion.id = -1;
            newQuestion.categoryId = categoryId;
            newQuestion.name = name;
            newQuestion.QuestionDisplay = question;
            newQuestion.AnswerDisplay = answer;
            newQuestion.active = active;

            return newQuestion;
		}