Ejemplo n.º 1
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="rolesRequestDto"></param>
        /// <returns></returns>
        public async Task <bool> CreateAsync(RolesRequestDto rolesRequestDto)
        {
            var roles = _mapper.Map <RolesRequestDto, Roles>(rolesRequestDto);
            await RolesValidatorsFilter.DoValidationAsync(_rolesRespository, roles, ValidatorTypeConstants.Create);

            return(await _rolesRespository.InsertAsync(roles));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 批量新增
        /// </summary>
        /// <param name="rolesRequestDtos"></param>
        /// <returns></returns>
        public async Task <bool> BatchCreateAsync(IList <RolesRequestDto> rolesRequestDtos)
        {
            var entities = rolesRequestDtos.MapToList <RolesRequestDto, Roles>();
            await RolesValidatorsFilter.DoValidationAsync(_rolesRespository, entities, ValidatorTypeConstants.Create);

            await _rolesRespository.BatchInsertAsync(entities);

            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="rolesRequestDto"></param>
        /// <returns></returns>
        public async Task <bool> ModifyAsync(RolesRequestDto rolesRequestDto)
        {
            var roles = await _rolesRespository.FirstOrDefaultAsync(e => e.Id == rolesRequestDto.Id);

            var entity = rolesRequestDto.MapToModifyEntity <RolesRequestDto, Roles>(roles);
            await RolesValidatorsFilter.DoValidationAsync(_rolesRespository, entity, ValidatorTypeConstants.Modify);

            return(await _rolesRespository.UpdateAsync(entity));
        }