コード例 #1
0
        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));
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        /// <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));
        }