public async Task <ActionResult> Config(string id) { if (string.IsNullOrEmpty(id)) { return(View()); } else { var config = db.DPages.Find(id); if (config == null) { config = new DPage { Id = id, CreatorId = User.Identity.GetUserId(), LastModify = DateTime.UtcNow } } ; await db.SaveAsync(); return(View("Pages", new DPageViewModel { Id = config.Id, Name = config.Name, Content = config.Content })); } }
public async Task <ActionResult> Index(string AppId, string BlogId) { if (BlogId != null) { var blog = await db.Blogs.FindAsync(BlogId); if (blog == null) { return(PartialView()); } if (blog.Galleries.Count == 0) { var gal = new GalleryDB(db).CreateBlog(blog); await db.SaveAsync(); } ViewBag.CreateLink = "BlogId=" + BlogId; return(PartialView("_Index", db.AppFiles.Where(x => x.Gallery.BlogId == BlogId))); } else if (AppId != null) { ViewBag.CreateLink = "AppId=" + AppId; var product = await db.Apps.FindAsync(AppId); if (product == null) { return(PartialView()); } if (product.Galleries.Count == 0) { var gal = new GalleryDB(db).Create(product); await db.SaveAsync(); } return(PartialView("_Index", db.AppFiles.Where(x => x.Gallery.AppId == AppId))); } return(View(db.AppFiles)); }
public async Task <ActionResult> Create([Bind(Include = "Name,Note,MaxStep,ParentId,AcceptId,Level")] AppTask appTask, string[] TagTaskId) { var helper = new DBHelper(); appTask.Id = helper.GetAppCategoryId(db); if (TagTaskId != null) { foreach (var item in TagTaskId) { var tag = await db.TagTasks.FindAsync(item); if (tag == null) { tag = await db.TagTasks.SingleOrDefaultAsync(x => x.Name == item); if (tag == null) { db.TagTasks.Add(new TagTask { Id = helper.GetTagTaskId(db), Name = item, }); await db.SaveAsync(); } } if (tag != null) { db.TaskTags.Add(new TaskTag { AppTask = appTask, TagTask = tag, }); } } } appTask.Created = DateTime.UtcNow; appTask.UserId = User.Identity.GetUserId(); db.AppTasks.Add(appTask); var str = await db.SaveMessageAsync(); if (str != null) { return(Json(str.GetError())); } return(Json(LanguageDB.AppTaskAdded, "/admin/apptasks/edit/" + appTask.Id)); }