public async Task <DictionaryDetailDto> Create(CreateOrUpdateDictionaryDetailDto input)
        {
            var master = await _masterRepository.FirstOrDefaultAsync(_ => _.Id == input.Pid);

            if (master == null)
            {
                throw new BusinessException("未找到字典!");
            }

            var exist = await _detailRepository.FirstOrDefaultAsync(_ => _.Label == input.Label);

            if (exist != null)
            {
                throw new BusinessException("名称:" + input.Label + "字典已存在");
            }

            //var top = await _detailRepository.OrderByDescending(_ => _.Sort).FirstAsync();
            //if (top != null)
            //{

            //}

            var result = await _detailRepository.InsertAsync(new DataDictionaryDetail(
                                                                 GuidGenerator.Create(),
                                                                 input.Pid,
                                                                 input.Label,
                                                                 input.Value,
                                                                 0));   //TODO:Sort排序

            return(ObjectMapper.Map <DataDictionaryDetail, DictionaryDetailDto>(result));
        }
        public async Task <DictionaryDetailDto> Create(CreateOrUpdateDictionaryDetailDto input)
        {
            var master = await _masterRepository.FirstOrDefaultAsync(_ => _.Id == input.Pid);

            if (master == null)
            {
                throw new BusinessException("未找到字典!");
            }

            var exist = await _detailRepository.FirstOrDefaultAsync(_ => _.Label == input.Label);

            if (exist != null)
            {
                throw new BusinessException("名称:" + input.Label + "字典已存在");
            }

            var result = await _detailRepository.InsertAsync(new DataDictionaryDetail(
                                                                 GuidGenerator.Create(),
                                                                 CurrentTenant.Id,
                                                                 input.Pid,
                                                                 input.Label,
                                                                 input.Value,
                                                                 input.Sort));

            return(ObjectMapper.Map <DataDictionaryDetail, DictionaryDetailDto>(result));
        }
        public async Task <DictionaryDetailDto> Update(Guid id, CreateOrUpdateDictionaryDetailDto input)
        {
            var detail = await _detailRepository.GetAsync(id);

            detail.Label = input.Label;
            detail.Value = input.Value;
            detail.Sort  = input.Sort;

            return(ObjectMapper.Map <DataDictionaryDetail, DictionaryDetailDto>(detail));
        }
Ejemplo n.º 4
0
 public Task <DictionaryDetailDto> Update(Guid id, CreateOrUpdateDictionaryDetailDto input)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 5
0
 public Task <DictionaryDetailDto> Update(Guid id, CreateOrUpdateDictionaryDetailDto input)
 {
     return(_dictionaryDetailAppService.Update(id, input));
 }
Ejemplo n.º 6
0
 public Task <DictionaryDetailDto> Create(CreateOrUpdateDictionaryDetailDto input)
 {
     return(_dictionaryDetailAppService.Create(input));
 }