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()); }
public async Task Ship(string id) { var order = _orderManager.GetOrderById(id); order.Status = OrderStatus.Shipped; await _orderManager.UpdateOrder(order); var orderConfirmationMessage = await _emailTemplateFactory.RenderShippingConfirmationAsync(order); await _emailSink.SendAsync(new SendEmailRequest { To = order.Cart.Email, Subject = $"Raw Coding - Order Shipped - {order.Id}", Message = orderConfirmationMessage, }); }