Пример #1
0
        public Task RemoveEntryAsync(PhoneEntry entry)
        {
            if (_phoneEntryRepository.FindAsync(entry.PhoneNumber).GetAwaiter().GetResult() == null)
            {
                throw new ArgumentException();
            }

            return(_phoneEntryRepository.RemoveAsync(entry));
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="phoneEntry"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">Input parameters are null</exception>
        public Task AddAsync(PhoneEntry phoneEntry)
        {
            if (phoneEntry == null)
            {
                throw new ArgumentNullException(nameof(phoneEntry));
            }

            _phones.Add(phoneEntry);

            return(Task.FromResult(0));
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="phoneEntry"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">Input parameters are null</exception>
        public Task RemoveAsync(PhoneEntry phoneEntry)
        {
            if (phoneEntry == null)
            {
                throw new ArgumentNullException(nameof(phoneEntry));
            }

            var phoneToRemove = _phones.FirstOrDefault(x => x.PhoneNumber == phoneEntry.PhoneNumber);

            if (phoneToRemove != null)
            {
                _phones.Remove(phoneToRemove);
            }

            return(Task.FromResult(0));
        }