public void NotifyTransferFailed(string pOrderNumber, string reason, string customerEmail)
        {
            using (var lScope = new TransactionScope())
            {
                /*var orderNumber = Guid.Parse(pOrderNumber);
                 * using (var lContainer = new BookStoreEntityModelContainer())
                 * {
                 */

                using (BookStoreEntityModelContainer lContainer = new BookStoreEntityModelContainer())
                {
                    //NEED TO RE-ADD back the reset stock level
                    Order pOrder = lContainer.Orders.Find(Int32.Parse(pOrderNumber));

                    pOrder.ResetStockLevels();

                    //    var order = lContainer.Orders.Include("Customer").FirstOrDefault(pOrder => pOrder.OrderNumber == orderNumber);

                    EmailProvider.SendMessage(new EmailMessage()
                    {
                        ToAddress = customerEmail,
                        // Message = "There was an error in processsing your order " + pOrderNumber + " " + reason

                        Message = "There was an error in processsing your order " + pOrder.OrderNumber.ToString() + " " + reason


                                  // Message = "There was an error in processsing your order, get in contact with the BookStore team so we can help you out!"
                    });

                    lScope.Complete();
                }
            }
        }
        public void FundsTransferError(Guid pOrderGuid)
        {
            using (TransactionScope lScope = new TransactionScope())
            {
                using (BookStoreEntityModelContainer lContainer = new BookStoreEntityModelContainer())
                {
                    try
                    {
                        Console.WriteLine("Funds Transfer Error");
                        var pOrder = lContainer.Orders
                                     .Include("Customer").FirstOrDefault(x => x.OrderNumber == pOrderGuid);

                        EmailProvider.SendMessage(new EmailMessage()
                        {
                            ToAddress = pOrder.Customer.Email,
                            Message   = "You have insufficient funds in your bank account. Your order " + pOrderGuid + " has been cancelled."
                        });
                        lContainer.SaveChanges();
                        lScope.Complete();
                    }
                    catch (Exception lException)
                    {
                        Console.WriteLine("Error in FundsTransferError: " + lException.Message);
                        throw;
                    }
                }
            }
        }
 private void SendOrderFailedConfirmation(Order pOrder)
 {
     EmailProvider.SendMessage(new EmailMessage()
     {
         ToAddress = pOrder.Customer.Email,
         Message   = "Your order " + pOrder.OrderNumber + " has failed because there is not enough stock."
     });
 }
 private void SendOrderPlacedConfirmation(Order pOrder)
 {
     EmailProvider.SendMessage(new EmailMessage()
     {
         ToAddress = pOrder.Customer.Email,
         Message   = "Your order " + pOrder.OrderNumber + " has been placed"
     });
 }
 private void SendOrderErrorMessage(Order pOrder, Exception pException)
 {
     EmailProvider.SendMessage(new EmailMessage()
     {
         ToAddress = pOrder.Customer.Email,
         Message   = "There was an error in processsing your order " + pOrder.OrderNumber + ": " + pException.Message + ". Please contact Book Store"
     });
 }
Beispiel #6
0
 private void SendOrderCancelledConfirmation(String customerEmail, Guid orderEmail)
 {
     try
     {
         EmailProvider.SendMessage(new EmailMessage()
         {
             ToAddress = customerEmail,
             Message   = "Your order " + orderEmail + " has been cancelled"
         });
     }
     catch (Exception lException)
     {
         Console.WriteLine("=================Failed Email====================");
         Console.WriteLine("From: BookStore");
         Console.WriteLine("To: " + customerEmail);
         Console.WriteLine("Order ID: " + orderEmail);
         Console.WriteLine("Cancellation time: " + DateTime.Now);
         Console.WriteLine("Status: Order Cancelled, Email not sent");
         Console.WriteLine("==========================================" + "\n");
         Console.WriteLine("Failed to send email to customer about order cancellation");
     }
 }
