public async Task <IActionResult> Order(
            [FromServices] IEmailSink emailSink,
            [FromServices] IWebHostEnvironment env,
            [FromServices] GetOrder getOrder,
            [FromServices] IEmailTemplateFactory etf)
        {
            if (env.IsProduction())
            {
                return(Ok());
            }

            var order = getOrder.ForUserById("dummy");
            // var templatePath = Path.Combine(env.WebRootPath, "email-templates", "order.liquid");
            // var templateString = await System.IO.File.ReadAllTextAsync(templatePath);
            // var template = Template.Parse(templateString);

            await emailSink.SendAsync(new SendEmailRequest
            {
                Subject = $"Order Placed, {order.Id}",
                To      = "*****@*****.**",
                Message = await etf.RenderShippingConfirmationAsync(order),// template.Render(Hash.FromAnonymousObject(OrderProjections.Project(order))),
                Html    = true,
            });

            return(Ok());
        }
예제 #2
0
        public IActionResult OnGet(string id,
                                   [FromServices] GetOrder getOrder)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(RedirectToPage("/Index"));
            }

            Order = getOrder.ForUserById(id);

            if (Order == null)
            {
                return(RedirectToPage("/Index"));
            }

            return(Page());
        }