public Models.JsonModels.DailyModel QueryDaily(int id) { var vDaily = new Models.JsonModels.DailyModel(); var daily = DataBase.Table <DailyModel>().Where(d => d.Id == id).FirstOrDefault(); if (daily != null) { vDaily = new Models.JsonModels.DailyModel() { id = daily.Id, body = daily.body, ga_prefix = daily.ga_prefix, image = daily.image, image_source = daily.image_source, share_url = daily.share_url, title = daily.title, type = daily.type, updatetime = daily.updatetime, css = new List <string>(), js = new List <string>() }; foreach (var item in DataBase.Table <DailyCssModel>().Where(d => d.DailyId == id).ToList()) { vDaily.css.Add(item.css); } foreach (var item in DataBase.Table <DailyJsModel>().Where(d => d.DailyId == id).ToList()) { vDaily.js.Add(item.js); } } return(vDaily); }
public void UpdateDaily(Models.JsonModels.DailyModel item) { DataBase.DeleteItem <DailyModel>(item.id); DataBase.InsertItem(new DailyModel { Id = item.id, body = item.body, ga_prefix = item.ga_prefix, image = item.image, image_source = item.image_source, share_url = item.share_url, title = item.title, type = item.type, updatetime = DateTime.Now }); foreach (var js in DataBase.Table <DailyJsModel>().Where(d => d.DailyId == item.id).ToList()) { DataBase.DeleteItem <DailyJsModel>(js.Id); } foreach (var js in item.js) { DataBase.InsertItem(new DailyJsModel { DailyId = item.id, js = js }); } foreach (var css in DataBase.Table <DailyCssModel>().Where(d => d.DailyId == item.id).ToList()) { DataBase.DeleteItem <DailyCssModel>(css.Id); } foreach (var css in item.css) { DataBase.InsertItem(new DailyCssModel { DailyId = item.id, css = css }); } }