Exemplo n.º 1
0
        public async Task <IActionResult> Post([FromBody] WebContact webContact)
        {
            var ip = HttpContext.Connection.RemoteIpAddress.ToString();

            IpStackClient client = new IpStackClient(_ipStackOptions.Key);

            webContact.SingleDetails = client.GetIpAddressDetails(ip);
            webContact.EmailTemplate = _emailOptions.Template;

            MailRequest request = new MailRequest
            {
                ToEmail = _emailOptions.ToAddress,
                Subject = _emailOptions.Subject,
                Body    = _emailService.CreateBody(webContact)
            };

            await _emailService.SendAsync(request);

            await _emailService.SendGridAsync(request);

            //https://www.pragimtech.com/blog/blazor/post-in-aspnet-core-rest-api/

            return(StatusCode(StatusCodes.Status200OK, "Success"));
        }