Beispiel #1
0
        public async Task <bool> UpdateDicTypeAsync(DicTypeViewModel model)
        {
            var entity = await _dictypeRepository.GetAsync(model.Id);

            _mapper.Map(model, entity);
            await _unitOfWork.SaveAsync();

            return(true);
        }
Beispiel #2
0
        public async Task <bool> AddDicTypeAsync(DicTypeViewModel model)
        {
            var dictype = _mapper.Map <DicType>(model);
            await _dictypeRepository.AddAsync(dictype);

            await _unitOfWork.SaveAsync();

            return(true);
        }
Beispiel #3
0
        public async Task <IActionResult> Update(DicTypeViewModel dictypeViewModel)
        {
            var codeExist = _dicTypeService.HasSameCode(dictypeViewModel.Id, dictypeViewModel.Code);

            if (codeExist)
            {
                return(this.BadRequestResult("字典类型编码已经存在,请修改!"));
            }

            var isSuccess = await _dicTypeService.UpdateDicTypeAsync(dictypeViewModel);

            if (!isSuccess)
            {
                return(this.BadRequestResult("更新失败!"));
            }
            return(Ok());
        }
Beispiel #4
0
        public async Task <bool> UpdateDicTypeAsync(DicTypeViewModel model)
        {
            try
            {
                var entity = await _dictypeRepository.GetAsync(model.Id);

                _mapper.Map(model, entity);
                await _unitOfWork.SaveAsync();

                return(true);
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message);
                _logger.LogError(e.StackTrace);
                return(false);
            }
        }
Beispiel #5
0
        public async Task <bool> AddDicTypeAsync(DicTypeViewModel model)
        {
            try
            {
                var dictype = _mapper.Map <DicType>(model);
                await _dictypeRepository.AddAsync(dictype);

                await _unitOfWork.SaveAsync();

                return(true);
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message);
                _logger.LogError(e.StackTrace);
                return(false);
            }
        }