Esempio n. 1
0
            public async Task <ViewModel.DailyModel> QueryDaily(int id)
            {
                var vDaily = new ViewModel.DailyModel();

                var daily = await Table <Model.DailyModel>().Where(d => d.Id == id).FirstOrDefaultAsync();

                if (daily != null)
                {
                    vDaily = new ViewModel.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 await Table <Model.DailyCssModel>().Where(d => d.DailyId == id).ToListAsync())
                    {
                        vDaily.css.Add(item.css);
                    }
                    foreach (var item in await Table <Model.DailyJsModel>().Where(d => d.DailyId == id).ToListAsync())
                    {
                        vDaily.js.Add(item.js);
                    }
                }
                return(vDaily);
            }
Esempio n. 2
0
            public async Task UpdateDaily(ViewModel.DailyModel item)
            {
                await DeleteAsync <Model.DailyModel>(item.id).ContinueWith(async(results) =>
                {
                    await InsertAsync(new Model.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 await Table <Model.DailyJsModel>().Where(d => d.DailyId == item.id).ToListAsync())
                {
                    await DeleteAsync <Model.DailyJsModel>(js.Id);
                }
                foreach (var js in item.js)
                {
                    await InsertAsync(new Model.DailyJsModel
                    {
                        DailyId = item.id,
                        js      = js
                    });
                }
                foreach (var css in await Table <Model.DailyCssModel>().Where(d => d.DailyId == item.id).ToListAsync())
                {
                    await DeleteAsync <Model.DailyCssModel>(css.Id);
                }
                foreach (var css in item.css)
                {
                    await InsertAsync(new Model.DailyCssModel
                    {
                        DailyId = item.id,
                        css     = css
                    });
                }
            }