/// <summary> /// 维护所属下拉框及分组下拉框的状态 /// </summary> private SelectList GetTagGroupSelectList(long groupId, string tenantTypeId) { //分组下拉框 IEnumerable<TagGroup> tagGroups = tagService.GetGroups(tenantTypeId); SelectList groupList = null; //如果该租户下没有分组 if (tagGroups.Count() == 0) { groupList = new SelectList(new List<SelectListItem>() { new SelectListItem() { Text = "无分组", Value = "0" } }, "value", "text"); } else { TagGroup tagGroupEntity = new TagGroup(); tagGroupEntity.GroupName = "无分组"; tagGroupEntity.GroupId = 0; List<TagGroup> tagGroupsList = tagGroups.ToList<TagGroup>(); tagGroupsList.Insert(0, tagGroupEntity); groupList = new SelectList(tagGroupsList.Select(n => new { text = n.GroupName, value = n.GroupId }), "value", "text", groupId); } return groupList; }
/// <summary> /// 更新标签分组 /// </summary> /// <param name="group">待更新分组实体</param> public void DeleteGroup(TagGroup group) { tagGroupRepository.Delete(group); }
/// <summary> /// 创建标签分组 /// </summary> /// <param name="group">待创建分组实体</param> public bool CreateGroup(TagGroup group) { long objectId = Convert.ToInt64(tagGroupRepository.Insert(group)); return(objectId > 0); }
/// <summary> /// 更新标签分组 /// </summary> /// <param name="group">待更新分组实体</param> public void UpdateGroup(TagGroup group) { tagGroupRepository.Update(group); }
public ActionResult GetTagGroupsByTenantTypeId(string tenantTypeId) { TagService tagService = new TagService(string.Empty); IEnumerable<TagGroup> tagGroups = tagService.GetGroups(tenantTypeId); if (tagGroups.Count() == 0) { return Json(new { text = "无分组", value = "" }, JsonRequestBehavior.AllowGet); } TagGroup tagGroupEntity = new TagGroup(); tagGroupEntity.GroupName = "无分组"; tagGroupEntity.GroupId = 0; List<TagGroup> tagGroupsList = tagGroups.ToList<TagGroup>(); tagGroupsList.Insert(0, tagGroupEntity); return Json(tagGroupsList.Select(tagGroup => new { text = tagGroup.GroupName, value = tagGroup.GroupId }), JsonRequestBehavior.AllowGet); }