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); }
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(); }
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(); }