Ejemplo n.º 1
0
        public ActionResult <MessageDto> Send(MessageDto message)
        {
            Message savedMessage = _messageCreatorService.Save(mapper.FromDtoToDomain(message));

            if (savedMessage == null)
            {
                return(NotFound());
            }

            try
            {
                _messageSender.Send(savedMessage);
            }
            catch (Exception ex)
            {
                var exception = new SendEmailException("Error sending email", ex);
                exception.Data["MessageId"] = savedMessage.Id;

                _logger.LogError(exception, "Error sending email");
                throw exception;
            }

            return(Ok(mapper.FromDomainToDto(savedMessage)));
        }