/// <summary> /// 新增 /// </summary> /// <param name="editRequest"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public async Task <ResponseMessage <bool> > RoleAddAsync(RoleEditRequest editRequest, CancellationToken cancellationToken = default(CancellationToken)) { var response = new ResponseMessage <bool>() { Extension = false }; if (editRequest == null) { throw new ArgumentNullException(); } var isexist = await _roleStore.IQueryableListAsync().Where(item => item.Name == editRequest.Name).FirstOrDefaultAsync(cancellationToken); if (isexist != null) { throw new ZCustomizeException(ResponseCodeEnum.ObjectAlreadyExists, "该角色名称已存在"); } var role = _mapper.Map <Role>(editRequest); role.CreateTime = DateTime.Now; role.Id = Guid.NewGuid().ToString(); response.Extension = await _roleStore.AddEntityAsync(role); return(response); }