Exemple #1
0
        public async Task <ServiceResponse <string> > SendCommunication(SendCommunicationCommand model)
        {
            var json     = JsonConvert.SerializeObject(model);
            var response = await client.PostAsync("/communications", new StringContent(json, Encoding.UTF8, "application/json"));

            var result = await response.ParseResponse <string>();

            return(result);
        }
Exemple #2
0
        public async Task <IActionResult> SendCommunication([FromBody] SendCommunicationCommand command)
        {
            var json = JsonConvert.SerializeObject(command);

            var message = new Message(Encoding.UTF8.GetBytes(json));

            await queueClient.SendAsync(message);

            return(NoContent());
        }
Exemple #3
0
        public async Task Handle(SendCommunicationCommand command)
        {
            //mock long running process
            Thread.SpinWait(2000);

            var contacts = await context.Contacts.ToListAsync();

            var emails = contacts.Select(x => x.Email);

            foreach (var email in emails)
            {
                Console.WriteLine($"Mock sending communications to {email}");
            }
        }
        public async Task <IActionResult> SendMessage(SendCommunicationCommand model)
        {
            if (!ModelState.IsValid)
            {
                return(View("Index", model));
            }

            var response = await communicationsService.SendCommunication(model);

            if (!response.Successful)
            {
                ModelState.AddModelError(string.Empty, response.ErrorMessage);
                return(View("Index", model));
            }

            return(View("SendMessage"));
        }