public string Update(tb_Keyword data) { var keywordRepository = InitKeywordRepository(); keywordRepository.Update(data); return(PromptToJson(Const.PromptSuccess)); }
public string Insert(tb_Keyword data) { var keywordRepository = InitKeywordRepository(); var result = keywordRepository.Insert(data); return(PromptToJson(result > 0 ? Const.PromptSuccess : Const.PromptFailure)); }
public List <tb_Keyword> GetKeywordsByTypeId(tb_Keyword data) { return(GetEntities <tb_Keyword>( t => t.Active == data.Active && t.KeywordTypeId == data.KeywordTypeId )); }
/// <summary> /// 修改关键字 /// </summary> /// <param name="input"></param> /// <returns></returns> public string EditKeyword(KeywordtData input) { input.KeywordId = FilterParamters(input.KeywordId); input.KeywordTypeId = FilterParamters(input.KeywordTypeId); input.Name = FilterParamters(input.Name); var dict = new Dictionary <string, object> { { "KeywordTypeId", input.KeywordTypeId }, { "Name", input.Name }, { "KeywordId", input.KeywordId } }; var valid = ValidateParameters <KeywordtData>(dict); if (valid.Length > 0) { return(valid); } var keyword = new tb_Keyword { KeywordId = int.Parse(input.KeywordId), KeywordTypeId = int.Parse(input.KeywordTypeId), Name = input.Name, Pinyin = Pinyin.GetPinyin(input.Name), }; var keywordService = InitKeywordService(); return(keywordService.Update(keyword)); }
public int Insert(tb_Keyword data) { using (var cd = Conn.GetClubContext()) { cd.tb_Keyword.InsertOnSubmit(data); cd.SubmitChanges(); return(data.KeywordTypeId); } }
/// <summary> /// 根据主键更新表内容 /// </summary> public void Update(tb_Keyword data) { using (var cd = Conn.GetClubContext()) { var update = cd.tb_Keyword.Single(t => t.KeywordId == data.KeywordId); update.KeywordTypeId = data.KeywordTypeId; update.Name = data.Name; update.Pinyin = data.Pinyin; cd.SubmitChanges(); } }
public string GetSelectedKeywords(tb_KeywordType data) { var typeRepository = InitKeywordTypeRepository(); var keywordRepository = InitKeywordRepository(); data.Active = true; data.ParentTypeId = 0; //根据线路类型 版块 类别查询出关键字类别 var allTypes = new List <tb_KeywordType>(); //一级 二级的关键字类别 现在只分到二级 TODO var types = typeRepository.GetSelectedTypesByParentId(data); foreach (var tbKeywordType in types) { allTypes.Add(tbKeywordType); data.ParentTypeId = tbKeywordType.KeywordTypeId; var children = typeRepository.GetSelectedTypesByParentId(data); if (children.Count <= 0) { continue; } allTypes.AddRange(children); } //查询关键字内容 //var allKeywords = new List<tb_Keyword>(); var allKeywords = new List <tb_KeywordType>(); var condition = new tb_Keyword { Active = true }; foreach (var tbKeywordType in allTypes) { //allKeywords.Add(new tb_Keyword //{ // KeywordTypeName = tbKeywordType.Name, // IsKeywordType = true, // Pinyin = string.Empty, // Name = string.Empty //}); condition.KeywordTypeId = tbKeywordType.KeywordTypeId; var keywords = keywordRepository.GetKeywordsByTypeId(condition); if (keywords.Count <= 0) { allKeywords.Add(tbKeywordType); continue; } tbKeywordType.Keywords = keywords; allKeywords.Add(tbKeywordType); } return(PromptToJson(Const.PromptSuccess, allKeywords)); }