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); }
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()); }
public void InsertPhonebook(PhoneBookDTO dto) { repo.Insert(dto.ToEntity()); }
public void UpdatePhonebook(PhoneBookDTO dto) { repo.Update(dto.ToEntity()); }
public void DeletePhonebook(PhoneBookDTO dto) { repo.Delete(dto.ToEntity()); }