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(); }
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); }
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(); }
public new void CheckUserIsAuthorizedForRace(Guid userId, Guid raceId, RaceAccessLevel minimumAccessLevel) { base.CheckUserIsAuthorizedForRace(userId, raceId, minimumAccessLevel); }