public IActionResult Get(Guid id) { var request = new ContactGet(id); using (var rpcClient = new ContactRpcClient <ContactGet, ContactGetResponse>(_connectionFactory, _encoding)) { var response = rpcClient.RemoteCall(request); return(Ok(response.Contact)); } }
private ContactGetResponse WorkHandler(ContactGet request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } var contactId = request.ContactId; var contact = _contactRepository.GetContact(contactId); var response = new ContactGetResponse(contact) { CorrelationId = request.CorrelationId }; return(response); }
public ContactGet DTOToProto(ContactDTO contactDTO) { if (contactDTO != null) { ContactGet contact = new ContactGet { IdCustomer = contactDTO.IdCustomer, Ddd = contactDTO.Ddd, Number = contactDTO.Number, Email = contactDTO.Email }; return(contact); } return(null); }
public ContactDTO ProtoToDTO(ContactGet proto) { if (proto != null) { ContactDTO contactDTO = new ContactDTO { Id = proto.Id, IdCustomer = proto.IdCustomer, Ddd = proto.Ddd, Number = proto.Number, Email = proto.Email }; return(contactDTO); } return(null); }
/// <summary> /// /// </summary> /// <param name="request"></param> /// <param name="context"></param> /// <returns></returns> public override Task <ContactsGet> List(Empty request, ServerCallContext context) { ContactsGet protos = new ContactsGet(); var contacts = _repositoryContato.List().ToList(); foreach (var contact in contacts) { var proto = new ContactGet { Id = contact.Id.Value, IdCustomer = contact.IdCustomer, Ddd = contact.Ddd, Number = contact.Number, Email = contact.Email }; protos.Items.Add(proto); } return(Task.FromResult(protos)); }