예제 #1
0
        public async Task Edit(Guid userId, Guid raceId, string emailaddress, RaceAccessLevel raceAccessLevel)
        {
            var editLink = await GetLink(userId, raceId, emailaddress);

            editLink.RaceAccess = raceAccessLevel;

            _unitOfWork.UserLinkRepository.Update(editLink);
            _unitOfWork.Save();
        }
예제 #2
0
        protected UserLink CheckUserIsAuthorizedForRace(Guid userId, Guid raceId, RaceAccessLevel minimumAccessLevel)
        {
            var userLink = GetRaceUserLink(userId, raceId);

            if (userLink == null || (int)userLink.RaceAccess > (int)minimumAccessLevel)
            {
                _logger.LogWarning($"Error in {GetType().Name}: User with ID '{userId}' tried to access race with ID '{raceId}' but is unauthorized.");
                throw new BusinessException($"User is not authorized for race.", BLErrorCodes.UserUnauthorized);
            }

            return(userLink);
        }
예제 #3
0
        public async Task Add(Guid userId, Guid raceId, string emailaddress, RaceAccessLevel raceAccessLevel)
        {
            CheckUserIsAuthorizedForRace(userId, raceId, RaceAccessLevel.Owner);

            var sharedUserId = await GetSharedUserId(emailaddress);

            _unitOfWork.UserLinkRepository.Insert(new UserLink
            {
                RaceId     = raceId,
                UserId     = sharedUserId,
                RaceAccess = raceAccessLevel
            });

            _unitOfWork.Save();
        }
예제 #4
0
 public new void CheckUserIsAuthorizedForRace(Guid userId, Guid raceId, RaceAccessLevel minimumAccessLevel)
 {
     base.CheckUserIsAuthorizedForRace(userId, raceId, minimumAccessLevel);
 }