public ActionResult proc() { var json = new StreamReader(Request.Body).ReadToEnd(); var data = JsonConvert.DeserializeObject <JGN_Tags>(json); if (data.title.Length < 3) { return(Ok(new { status = "error", message = SiteConfig.generalLocalizer["_invalid_title"].Value })); } if (UtilityBLL.isLongWordExist(data.title) || UtilityBLL.isLongWordExist(data.title)) { return(Ok(new { status = "error", message = SiteConfig.generalLocalizer["_invalid_title"].Value })); } dynamic CategoryContentType = 1; if (data.id > 0) { // Update Operation TagsBLL.Update(_context, data); } else { // Add Operation TagsBLL.Add(_context, data.title, (TagsBLL.Types)data.type, data.records, data.term); } return(Ok(new { status = "success", id = data.id, message = SiteConfig.generalLocalizer["_records_processed"].Value })); }
/// <summary> /// 保存标签 /// </summary> public string SaveTagsData() { var service = new TagsBLL(CurrentUserInfo); TagsEntity tags = new TagsEntity(); string content = string.Empty; var responseData = new ResponseData(); string key = string.Empty; string tags_id = string.Empty; if (Request("tags") != null && Request("tags") != string.Empty) { key = Request("tags").ToString().Trim(); } if (Request("TagsId") != null && Request("TagsId") != string.Empty) { tags_id = Request("TagsId").ToString().Trim(); } tags = key.DeserializeJSONTo <TagsEntity>(); if (tags.TagsName == null || tags.TagsName.Trim().Length == 0) { responseData.success = false; responseData.msg = "标签名称不能为空"; return(responseData.ToJSON()); } bool status = true; string message = "保存成功"; if (tags.TagsId.Trim().Length == 0) { tags.TagsId = Utils.NewGuid(); tags.CustomerId = this.CurrentUserInfo.CurrentUser.customer_id; service.Create(tags); } else { tags.TagsId = tags_id; service.Update(tags, false); } responseData.success = status; responseData.msg = message; content = responseData.ToJSON(); return(content); }
public string SaveTagsType(string pRequest) { var rp = pRequest.DeserializeJSONTo <APIRequest <SaveTagsTypeRP> >(); var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; var rd = new SaveTagsTypeRD();//返回值 var _TagsTypeInfo = rp.Parameters.TagsTypeInfo; if (string.IsNullOrEmpty(_TagsTypeInfo.TypeName)) { throw new APIException("缺少参数【TypeName】或参数值为空") { ErrorCode = 135 }; } TagsTypeEntity TagsTypeEn = new TagsTypeEntity(); bool isNew = false; if (string.IsNullOrEmpty(_TagsTypeInfo.TypeId)) { _TagsTypeInfo.TypeId = Guid.NewGuid().ToString(); isNew = true; } TagsTypeEn.TypeId = _TagsTypeInfo.TypeId; TagsTypeEn.TypeName = _TagsTypeInfo.TypeName; TagsTypeEn.LastUpdateBy = loggingSessionInfo.UserID; TagsTypeEn.LastUpdateTime = DateTime.Now; TagsTypeEn.IsDelete = 0; string error = ""; //service.SaveProp(propInfo, ref error); TagsTypeBLL TagsTypeBLL = new TagsTypeBLL(loggingSessionInfo); if (isNew) { TagsTypeEn.CreateBy = loggingSessionInfo.UserID; TagsTypeEn.CreateTime = DateTime.Now; TagsTypeBLL.Create(TagsTypeEn); } else { TagsTypeBLL.Update(TagsTypeEn, false); } TagsBLL TagsBLL = new TagsBLL(loggingSessionInfo); if (!isNew)//不是新的 { string propIds = ""; foreach (var itemInfo in _TagsTypeInfo.TagsList)//数组,更新数据 { if (!string.IsNullOrEmpty(itemInfo.TagsId)) { if (propIds != "") { propIds += ","; } propIds += "'" + itemInfo.TagsId + "'"; } } //删除不在这个里面的 if (!string.IsNullOrEmpty(propIds)) { TagsBLL.DeleteByIds(propIds, TagsTypeEn); } } foreach (var itemInfo in _TagsTypeInfo.TagsList)//数组,更新数据 { TagsEntity TagsEn = new TagsEntity(); TagsEn.TagsName = itemInfo.TagsName; TagsEn.TagsDesc = itemInfo.TagsName; TagsEn.LastUpdateBy = rp.UserID; TagsEn.LastUpdateTime = DateTime.Now; TagsEn.IsDelete = 0; TagsEn.CustomerId = loggingSessionInfo.ClientID; TagsEn.TypeId = TagsTypeEn.TypeId; if (string.IsNullOrEmpty(itemInfo.TagsId)) { TagsEn.TagsId = Guid.NewGuid().ToString(); TagsEn.CreateBy = rp.UserID; TagsEn.CreateTime = DateTime.Now; TagsBLL.Create(TagsEn); } else { TagsEn.TagsId = itemInfo.TagsId; TagsBLL.Update(TagsEn, false); } } var rsp = new SuccessResponse <IAPIResponseData>(rd); return(rsp.ToJSON()); }