public async Task <bool> UpdateDicTypeAsync(DicTypeViewModel model) { var entity = await _dictypeRepository.GetAsync(model.Id); _mapper.Map(model, entity); await _unitOfWork.SaveAsync(); return(true); }
public async Task <bool> AddDicTypeAsync(DicTypeViewModel model) { var dictype = _mapper.Map <DicType>(model); await _dictypeRepository.AddAsync(dictype); await _unitOfWork.SaveAsync(); return(true); }
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()); }
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); } }
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); } }