private string GetEstimateTotal(OrderFormModel model, PricingTier pricingTier ) { decimal price = model.EstimatedGallons * model.QuotedPricePerGallon; if (model.RequiresBurnerPriming && pricingTier != null) { price += pricingTier.BurnerPrimingFee; } return string.Format("{0:C}", price); }
private void SendRequestNotification(OrderFormModel model, PricingTier pricingTier) { var emailTemplate = Path.Combine(HttpContext.Request.PhysicalApplicationPath, @"App_Data\template-oil-delivery-submission-email.txt"); var customerTemplate = Path.Combine(HttpContext.Request.PhysicalApplicationPath, @"App_Data\template-oil-delivery-submission-customer-email.txt"); var smsTemplate = Path.Combine(HttpContext.Request.PhysicalApplicationPath, @"App_Data\template-oil-delivery-submission-sms.txt"); using (StreamReader streamReader = new StreamReader(emailTemplate, Encoding.ASCII)) { emailTemplate = streamReader.ReadToEnd(); } using (StreamReader streamReader = new StreamReader(smsTemplate, Encoding.ASCII)) { smsTemplate = streamReader.ReadToEnd(); } using (StreamReader streamReader = new StreamReader(customerTemplate, Encoding.ASCII)) { customerTemplate = streamReader.ReadToEnd(); } var formCollection = Request.Form; foreach (PropertyInfo prop in model.GetType().GetProperties()) { if (prop.PropertyType.IsPrimitive || prop.PropertyType.Equals(typeof(string)) || prop.PropertyType.IsValueType) { var value = prop.GetValue(model, null) ?? string.Empty; emailTemplate = emailTemplate.Replace(string.Format(@"{{{0}}}", prop.Name), value.ToString()); customerTemplate = customerTemplate.Replace(string.Format(@"{{{0}}}", prop.Name), value.ToString()); smsTemplate = smsTemplate.Replace(string.Format(@"{{{0}}}", prop.Name), value.ToString()); } } customerTemplate = customerTemplate.Replace(@"{BurnerPrimingFee}", GetBurnerPrimingFee( model, pricingTier )); customerTemplate = customerTemplate.Replace("{EstimatedPrice}", GetEstimateTotal(model, pricingTier)); customerTemplate = GetDisclaimers(customerTemplate, model); emailTemplate = GetDisclaimers( emailTemplate, model ); string[] recipients = ConfigurationManager.AppSettings["SmtpTo"].Split(','); UtilitySmtp.SendSmsMessage("Oil Delivery Request", smsTemplate, true); UtilitySmtp.SendSmtpMessage(recipients, "Oil Delivery Request", emailTemplate, true, true); UtilitySmtp.SendSmtpMessage(new[] { model.Email }, "Conger's Heating & Cooling: Your Oil Delivery Estimate Confirmation", customerTemplate, true, false); }
private string GetBurnerPrimingFee(OrderFormModel model, PricingTier pricingTier) { return model.RequiresBurnerPriming && pricingTier != null ? string.Format(@" <tr> <td><b>Burner Priming Fee:</b></td> <td>{0:C}</td> </tr>", pricingTier.BurnerPrimingFee) : ""; }