public ActionResult StorePurchase(int passId, int userId) { Pass_Log pl = db.processPurchase(db.getClassPasse(passId), userId, "IN-STORE"); Yoga_User u = db.getUserById(userId); EmailSender.sendPurchaseConfirmation(u, pl, "In-Store"); return(RedirectToAction("SuccessView")); }
public ActionResult SalesMonth(FormCollection collection) { // get the date in form collection try { DateTime date = DateTime.Parse(collection["datepicker"]); DateTime date2 = date.AddMonths(1); //get list with this time constraint IEnumerable <Database.Pass_Log> saleList = db.GetSaleReport(date, date2); List <SaleReportViewModel> list = new List <SaleReportViewModel>(); foreach (var sale in saleList) { SaleReportViewModel saleReport = new SaleReportViewModel(); var classPass = db.getClassPasse(sale.Pass_Id); var user = db.getUserById(sale.U_Id); saleReport.Pass_Log_Id = sale.Pass_Log_Id; saleReport.Pass_Id = sale.Pass_Id; saleReport.Pass_Name = classPass.Pass_Name; saleReport.U_Id = sale.U_Id; saleReport.U_First_Name = user.U_First_Name; saleReport.U_Last_Name = user.U_Last_Name; saleReport.Num_Classes = sale.Num_Classes.GetValueOrDefault(); saleReport.Purchase_Price = Convert.ToDouble(sale.Purchase_Price); saleReport.Date_Purchased = sale.Date_Purchased; list.Add(saleReport); TempData["saleList"] = list; } }catch (Exception e) { TempData["Message"] = e.ToString(); return(RedirectToAction("MessageView")); } // redirect view with list of passlog return(RedirectToAction("SaleList")); }
public ActionResult EditClassPass(int id) { var classPassEdit = db.getClassPasse(id); ViewBag.EditClassPass = classPassEdit; return(View(classPassEdit)); }
public static void sendPurchaseConfirmation(Yoga_User user, Pass_Log pl, string purchaseType) { DBMaster db = new DBMaster(); Class_Passes pass = db.getClassPasse(pl.Pass_Id); Promotion p = db.getPromotionByPassId(pl.Pass_Id); SmtpClient client = new SmtpClient("smtp.gmail.com", 587); client.EnableSsl = true; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "xkcd1701"); MailMessage msobj = new MailMessage(); msobj.To.Add(user.U_Email); msobj.From = new MailAddress("*****@*****.**"); msobj.Subject = "Confirmation of " + purchaseType + " Purchase from Samsara Yoga"; msobj.IsBodyHtml = true; if (p == null || p.Promo_End < DateTime.Now.Date) { decimal tax = ((pass.Pass_Price) * (decimal).15); msobj.Body = "<h1 style='color:#557ee6;'>Saṃsāra Yoga</h1><p>Thank you for your recent " + purchaseType.ToLower() + " purchase from Samsara Yoga. Details of this transaction are below:</p><br/>Transaction ID: " + pl.Invoice_Number + "<br/>Transaction Date: " + pl.Date_Purchased + "<br/><br/>Purchased Item: " + pass.Pass_Name + "<br/><br/>‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑<br/><br/>Unit Price: " + pass.Pass_Price.ToString("F") + "<br/>Tax: " + tax.ToString("F") + "<br>Total: " + (tax + pass.Pass_Price).ToString("F") + "$"; client.Send(msobj); } else { if (p.Promo_End.Date > DateTime.Today && p.Num_Classes == 0) { decimal discount = decimal.Round((pass.Pass_Price * (decimal)p.Discount * -1), 2); decimal tax = ((pass.Pass_Price + discount) * (decimal).15); msobj.Body = "<h1 style='color:#557ee6;'>Saṃsāra Yoga</h1>" + "<p>Thank you for your recent " + purchaseType.ToLowerInvariant() + " purchase from Samsara Yoga. Details of this transaction are below:</p><br/>Transaction ID: " + pl.Invoice_Number + "<br/>Transaction Date: " + pl.Date_Purchased + "<br/><br/>Purchased Item: " + pass.Pass_Name + "<br/>Promotion: " + p.Promo_Desc + " " + (int)(p.Discount * 100) + "% Off<br/><br>‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑<br/><br/>Unit Price: " + pass.Pass_Price.ToString("F") + "<br/>Discount: " + discount.ToString("F") + "<br/><br/>Subtotal: " + (discount + pass.Pass_Price).ToString("F") + "<br/>Total: " + (tax + pass.Pass_Price + discount).ToString("F") + "$"; client.Send(msobj); } else { decimal tax = ((pass.Pass_Price) * (decimal).15); msobj.Body = "<h1 style='color:#557ee6;'>Saṃsāra Yoga</h1><p>Thank you for your recent " + purchaseType.ToLowerInvariant() + " purchase from Samsara Yoga. Details of this transaction are below:</p><br/>Transaction ID: " + pl.Invoice_Number + "<br/>Transaction Date: " + pl.Date_Purchased + "<br/><br/>Purchased Item: " + pass.Pass_Name + "<br/>Promotion: " + p.Promo_Desc + " +" + p.Num_Classes + " Passes<br/><br/>‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑<br/><br/>Unit Price: " + pass.Pass_Price.ToString("F") + "<br/>Tax: " + tax.ToString("F") + "<br>Total: " + (tax + pass.Pass_Price).ToString("F") + "$"; client.Send(msobj); } } }