예제 #1
0
        public async Task AddNewSubscriber(CreateSubscriberRequest request)
        {
            var(email, subscribed) = request;
            if (string.IsNullOrWhiteSpace(email))
            {
                throw new ArgumentNullException(email);
            }

            try
            {
                await _subscriberRepository.AddNewSubscriber(email, subscribed);
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("PRIMARY KEY"))
                {
                    throw new DuplicateEmailException();
                }
            }
        }