using Microsoft.AspNetCore.Components;
using System.ComponentModel.DataAnnotations;
using Telerik.Blazor;
using Telerik.Blazor.Components;
using Telerik.SvgIcons;
using kmCommonLibsCore;
namespace SummerBestWebForm2.Components.Pages;
public partial class Home
{
async Task OnFinishHandler()
//private void SaveIt()
{
using (var em = new kmCommonLibsCore.Emails())
{
// Parsing the submitted form to pull the relevant information
string cardType = isPostcard ? "Postcard" : "Plastic Card";
string cardDesign = string.Empty;
if (designOne)
cardDesign = "A";
else if (designTwo)
cardDesign = "B";
else if (designThree)
cardDesign = "C";
// Postcard or Plastic specific options
string customizationInfo = string.Empty;
if (isPostcard)
{
string verseChoice = string.Empty;
string sigChoice = string.Empty;
if (verseOne)
verseChoice = "1";
else if (verseTwo)
verseChoice = "2";
else if (verseThree)
verseChoice = "3";
if (sigOne)
sigChoice = string.Format("Option D - From Your Friends At:
{0}
{1}", locationInfo.LocationName, locationInfo.PhoneNumber);
else if (sigTwo)
sigChoice = string.Format("Option E - Name: {0}
Title: {1}
Phone: {2}", customName, customTitle, customPhone);
else if (sigThree)
sigChoice = string.Format("Option F - {0}", customSignature);
// combine these into customizationInfo
customizationInfo = string.Format("Verse: {0}
Signature: {1}", verseChoice, sigChoice);
}
else // isPlasticCard
{
string smallOfferString = string.Empty;
string bigOfferString = string.Empty;
int[] smallIndexes = new int[4];
int[] bigIndexes = new int[2];
int smallCount = 0;
for (int index = 0; index < smallOffers.Length; index++)
{
if (smallOffers[index])
{
smallIndexes[smallCount] = index;
smallCount++;
}
}
int bigCount = 0;
for (int index = 0; index < bigOffers.Length; index++)
{
if (bigOffers[index])
{
bigIndexes[bigCount] = index;
bigCount++;
}
}
foreach (int index in smallIndexes)
{
switch (index)
{
case 0:
smallOfferString = smallOfferString + "B1 ";
break;
case 1:
smallOfferString = smallOfferString + "B2 ";
break;
case 2:
smallOfferString = smallOfferString + "B3 ";
break;
case 3:
smallOfferString = smallOfferString + "B4 ";
break;
case 4:
smallOfferString = smallOfferString + "B5 ";
break;
case 5:
smallOfferString = smallOfferString + "B6 ";
break;
case 6:
smallOfferString = smallOfferString + "B7 ";
break;
case 7:
smallOfferString = smallOfferString + "B8 ";
break;
case 8:
smallOfferString = smallOfferString + "B9 ";
break;
case 9:
smallOfferString = smallOfferString + "B10 ";
break;
case 10:
smallOfferString = smallOfferString + "B11 ";
break;
case 11:
smallOfferString = smallOfferString + "B12 ";
break;
}
}
foreach (int index in bigIndexes)
{
switch (index)
{
case 0:
bigOfferString = bigOfferString + "A1 ";
break;
case 1:
bigOfferString = bigOfferString + "A2 ";
break;
case 2:
bigOfferString = bigOfferString + "A3 ";
break;
case 3:
bigOfferString = bigOfferString + "A4 ";
break;
case 4:
bigOfferString = bigOfferString + "A5 ";
break;
case 5:
bigOfferString = bigOfferString + "A6 ";
break;
}
}
customizationInfo = string.Format("Offers: {0} - {1}", bigOfferString, smallOfferString);
}
// Logo info
string logos = string.Empty;
if (!goodyear && !michelin && !custom)
logos = "NA";
else
{
if (goodyear)
{
logos += "Goodyear";
if (michelin)
logos += ", Michelin";
if (custom)
logos += ", Custom";
}
else if (michelin)
{
logos += "Michelin";
if (custom)
logos += ", Custom";
}
else if (custom)
logos += "Custom";
}
// Payment info
string paymentMethod = string.Empty;
if (ccOnFile)
paymentMethod = "Credit Card on File";
else if (callWithInfo)
paymentMethod = "Call With Payment Info";
else if (check)
paymentMethod = "Check";
// Formulating the email to send
em.Subject = "SBC Order Form Submission";
em.AddAddress(enuAddressType.From, "support@keymotive.us", "Summer Growth Enrollment");
em.AddAddress(enuAddressType.To, "support@keymotive.us", "KeyMotive Support");
string locInfoString = string.Format("
Location Name: {0}"; try { em.Send(); await Console.Out.WriteLineAsync("Done sending"); } catch (Exception e) { await Console.Out.WriteLineAsync("ERROR: " + e.Message); } ShowWizard = false; await Dialogs.AlertAsync("The Registration was submitted successfully", "Done"); } } #region "User Selections - Model" public bool? IsAudienceChoiceValid { get; set; } = false; public bool? IsCardChoiceValid { get; set; } = false; public bool? IsDesignChoiceValid { get; set; } = false; [CascadingParameter] public DialogFactory Dialogs { get; set; } public bool ShowWizard { get; set; } = true; public int Value { get; set; } = 0; //public TelerikForm RegisterForm { get; set; } public User UserModel { get; set; } = new User(); public TelerikForm IntroForm { get; set; } = new(); // Variables for selecting between plastic and post public TelerikForm cardTypeForm { get; set; } = new(); public CardType cardType { get; set; } = new CardType(); public bool isPlasticCard { get; set; } = true; public bool isPostcard { get; set; } = false; public string audienceType { get; set; } = string.Empty; public List
Manager: {1}
Address: {2}
City: {3}
State: {4}
Zip: {5}
Phone Number: {6}
Contact Name: {7}
Contact Phone: {8}
Contact Email: {9}
", locationInfo.LocationName, locationInfo.Manager, locationInfo.Address, locationInfo.City, locationInfo.State, locationInfo.Zip, locationInfo.PhoneNumber, locationInfo.ContactName, locationInfo.ContactPhone, locationInfo.ContactEmail); string cardInfoString = string.Format("Card type: {0}, Design {1}
Customization Options:
{2}
Logos: {3}
", cardType, cardDesign, customizationInfo, logos); string paymentString = string.Format("Payment Method: {0}
Requested Quantity: {1}
Additional Comments: {2}", paymentMethod, requestedQuantity, additionalComments); em.HtmlBody = "You have a new enrollment:
" + locInfoString + cardInfoString + paymentString + "