public async Task SeedAsync(DataSeedContext context) { if (await _dataDictionaryRepository.GetCountAsync() == 0) { var dict1 = new Dict(_guidGenerator.Create(), context.TenantId, "Sex", "性别", "性别信息。", new List <DataDictionaryItem>()); dict1.AddOrUpdateItem("1", "男", "男性"); dict1.AddOrUpdateItem("2", "女", "女性"); dict1.AddOrUpdateItem("3", "未知", "未知性别"); var dict2 = new Dict(_guidGenerator.Create(), context.TenantId, "Level", "等级", "等级信息", new List <DataDictionaryItem>()); dict2.AddOrUpdateItem("1", "一级", "一级"); dict2.AddOrUpdateItem("2", "二级", "二级"); dict2.AddOrUpdateItem("3", "三级", "三级"); dict2.AddOrUpdateItem("4", "四级", "四级"); await _dataDictionaryRepository.InsertAsync(dict1); await _dataDictionaryRepository.InsertAsync(dict2); } }
public async Task <DataDictionaryDto> CreateAsync(DataDictionaryCreateDto input) { var newDict = new DataDictionary(GuidGenerator.Create(), CurrentTenant.Id, input.Code, input.DisplayText, input.Description, new List <DataDictionaryItem>(), input.IsStatic); foreach (var itemDto in input.Items) { newDict.AddOrUpdateItem(itemDto.Code, itemDto.DisplayText, itemDto.Description); } await _dataDictionaryManager.CreateAsync(newDict); return(ObjectMapper.Map <DataDictionary, DataDictionaryDto>(newDict)); }