public async Task <ProjectPermission> AddProjectPermissionAsync(UpsertProjectPermissionParams ps)
        {
            if (await _context.ProjectPermissions.AsNoTracking().AnyAsync(pp => pp.ProjectKey == ps.ProjectKey && pp.Username == ps.Username))
            {
                throw new ConflictException($"Project permission {ps.Username}@{ps.ProjectKey} is already existing.");
            }

            var permission = _mapper.Map <ProjectPermission>(ps);

            await _context.ProjectPermissions.AddAsync(permission);

            await _context.SaveChangesAsync();

            return(permission);
        }
        public async Task <ProjectPermission> UpdateProjectPermissionAsync(UpsertProjectPermissionParams ps)
        {
            _cache.Remove($"project-permission-{ps.ProjectKey}-{ps.Username}");

            var oldPermission = await _context.ProjectPermissions.FirstOrDefaultAsync(pp => pp.ProjectKey == ps.ProjectKey && pp.Username == ps.Username);

            if (oldPermission == null)
            {
                throw new NotFoundException($"Project permission {ps.Username}@{ps.ProjectKey} cannot be found.");
            }

            _mapper.Map(ps, oldPermission);

            await _context.SaveChangesAsync();

            return(oldPermission);
        }