public async Task <EmailNotificationViewModel> GetEmailDataAsync(int id) { var order = (await GetAllAsync(x => x.OrderId == id)).FirstOrDefault(); EmailNotificationViewModel emailData = ToEmailNotification(order); return(emailData); }
public EmailNotificationViewModel ToEmailNotification(Order order) { var emailData = new EmailNotificationViewModel(); emailData.AbsoluteUrl = host; emailData.Comments = order.CustomerComments; emailData.MercadoPagoTransaction = order.MercadoPagoTransaction; emailData.OrderItems = order.OrderLines; emailData.OrderCatalogItems = order.OrderCatalogItems; emailData.OrderCaterings = order.OrderCaterings; emailData.OrderReady = order.PickUpTimeFrom ?? order.PickUpTime; emailData.TimeLeftUntilStoreCloses = order.TimeLeftUntilStoreCloses; emailData.OrderTotal = order.OrderTotal; //Without MP interests emailData.TotalInStore = order.TotalInStore; emailData.OrderType = String.IsNullOrEmpty(order.MercadoPagoTransaction) ? "Reserva" : "Compra"; emailData.PreparationTime = order.PreparationTime; emailData.FriendlyBookingId = order.FriendlyBookingId; emailData.OrderId = order.OrderId.ToString(); emailData.Delivery = order.DeliveryAddress; emailData.Discount = order.Discount; emailData.Factura = order.Factura; emailData.CustomarAlias = order.Registration == null ? order.MercadoPagoName : order.Registration.FirstName; emailData.CustomarAlias = Regex.Replace(emailData.CustomarAlias.ToLower(), @"(^\w)|(\s\w)", m => m.Value.ToUpper()); return(emailData); }
public async Task <ActionResult> ForgotPassword(ForgotPasswordViewModel model) { if (ModelState.IsValid) { var user = await _userManager.FindByNameAsync(model.Email); if (user == null) { // Don't reveal that the user does not exist or is not confirmed return(View("ForgotPasswordConfirmation")); } // Send an email with this link string code = await _userManager.GeneratePasswordResetTokenAsync(user); var callbackUrl = Url.Action("ResetPassword", "Accounts", new { userId = user.Id, code = code }, protocol: Request.Scheme); // Send the email var emailNotification = new EmailNotificationViewModel { Email = user.Email, Subject = "SPINE - Password Reset", Content = "", Html = "Please reset your password by clicking <a href =\"" + callbackUrl + "\">here</a>" }; await notificationsController.SendEmailNotification(emailNotification); return(RedirectToAction("ForgotPasswordConfirmation", "Accounts")); } // If we got this far, something failed, redisplay form return(View(model)); }
public EmailNotificationViewModel GetEmailData(int id) { var order = GetOrder(id); EmailNotificationViewModel emailData = ToEmailNotification(order); return(emailData); }
public async Task <IActionResult> OrderComplete(int id) { Order order = await _orderRepository.GetOrderByIdAsync(id); if (order == null) { return(NotFound()); } else { EmailNotificationViewModel viewModel = _orderRepository.ToEmailNotification(order); return(View(viewModel)); } }
public IActionResult OrderComplete(int id) { Order order = _orderRepository.GetOrder(id); if (order == null) { return(NotFound()); } else { EmailNotificationViewModel viewModel = _orderRepository.ToEmailNotification(order); return(View(viewModel)); } }
public async Task <IActionResult> SendEmailNotification([FromBody] EmailNotificationViewModel model) { var apiKey = configuration.GetSection("SendGrid")["ApiKey"]; var client = new SendGridClient(apiKey); var from = new EmailAddress(configuration.GetSection("UserSettings")["UserEmail"]); EmailAddress to = new EmailAddress(model.Email); ErrorMessageViewModel errorMessage = new ErrorMessageViewModel(); var error = new { Error = errorMessage.Message }; if (model.Email == null || model.Subject == null || model.Content == null) { errorMessage.Message = "Email notification could not be sent"; return(Json(error)); } var htmlContent = String.IsNullOrWhiteSpace(model.Html) ? "" : model.Html; var message = MailHelper.CreateSingleEmail(from, to, model.Subject, model.Content, htmlContent); var response = await client.SendEmailAsync(message); return(Ok(response)); }