예제 #1
0
        protected virtual async Task <BookTagEditDto> Create(BookTagEditDto input)
        {
            //TODO:新增前的逻辑判断,是否允许新增
            // var entity = ObjectMapper.Map <BookTag>(input);
            var entity = input.MapTo <BookTag>();

            entity = await _entityRepository.InsertAsync(entity);

            return(entity.MapTo <BookTagEditDto>());
        }
예제 #2
0
        protected virtual async Task Update(BookTagEditDto input)
        {
            //TODO:更新前的逻辑判断,是否允许更新

            var entity = await _entityRepository.GetAsync(input.Id.Value);

            input.MapTo(entity);

            // ObjectMapper.Map(input, entity);
            await _entityRepository.UpdateAsync(entity);
        }
예제 #3
0
        public virtual async Task <BookTagEditDto> Create(BookTagEditDto input)         //
        {
            //TODO:新增前的逻辑判断,是否允许新增
            var entity = input.MapTo <BookTag>();
            var result = await CheckForDuplicateNamesAsync(entity.TagName);

            if (result.result)
            {
                return(result.entity.MapTo <BookTagEditDto>());
            }
            var entityId = await _entityRepository.InsertAndGetIdAsync(entity);

            entity.Id = entityId;
            return(entity.MapTo <BookTagEditDto>());
        }
예제 #4
0
        protected virtual async Task Update(BookTagEditDto input)
        {
            //TODO:更新前的逻辑判断,是否允许更新

            var entity = await _entityRepository.GetAsync(input.Id.Value);

            input.MapTo(entity);

            var result = await CheckForDuplicateNamesAsync(entity.TagName); //

            if (result.result)                                              //
            {
                throw new UserFriendlyException("Tag标签名称重复。");              //
            }

            // ObjectMapper.Map(input, entity);
            await _entityRepository.UpdateAsync(entity);
        }
        public virtual async Task <BookTagEditDto> Create(BookTagEditDto input)
        {
            //TODO:新增前的逻辑判断,是否允许新增

            // var entity = ObjectMapper.Map <BookTag>(input);
            var entity = input.MapTo <BookTag>();

            var result = await CheckForDuplicateNamesAsync(entity.TagName);

            if (!result.result)
            {
                var entityid = await _entityRepository.InsertAndGetIdAsync(entity);

                entity.Id = entityid;
                return(entity.MapTo <BookTagEditDto>());
            }
            else
            {
                return(result.entity.MapTo <BookTagEditDto>());
            }
        }