/// <summary> /// Updates this instance of Page. Returns true on success. /// </summary> /// <returns>bool</returns> private bool Update() { return(DBSurveyPage.Update( this.pageGuid, this.surveyGuid, this.pageTitle, this.pageOrder, this.pageEnabled)); }
/// <summary> /// Persists a new instance of Page. Returns true on success. /// </summary> /// <returns></returns> private bool Create() { this.pageGuid = Guid.NewGuid(); int rowsAffected = DBSurveyPage.Add( this.pageGuid, this.surveyGuid, this.pageTitle, this.pageEnabled); return(rowsAffected > 0); }
/// <summary> /// Gets an instance of Page. /// </summary> /// <param name="pageGuid"> pageGuid </param> private void GetPage(Guid pageGuid) { using (IDataReader reader = DBSurveyPage.GetOne(pageGuid)) { if (reader.Read()) { this.pageGuid = new Guid(reader["PageGuid"].ToString()); this.surveyGuid = new Guid(reader["SurveyGuid"].ToString()); this.pageTitle = reader["PageTitle"].ToString(); this.pageOrder = Convert.ToInt32(reader["PageOrder"]); this.pageEnabled = Convert.ToBoolean(reader["PageEnabled"]); this.questionCount = Convert.ToInt32(reader["QuestionCount"]); } } }
///// <summary> ///// Returns the count of questions on the given page ///// </summary> ///// <param name="pageGuid"> pageGuid </param> ///// <returns></returns> //public static int QuestionCount(Guid pageGuid) //{ // return DB.PageQuestionsCount(pageGuid); //} /// <summary> /// Gets an IList with all instances of Page. /// </summary> public static List <Page> GetAll(Guid surveyGuid) { List <Page> pageList = new List <Page>(); using (IDataReader reader = DBSurveyPage.GetAll(surveyGuid)) { while (reader.Read()) { Page page = new Page(); page.pageGuid = new Guid(reader["PageGuid"].ToString()); page.surveyGuid = new Guid(reader["SurveyGuid"].ToString()); page.pageTitle = reader["PageTitle"].ToString(); page.pageOrder = Convert.ToInt32(reader["PageOrder"], CultureInfo.CurrentCulture); page.pageEnabled = Convert.ToBoolean(reader["PageEnabled"], CultureInfo.CurrentCulture); page.questionCount = Convert.ToInt32(reader["QuestionCount"]); pageList.Add(page); } } return(pageList); }
/// <summary> /// Deletes an instance of Page. Returns true on success. /// </summary> /// <param name="pageGuid"> pageGuid </param> /// <returns>bool</returns> public static bool Delete(Guid pageGuid) { return(DBSurveyPage.Delete(pageGuid)); }