/// <summary> /// 更新数据 /// </summary> public async Task <DataTagDto> Update(DataTagInputDto input) { try { DataTagEntity entity = new DataTagEntity { Id = input.Id, TagName = input.TagName, TagDesc = input.TagDesc, DictCodeID = input.DictCodeID }; var query = await _IDataTagRepository.UpdateAsync(entity); var result = entity.MapTo <DataTagDto>(); return(result); } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// 新增数据 /// </summary> public async Task <DataTagDto> Insert(DataTagInputDto input) { try { input.Id = Guid.NewGuid().ToString(); DataTagEntity entity = new DataTagEntity { Id = input.Id, TagName = input.TagName, TagDesc = input.TagDesc, DictCodeID = input.DictCodeID }; var query = await _IDataTagRepository.InsertAsync(entity); var result = entity.MapTo <DataTagDto>(); return(result); } catch (Exception ex) { throw new Exception(ex.Message); } }
public bool MultiInsert(TagDto tagDto) { try { string tagName = tagDto.tagName; string dataID = tagDto.dataID; string mapLayerID = tagDto.mapLayerID; _ITagReleationRepository.Delete(q => q.MapID == mapLayerID); string multiTagID = ""; string[] arr; if (!string.IsNullOrEmpty(tagName)) { tagName = tagName.Replace(",", ",").Replace(" ", ",").Replace(" ", ","); if (tagName.Contains(",")) { arr = tagName.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); } else { arr = new string[] { tagName }; } for (int i = 0; i < arr.Length; i++) { string tagID = ""; var name = arr[i]; var ret = _IDataTagRepository.GetAll().Where(q => q.TagName == name && q.DictCodeID == dataID).FirstOrDefault(); if (ret != null && ret.Id != null) { tagID = ret.Id; } else { DataTagEntity entity = new DataTagEntity(); entity.Id = Guid.NewGuid().ToString(); entity.TagName = arr[i]; entity.DictCodeID = dataID; tagID = _IDataTagRepository.InsertAndGetId(entity); } if (!string.IsNullOrEmpty(tagID)) { TagReleationEntity rel = new TagReleationEntity(); rel.Id = Guid.NewGuid().ToString(); rel.MapID = mapLayerID; rel.DataTagID = tagID; multiTagID += _ITagReleationRepository.InsertAndGetId(rel) + ","; } } return(true); } else { return(true); } } catch (Exception ex) { return(false); } }