protected void EmailReceipt(string orderid) { //Get the order first thing to make sure we have it. ReceiptBindingModel Receipt = new ReceiptBindingModel(); try { var sqlQuery = "SELECT Orders.Id,OrderId,PayType,Grade,BookType,Teacher,PersText1,Studentfname,Studentlname,Emailaddress,Schcode,ItemAmount,Itemqty,Schinvoicenumber,Orddate,ItemTotal,Schname,Yr,l1.caption as Caption1,l2.caption As Caption2,l3.caption As Caption3,l4.caption As Caption4 FROM Orders Left Join lookup l1 On l1.ivalue=Orders.icon1 Left Join lookup l2 on l2.ivalue=Orders.icon2 Left Join lookup l3 on l3.ivalue=Orders.icon3 Left Join lookup l4 on l4.ivalue=Orders.icon4 where orderid=@OrderId"; MySqlParameter[] parameters = new MySqlParameter[] { new MySqlParameter("@OrderId", orderid) }; var sqlQueryService = new SQLQuery(); var orderResult = sqlQueryService.ExecuteReaderAsync <OrderBindingModel>(CommandType.Text, sqlQuery, parameters); if (!orderResult.Result.IsSuccessful) { ExceptionlessClient.Default.CreateLog(typeof(TempOrderController).FullName, orderResult.Result.Error.UserMessage, "Error"); } Receipt.Items = (List <OrderBindingModel>)orderResult.Result.Data; var hasAd = false; foreach (var order in Receipt.Items) { switch (order.BookType) { case "Full Page Ad": hasAd = true; break; case "1/2 Page Ad": hasAd = true; break; case "1/4 Page Ad": hasAd = true; break; case "1/8 Page Ad": hasAd = true; break; } } MySqlParameter[] payParameters = new MySqlParameter[] { new MySqlParameter("@OrderId", orderid) }; var sqlQueryService1 = new SQLQuery(); sqlQuery = "Select Schcode,PayerFname,PayerLname,Poamt,PayType,TransId, AuthCode,CustEmail,Ddate,OrderId,Schname from Payment where orderid=@OrderId"; var payResult = sqlQueryService.ExecuteReaderAsync <PaymentBindingModel>(CommandType.Text, sqlQuery, payParameters); if (!payResult.Result.IsSuccessful) { ExceptionlessClient.Default.SubmitLog(typeof(TempOrderController).FullName, orderResult.Result.Error.UserMessage, "Error"); } List <PaymentBindingModel> payments = (List <PaymentBindingModel>)payResult.Result.Data; PaymentBindingModel payment = payments[0];//should only be one payment Receipt.Schname = payment.Schname; Receipt.Schcode = payment.Schcode; Receipt.PayerFname = payment.PayerFname; Receipt.PayerLname = payment.PayerLname; Receipt.Payment = payment.Poamt; Receipt.PayType = payment.PayType; Receipt.TransId = payment.TransId; Receipt.AuthCode = payment.AuthCode; Receipt.OrderId = payment.OrderId; Receipt.CustomerEmail = payment.CustEmail; Receipt.OrderDate = payment.Ddate; Receipt.Payment = payment.Poamt; var body = ""; var hbody = "<div class='form-group col-md-12'><label style = 'font-size:x-large' ><strong>Thank you for your payment</strong></label></div>" + "<div class='form-group'><div class='col-sm-6'><strong>School Name: </strong>" + payment.Schname + "</div></div>" + "<div class='form-group'> <div class='col-sm-6'><strong>School Code: </strong>" + payment.Schcode + "</div></div>" + " <div class='form-group'> <div class='col-sm-6'><strong>Payer Name: </strong>" + payment.PayerFname + " " + payment.PayerLname + "</div></div>" + " <div class='form-group'> <div class='col-sm-6'><strong>Order Date: </strong>" + payment.Ddate.ToString("MM/dd/yyyy") + "</div></div>" + "<div class='form-group'> <div class='col-sm-6'><strong>Order Id: </strong>" + payment.OrderId + "</div></div>" + "<div class='form-group'> <div class='col-sm-6'><strong>Pay Type: </strong>" + payment.PayType + "</div></div>" + "<div class='form-group'><div class='col-sm-6'><strong>Transaction Id: </strong>" + payment.TransId + "</div></div>" + "<div class='form-group'><div class='col-sm-6'><strong>Authorization Code: </strong>" + payment.AuthCode + "</div></div>" + "<div class='form-group'><div class='col-sm-6'><strong>Amount Paid: </strong>$" + payment.Poamt + "</div> </div><div></div>"; body = hbody; if (hasAd) { body = body + "<div style = 'font-size:larger' ><strong ><a href = 'http://mbcadpages.v5.pressero.com/' target = '_blank'> You have ordered an ad. Click here to configure your ad. (http://mbcadpages.v5.pressero.com/)</a></strong></div>"; } body = body + "<div style='color: red; margin - bottom:5px'><i>If you have questions about your order contact your school's yearbook advisor. </i></div><hr>"; foreach (var order in Receipt.Items) { var items = "<div style='margin:7px'><table>" + "<tr><td style='text-align:right'><strong> Item Quantity: </strong ></td><td>" + order.Itemqty + "</td></tr>" + "<tr><td style='text-align:right'><strong> Item: </strong></td><td> " + order.BookType + "</td></tr>" + "<tr><td style='text-align:right'><strong> Student Name: </strong></td><td> " + order.Studentfname + " " + order.Studentlname + "</td></tr>" + "<tr><td style='text-align:right'><strong> Teacher: </strong></td><td>" + order.Teacher + "</td></tr>" + "<tr><td style='text-align:right'><strong> Grade: </strong></td><td>" + order.Grade + "</td></tr>"; var text = ""; if (order.PersText1 != "" && order.PersText1 != "Not Available") { if (order.BookType == "Love Line") { text = "<tr><td style='text-align:right'><strong>Love Line: </strong></td><td >" + order.PersText1 + "</td></tr>"; items = items + text; } else if (order.BookType != "Love Line" && order.PersText1 != "") { text = "<tr><td style='text-align:right'><strong>Personalized Text :</strong></td><td>" + order.PersText1 + "</td></tr>"; items = items + text; } } var icontext = ""; if (order.BookType == "Personalized Ink Yearbook" || order.BookType == "Personalized Foil Yearbook") { icontext = "<tr><td style='text-align:right'><strong>Icons: </strong></td><td style='font-size:xx-small'><i>" + order.Caption1 + " " + order.Caption2 + " " + order.Caption3 + " " + order.Caption4 + "</i></td></tr>"; items = items + icontext; } items = items + "<tr><td style='text-align:right'>Item Amount: </td><td>$" + order.ItemTotal + "</td ></tr></table></div><div></div><hr>"; body = body + items; } var emailhelper = new Utilities.EmailHelper(); emailhelper.SendEmail("Receipt for a Parent Payment to Memory Book Company (Transaction Id " + Receipt.TransId + ") Using " + Receipt.PayType + " " + DateTime.Now.ToShortDateString(), Receipt.CustomerEmail, "", "*****@*****.**", body, Utils.EmailType.Mbc); } catch (Exception ex) { ex.ToExceptionless() .MarkAsCritical() .SetMessage("Failed to send receipt email.") .Submit(); } }
protected void EmailSchoolReceipt(string transid) { //Get the order first thing to make sure we have it. ReceiptBindingModel Receipt = new ReceiptBindingModel(); try { var sqlQuery = "SELECT Schname,Schcode,PayerFname,PayerLname,Poamt,PayType,TransId,AuthCode,CustEmail,Ddate,OrderId from Payment where transid=@Transid"; MySqlParameter[] parameters = new MySqlParameter[] { new MySqlParameter("@Transid", transid) }; var sqlQueryService = new SQLQuery(); var payResult = sqlQueryService.ExecuteReaderAsync <PaymentBindingModel>(CommandType.Text, sqlQuery, parameters); if (!payResult.Result.IsSuccessful) { ExceptionlessClient.Default.CreateLog(typeof(OrderController).FullName, payResult.Result.Error.UserMessage, "Error"); } List <PaymentBindingModel> payments = (List <PaymentBindingModel>)payResult.Result.Data; PaymentBindingModel payment = payments[0];//should only be one payment Receipt.Schname = payment.Schname; Receipt.Schcode = payment.Schcode; Receipt.PayerFname = payment.PayerFname; Receipt.PayerLname = payment.PayerLname; Receipt.Payment = payment.Poamt; Receipt.PayType = payment.PayType; Receipt.TransId = payment.TransId; Receipt.AuthCode = payment.AuthCode; Receipt.OrderId = payment.OrderId; Receipt.CustomerEmail = payment.CustEmail; Receipt.OrderDate = payment.Ddate; Receipt.Payment = payment.Poamt; var body = ""; var hbody = "<div class='form-group col-md-12'><label style = 'font-size:x-large' ><strong>Thank you for your payment</strong></label></div>" + "<div class='form-group'><div class='col-sm-6'><strong>School Name: </strong>" + payment.Schname + "</div></div>" + "<div class='form-group'> <div class='col-sm-6'><strong>School Code: </strong>" + payment.Schcode + "</div></div>" + " <div class='form-group'> <div class='col-sm-6'><strong>Payer Name: </strong>" + payment.PayerFname + " " + payment.PayerLname + "</div></div>" + " <div class='form-group'> <div class='col-sm-6'><strong>Order Date: </strong>" + payment.Ddate.ToString("MM/dd/yyyy") + "</div></div>" + "<div class='form-group'> <div class='col-sm-6'><strong>Pay Type: </strong>" + payment.PayType + "</div></div>" + "<div class='form-group'><div class='col-sm-6'><strong>Transaction Id: </strong>" + payment.TransId + "</div></div>" + "<div class='form-group'><div class='col-sm-6'><strong>Authorization Code: </strong>" + payment.AuthCode + "</div></div>" + "<div class='form-group'><div class='col-sm-6'><strong>Amount Paid: </strong>$" + payment.Poamt + "</div> </div><div></div>"; body = hbody; //body = body + "<div style='color: red; margin - bottom:5px'><i>If you have questions about your order contact your schools yearbook advisor. </i></div><hr>"; var emailhelper = new Utilities.EmailHelper(); emailhelper.SendEmail("Receipt for a School Payment to Memory Book Company (Transaction Id " + Receipt.TransId + ") Using " + Receipt.PayType + " " + DateTime.Now.ToShortDateString(), Receipt.CustomerEmail, "", "*****@*****.**", body, Utils.EmailType.Mbc); } catch (Exception ex) { ex.ToExceptionless() .MarkAsCritical() .SetMessage("Failed to send receipt email.") .Submit(); } }