Example #1
0
        public void CreateOrUpdatePhoneBook(Domain.Models.PhoneBook phoneBook)
        {
            var existingPhoneBook = GetPhoneBookById(phoneBook.Id);

            if (existingPhoneBook == null)
            {
                _phoneBookRepository.Add(phoneBook);
            }
            else
            {
                _phoneBookRepository.Detach(existingPhoneBook);
                existingPhoneBook.Name    = phoneBook.Name;
                existingPhoneBook.Entries = phoneBook.Entries;
                _phoneBookRepository.Edit(existingPhoneBook);
            }

            _phoneBookRepository.Save();
        }