public void AddContactInformationToPerson(ContactInformations model)
        {
            if (ConnectionExists())
            {
                using var channel = _connection.CreateModel();
                channel.QueueDeclare(queue: _queueName, durable: false, exclusive: false, autoDelete: false, arguments: null);

                var json = JsonConvert.SerializeObject(model);
                var body = Encoding.UTF8.GetBytes(json);

                channel.BasicPublish(exchange: "", routingKey: _queueName, basicProperties: null, body: body);
            }
        }
 public async void AddContactInformationToPerson(ContactInformations model)
 {
     try
     {
         await _mediator.Send(new CreateContactInformationCommand
         {
             ContactInformation = model
         });
     }
     catch (Exception ex)
     {
         // log an error message here
         Debug.WriteLine(ex.Message);
     }
 }
示例#3
0
        public async Task <bool> AddContactInformationToPerson(ContactInformations model, CancellationToken cancellationToken)
        {
            if (model == null)
            {
                throw new ArgumentNullException($"{nameof(AddContactInformationToPerson)} entity must not be null");
            }

            try
            {
                await ReportContext.ContactInformations.AddAsync(model, cancellationToken);

                return(await ReportContext.SaveChangesAsync(cancellationToken) > 0);
            }
            catch (Exception ex)
            {
                throw new Exception($"{nameof(model)} could not be saved: {ex.Message}");
            }
        }
 private void HandleMessage(ContactInformations model)
 {
     _contactInformationService.AddContactInformationToPerson(model);
 }