public async Task <ApiResult <object> > Item(int ID) { var res = new ApiResult <object>(); if (ID > 0) { ArticleMenu m = articleMenuDB.GetId(ID); if (m != null) { res.success = true; res.data = new { m.ParentID, m.Names, m.ENames, m.Sorting }; } else { res.data = new { ParentID = 0, Names = "", ENames = "", Sorting = "" }; } } if (res.data != null) { res.success = true; } return(await Task.Run(() => res)); }
public async Task <ApiResult <string> > Item(int ID, int ParentID, string Names, string ENames, int Sorting) { var res = new ApiResult <string>(); if (string.IsNullOrWhiteSpace(Names)) { res.msg = "请填写名称"; } else if (ID > 0 && ID == ParentID) { res.msg = "类型不能在自己之下!"; } else if (ParentID < 0) { res.msg = "请正确填写父类id"; } else { try { ArticleMenu m = articleMenuDB.GetId(ID); ArticleMenu am = articleMenuDB.GetId(ParentID); if (ParentID == 0 || am != null) { if (m != null) { m.Names = Names; m.ENames = ENames; m.Sorting = Sorting; res.success = articleMenuDB.Update(m) > 0; if (res.success) { res.msg = "修改成功"; } else { res.msg = "修改失败"; res.statusCode = (int)ApiEnum.Status; } } else { res.msg = "栏目查询失败!"; res.statusCode = (int)ApiEnum.Error; } } else { res.msg = "父类填写错误,无该父类"; } } catch (Exception ex) { res.statusCode = (int)ApiEnum.Error; res.msg = ApiEnum.Error.GetEnumText() + ex.Message; } } return(await Task.Run(() => res)); }
public async Task <ApiResult <string> > Item(int ParentID, string Names, string ENames, int Sorting) { var res = new ApiResult <string>(); if (string.IsNullOrWhiteSpace(Names)) { res.msg = "请填写名称"; } else if (ParentID < 0) { res.msg = "请正确填写父类id"; } else { ArticleMenu m = new ArticleMenu(); ArticleMenu am = articleMenuDB.GetId(ParentID); if (ParentID == 0 || am != null) { m.Names = Names; m.ENames = ENames; m.Sorting = Sorting; m.ParentID = ParentID; m.State = 2; m.AddDate = DateTime.Now; m.URL = ""; try { res.success = articleMenuDB.Add(m) > 0; if (res.success) { res.msg = "添加成功"; } else { res.msg = "添加失败"; res.statusCode = (int)ApiEnum.Status; } } catch (Exception ex) { res.statusCode = (int)ApiEnum.Error; res.msg = ApiEnum.Error.GetEnumText() + ex.Message; } } else { res.msg = "父类填写错误,无该父类"; } } return(await Task.Run(() => res)); }
public async Task <ApiResult <object> > Item(int ID) { var res = new ApiResult <object>(); if (ID > 0) { Article m = db.GetId(ID); if (m != null) { List <ArticleMenu_Article> list2 = articleMenu_ArticleService.GetWhere(a => a.ArticleID == ID); List <ArticleMenuViewModel> Articlemenumodel = new List <ArticleMenuViewModel>(); if (list2 != null) { foreach (var item in list2) { ArticleMenu articmenus = articleMenuDB.GetId(item.ArticleMenuID); if (articmenus != null) { Articlemenumodel.Add(new ArticleMenuViewModel { id = item.ArticleMenuID, Names = articmenus.Names }); } else { res.msg = "参数丢失"; } } } //List<ArticleMenu_Article> list2 = articleMenu_ArticleService.GetWhere(a => a.ArticleID == ID); //if (list2 != null) //{ // foreach (var item in list2) // { // ArticleMenu articmenus = articleMenuDB.GetId(item.ArticleMenuID); // if (articmenus != null) // { // ArticleMenuID = ArticleMenuID + item.ArticleMenuID + ","; // ArticleMenuName = ArticleMenuName + articmenus.Names + ","; // } // else // { // res.msg = "参数丢失"; // } // } if (m.Contents == null) { m.Contents = ""; } res.data = new { m.ID, m.Title, AddDate = Utility.GetDateFormat(m.AddDate, 1), Contents = m.Contents.Replace("src=\"/UploadFiles", "src=\"" + Utility.WEB_IMAGES_URL + "/UploadFiles"), // 图片路径替换 m.ImgUrl, m.Type, m.FileUrl, m.Keyword, m.Source, m.IsTop, m.State, m.Synopsis, m.Sorting, m.PageView, m.Author, FileSize = m.FileSize + "", FileFormat = m.FileFormat + "", Articlemenumodel }; //} } else { res.msg = "参数丢失"; } } else { res.data = new { Title = "", AddDate = DateTime.Now, Contents = "", Source = "", ImgUrl = "", Type = 1, FileUrl = "", Keyword = "", Sorting = 1, IsTop = false, State = 2, Synopsis = "", PageView = 0, Author = "", FileSize = "", FileFormat = "", Articlemenumodel = new List <ArticleMenuModel>() }; res.msg = "无数据"; } if (res.data != null) { res.success = true; } return(await Task.Run(() => res)); }