/// <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));
        }
        /// <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));
        }
Exemple #3
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <JsonResponse> Modify(RolesRequestDto input)
        {
            input.InitModifyRequest();
            var resJson = await _applicationEnginee.TryTransactionAsync(async() =>
            {
                await _rolesAppService.ModifyAsync(input);
            });

            return(resJson);
        }