/// <summary> /// DBFill /// </summary> /// <param name="reader"></param> /// <param name="slide"></param> public static void DBFill(SqliteDataReader reader, Slide slide) { slide.SlideID = Convert.ToInt32(reader["slide_id"]); slide.SlideText = HttpUtility.UrlDecode(reader["slide_text"].ToString(), System.Text.Encoding.Default); slide.SlideIndex = Convert.ToInt32(reader["slide_index"]); slide.PhotoID = Convert.ToInt32(reader["photo_id"]); slide.Photo = Photo.Get(slide.PhotoID); }
public JsonResult Save(string slide_text, int slide_index, int photo_id, int? slide_id = null) { Slide slide = new Slide(); slide.SlideID = slide_id; slide.SlideText = slide_text; slide.SlideIndex = slide_index; slide.PhotoID = photo_id; slide.Save(); return Json(slide); }
/// <summary> /// Gets all project /// </summary> /// <returns>List of slides</returns> public static List<Slide> GetAll() { List<Slide> slides = new List<Slide>(); string query = "SELECT * FROM kk_slide ORDER BY slide_index;"; // get database connection using (SqliteConnection conn = new SqliteConnection(connectionString)) { conn.Open(); // execute cmd using (SqliteCommand cmd = new SqliteCommand(query, conn)) { // user reader to fill data using (SqliteDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { Slide slide = new Slide(); Slide.DBFill(reader, slide); slides.Add(slide); } } } } return slides; }