Beispiel #7
0
 private void SendOrderConfirmedConfirmation(Order pOrder)
 {
     try
     {
         EmailProvider.SendMessage(new EmailMessage()
         {
             ToAddress = pOrder.Customer.Email,
             Message   = "Your order " + pOrder.OrderNumber + " has been accepted and processed!"
         });
     }
     catch (Exception lException)
     {
         Console.WriteLine("=================Failed Email====================");
         Console.WriteLine("From: BookStore");
         Console.WriteLine("To: " + pOrder.Customer.Email);
         Console.WriteLine("Order ID: " + pOrder.OrderNumber);
         Console.WriteLine("Message " + lException.Message);
         Console.WriteLine("OrderConfirmation time: " + DateTime.Now);
         Console.WriteLine("Status: FAILURE");
         Console.WriteLine("==========================================" + "\n");
     }
 }
Beispiel #8
0
 private void SendOrderDeletedErrorMessage(string pCustomerEmail, Guid pOrderId)
 {
     try
     {
         EmailProvider.SendMessage(new EmailMessage()
         {
             ToAddress = pCustomerEmail,
             Message   = "Just verifyng that your order of id " + pOrderId + " was cancelled and hence could not be delivered"
         });
     }
     catch (Exception lException)
     {
         Console.WriteLine("=================Email====================");
         Console.WriteLine("From: BookStore");
         Console.WriteLine("To: " + pCustomerEmail);
         Console.WriteLine("Order ID: " + pOrderId);
         Console.WriteLine("Transfer time: " + DateTime.Now);
         Console.WriteLine("Status: FAIED");
         Console.WriteLine("Message: " + lException.Message);
         Console.WriteLine("==========================================" + "\n");
         Console.WriteLine("Failed to send email to customer about error in processing order");
     }
 }
Beispiel #9
0
 private void SendOrderErrorMessage(Order pOrder, Exception pException)
 {
     try
     {
         EmailProvider.SendMessage(new EmailMessage()
         {
             ToAddress = pOrder.Customer.Email,
             Message   = "There was an error in processsing your order " + pOrder.OrderNumber + ": " + pException.Message + ". Please contact Book Store"
         });
     }
     catch (Exception lException)
     {
         Console.WriteLine("=================Email====================");
         Console.WriteLine("From: BookStore");
         Console.WriteLine("To: " + pOrder.Customer.Email);
         Console.WriteLine("Order ID: " + pOrder.OrderNumber);
         Console.WriteLine("Transfer time: " + DateTime.Now);
         Console.WriteLine("Message: " + lException.Message);
         Console.WriteLine("Status: FAILED");
         Console.WriteLine("==========================================" + "\n");
         Console.WriteLine("Failed to send email to customer about error in processing order");
     }
 }
        public void NotifyTransferSuccess(string pOrderNumber, string customerEmail)
        {
            using (var lScope = new TransactionScope())
            {
                using (BookStoreEntityModelContainer lContainer = new BookStoreEntityModelContainer())
                {
                    Order pOrder = lContainer.Orders.Find(Int32.Parse(pOrderNumber));


                    //    var order = lContainer.Orders.Include("Customer").FirstOrDefault(pOrder => pOrder.OrderNumber == orderNumber);
                    // try
                    // {
                    //   if (pOrder != null)
                    //   {

                    EmailProvider.SendMessage(new EmailMessage()
                    {
                        //  ToAddress = pOrder.Customer.Email,
                        ToAddress = customerEmail,
                        // Message = "Transaction was successful and your money has been transfered for your order number " + (pOrder.OrderNumber).ToString()
                        //  Message = "Transaction was successful and your money has been transfered for your order " + (pOrder.Id).ToString()
                        Message = "Transaction was successful and your money has been transfered for your order " + (pOrder.OrderNumber).ToString()
                    });

                    lScope.Complete();

                    /*}
                     * }
                     * catch (Exception lException)
                     * {
                     * SendOrderErrorMessage(pOrder, lException);
                     * throw;
                     * }
                     */
                }
            }
        }