Пример #1
0
        public void UpdateEntry(PhoneBookDTO dto)
        {
            var phoneBook = repo.FindByID(dto.id);

            if (phoneBook == null)
            {
                throw new Exception("not found");
            }
            dto.ToEntity(phoneBook);
            repo.Update(phoneBook);

            KafkaMessage message = new KafkaMessage("phonebookUpdated", JsonConvert.SerializeObject(phoneBook.ToDTO()));

            producer.PublishAsync("phonebook-incoming", message);
        }
Пример #2
0
        public PhoneBookDTO SaveEntry(PhoneBookDTO dto)
        {
            PhoneBook phoneBook = dto.ToEntity();

            if (phoneBook.id != 0)
            {
                var book = repo.FindByID(phoneBook.id);
                if (book != null)
                {
                    repo.Update(phoneBook);
                    return(phoneBook.ToDTO());
                }
            }
            var entity = repo.Add(phoneBook);

            KafkaMessage message = new KafkaMessage("phonebookCreated", JsonConvert.SerializeObject(entity.ToDTO()));

            producer.PublishAsync("phonebook-incoming", message);

            return(entity.ToDTO());
        }
Пример #3
0
 public void InsertPhonebook(PhoneBookDTO dto)
 {
     repo.Insert(dto.ToEntity());
 }
Пример #4
0
 public void UpdatePhonebook(PhoneBookDTO dto)
 {
     repo.Update(dto.ToEntity());
 }
Пример #5
0
 public void DeletePhonebook(PhoneBookDTO dto)
 {
     repo.Delete(dto.ToEntity());
 }