예제 #1
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="editRequest"></param>
        /// <returns></returns>
        public async Task <ResponseMessage <bool> > PermissionitemAddAsync(PermissionEditRequest editRequest)
        {
            var response = new ResponseMessage <bool>()
            {
                Extension = false
            };

            if (editRequest == null)
            {
                throw new ArgumentNullException();
            }

            if (await _permissionStore.IQueryableListAsync().Where(y => y.Name == editRequest.Name).AnyAsync())
            {
                throw new ZCustomizeException(ResponseCodeEnum.ObjectAlreadyExists, "已经存在该权限名称");
            }
            var permissionitem = _mapper.Map <Permissionitem>(editRequest);

            permissionitem.Id         = Guid.NewGuid().ToString();
            permissionitem.CreateTime = DateTime.Now;
            response.Extension        = await _permissionStore.AddEntityAsync(permissionitem);

            return(response);
        }