Example #1
0
        /// <summary>
        /// Process the customer
        /// </summary>
        /// <param name="customer"></param>
        public void ProcessCustomer(Customer customer, string letterTemplateFilePath, string outputFolderPath)
        {
            try
            {   // Load the email template
                string templateText = String.Empty;
                templateText = fileProcessor.ReadTextFile(letterTemplateFilePath);

                // Get values for the email template tokens
                string outputText = String.Empty;
                if (String.IsNullOrEmpty(templateText))
                {
                    Console.WriteLine("Email template file has no content");
                    return;
                }
                outputText = LoadValues(templateText, customer);

                // Write the output file
                if (String.IsNullOrEmpty(outputText))
                {
                    Console.WriteLine("Output text not created for customer - " + customer.Id);
                    return;
                }
                fileProcessor.WriteFile(outputText, outputFolderPath,
                                        $"{customer.Id}{customer.FirstName}{customer.Surname}.txt");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error processing data." + ex.Message);
                return;
            }
        }