예제 #1
0
        public async Task <UserTargeting> GetTarget(Guid id)
        {
            var userId         = authService.CurrentUserId();
            var userTargetings = unitOfWork.Repository <UserTargeting, Guid>();

            var target = await userTargetings.FirstOrDefaultAsync(UserTargeting.ById(id), "FeatureToggle,TargetRule");

            Guard.IsTrue(await hasEnvironmentPermission.ToRead(userId, target.EnvironmentId));
            return(target);
        }
예제 #2
0
        public async Task UpdatePerPercent(Guid id, int percent)
        {
            var userId         = authService.CurrentUserId();
            var userTargetings = unitOfWork.Repository <UserTargeting, Guid>();
            var target         = await userTargetings.FirstOrDefaultAsync(UserTargeting.ById(id), "TargetRule");

            Guard.IsTrue(await hasEnvironmentPermission.ToWrite(userId, target.EnvironmentId), "You don't have permissions to update");

            (target.TargetRule as TargetPercentage).Percent.SetNumber(percent);

            await unitOfWork.SaveAsync();
        }
예제 #3
0
        public async Task UpdatePerUser(Guid id, string property, string valuesList, TargetOption option)
        {
            var userId         = authService.CurrentUserId();
            var userTargetings = unitOfWork.Repository <UserTargeting, Guid>();
            var userTarget     = await userTargetings.FirstOrDefaultAsync(UserTargeting.ById(id), "TargetRule");

            Guard.IsTrue(await hasEnvironmentPermission.ToWrite(userId, userTarget.EnvironmentId), "You don't have permissions to update");

            (userTarget.TargetRule as TargetSpecificUsers).Update(property, option, valuesList);

            await unitOfWork.SaveAsync();
        }