Beispiel #1
0
        public async Task Should_Update_DataDictionary_DisplayText()
        {
            // Arrange
            var updateDto = new DataDictionaryUpdateDto
            {
                Description = "用于展示民族信息。",
                DisplayText = "民族(已修改)",
                Items       = new List <DataDictionaryItemDto>
                {
                    new DataDictionaryItemDto
                    {
                        Code        = "1",
                        DisplayText = "回族"
                    }
                }
            };

            // Act
            var response = await _dataDictionaryAppService.UpdateAsync(_testData.DataDictionary1, updateDto);

            // Assert
            response.ShouldNotBeNull();
            response.Description.ShouldNotBeEmpty();
            response.DisplayText.ShouldBe("民族(已修改)");

            UsingDbContext(db =>
            {
                var query = db.Dictionaries
                            .Include(x => x.Items)
                            .FirstOrDefault(x => x.Code == "MZ");

                query.ShouldNotBeNull();
                query.Items.Count.ShouldBe(1);
            });
        }
Beispiel #2
0
        public async Task <DataDictionaryDto> UpdateAsync(Guid id, DataDictionaryUpdateDto input)
        {
            var dict = await _dataDictionaryRepository.GetAsync(id);

            dict.SetContent(input.DisplayText, input.Description);

            foreach (var itemDto in input.Items)
            {
                dict.AddOrUpdateItem(itemDto.Code, itemDto.DisplayText, itemDto.Description);
            }

            dict.Items.RemoveAll(item => !input.Items.Select(dtoItem => dtoItem.Code).Contains(item.Code));

            await _dataDictionaryManager.UpdateAsync(dict);

            return(ObjectMapper.Map <DataDictionary, DataDictionaryDto>(dict));
        }
Beispiel #3
0
 public Task <DataDictionaryDto> UpdateAsync(Guid id, DataDictionaryUpdateDto input) => _dataDictionaryAppService.UpdateAsync(id, input);