public async Task <ActionResult> Order(int id) { OrdersProvider ordersProvider = new OrdersProvider(); SimpleOrderModel order = await ordersProvider.GetOrder(id); if (order.PaymentMethodId == 1) { return(this.View("Epay", order)); } return(this.Redirect("/order-accepted")); }
public void SendOrderStatusChangedMail(int orderId, int oldStatusId, int newStatusId) { if (oldStatusId == newStatusId) { return; } HostingEnvironmentPolyfills.QueueBackgroundWorkItemPf(async ct => { OrdersProvider ordersProvider = new OrdersProvider(); Task <OrderStatusModel> getNewStatusTask = ordersProvider.GetStatus(newStatusId); Task <OrderStatusModel> getOldStatusTask = ordersProvider.GetStatus(oldStatusId); OrderStatusChangedEmailModel emailModel = new OrderStatusChangedEmailModel(); emailModel.OrderNumber = orderId; SimpleOrderModel orderModel = await ordersProvider.GetOrder(orderId); string toEmailAddress; using (ApplicationDbContext appContext = new ApplicationDbContext()) { string userId = orderModel.UserId.ToString(); Address userAddress = await appContext.AddressInfos.FirstOrDefaultAsync(a => a.UserId == userId); emailModel.FullName = string.Format("{0} {1} {2}", userAddress.FirstName, userAddress.MiddleName, userAddress.LastName); toEmailAddress = userAddress.Email; } emailModel.BaseUrl = ConfigurationManager.AppSettings["Site.BaseUrl"]; OrderStatusModel newOrderStatus = await getNewStatusTask; OrderStatusModel oldOrderStatus = await getOldStatusTask; emailModel.NewOrderStatus = newOrderStatus.Name; emailModel.OldOrderStatus = oldOrderStatus.Name; string emailContent = templateEngine.RenderTemplate("OrderStatusChanged", emailModel); await this.mailSender.SendEmail(toEmailAddress, string.Format("{0}: Статусът на поръчка #{1} беше променен", emailModel.BaseUrl, orderId), emailContent); }); }