示例#1
0
文件: AppDB.cs 项目: cnstandat/TD
        public async Task <string> Delete(string id)
        {
            var blog = await db.Blogs.FindAsync(id);

            if (blog == null)
            {
                return(LanguageDB.NotFound);
            }
            var comments = await db.Comments.Where(x => x.BlogId == id).Select(x => x.Id).ToListAsync();

            var commentDB = new CommentDB(db);

            foreach (var item in comments)
            {
                await commentDB.Delete(item);
            }
            var galleryDB = new GalleryDB(db);
            var gallery   = await db.Galleries.Where(x => x.BlogId == id).Select(x => x.Id).ToListAsync();

            foreach (var item in gallery)
            {
                await galleryDB.Delete(item);
            }
            db.Blogs.Remove(blog);
            var str = await db.SaveMessageAsync();

            return(str);
        }
示例#2
0
文件: AppDB.cs 项目: cnstandat/TD
        public async Task <string> Delete(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return((TD.Global.NoData));
            }
            using (var db = new TDContext())
            {
                App app = await db.Apps.FindAsync(id);

                if (app == null)
                {
                    return(LanguageDB.NotFound);
                }


                db.Apps.Remove(app);
                var galleries = db.Galleries.Where(x => x.AppId == app.Id).Select(x => x.Id).ToList();
                if (galleries != null && galleries.Count > 0)
                {
                    var galleryDB = new GalleryDB(db);
                    for (int i = 0, j = galleries.Count; i < j; i++)
                    {
                        await galleryDB.Delete(galleries[i]);
                    }
                }
                var str = await db.SaveMessageAsync();

                if (!string.IsNullOrEmpty(str))
                {
                    return(str);
                }


                return("");
                //return (Js.SuccessRedirect(AppRemove, TD.Properties.Resources.AdminAppsLink));
            }
        }