using System; using System.Threading.Tasks; using Flexitime.Objects; using FlexitimeAPI.Exceptions; using FlexitimeAPI.Interfaces; namespace FlexitimeAPI.Services { public class IdentifierService : IIdentifierService { private readonly IUserService _userService; public IdentifierService(IUserService userService) { _userService = userService; } public async Task Associate(Identifier identifier, Guid userId) { var user = await _userService.GetById(userId); if (user == null) { throw new InvalidUserIdException(userId); } user.AssociatedIdentifiers.Add(identifier); await _userService.Update(user); } } }