public Config GetConfig(LocaleService localeService)
        {
            _localeService = localeService;

            var config = new Config();

            config.Locale = Locale;

            config.MailBodyTitle = _localeService.Get(LocaleService.AUTO_BODY_TITLE);
            config.MailBody      = _localeService.Get(LocaleService.AUTO_BODY);

            DisplaySeparator(_step++);
            config.MailSubject = GetMailSubject();

            DisplaySeparator(_step++);
            config.Participants.AddRange(GetParticipants());

            DisplaySeparator(_step++);
            var mailProviderSettings = GetMailProviderSettings();

            config.SmtpHost = mailProviderSettings.SMTP_HOST;
            config.SmtpPort = mailProviderSettings.SMTP_PORT;

            DisplaySeparator(_step++);
            var credentials = GetUserCredentials();

            config.SmtpEmail    = credentials.email;
            config.SmtpPassword = credentials.password;

            return(config);
        }
Beispiel #2
0
        public string GetHtmlBody(Participant santa)
        {
            string bodyMessage;

            if (santa.ReceiversList.Any())
            {
                var body      = _localeService.Get(LocaleService.AUTO_BODY_WITH_GIFTS);
                var giftsHtml = GetGiftIdeasFormatted(santa.ReceiversList);
                bodyMessage = string.Format(body, santa.Name, santa.ReceiversName, giftsHtml);
            }
            else
            {
                var body = _localeService.Get(LocaleService.AUTO_BODY);
                bodyMessage = string.Format(body, santa.Name, santa.ReceiversName);
            }

            return("<!DOCTYPE html>"
                   + "<html lang=\"en\" xmlns=\"http://www.w3.org/1999/xhtml\">"
                   + "<head>"
                   + "<meta charset=\"utf-8\" />"
                   + "<title></title>"
                   + "</head>"
                   + "<body>"
                   + "<div style=\"height:100%; width:100%; background-color: #5a992f; position: absolute; top: 0; left: 0;\">"
                   + "<div style=\"padding: 30px; font-family: Arial; color: white;\">"
                   + "<div style=\"text-align: center;\">"
                   + $"<h1>{_localeService.Get(LocaleService.AUTO_BODY_TITLE)}</h1>"
                   + "<div style=\"display: inline-flex; margin-bottom: 15px;\">"
                   + "<span style=\"opacity: 60%; background-color: red; height: 30px; width: 30px; border-radius: 50%; margin: 0 20px; border: 0px black solid;\"></span>"
                   + "<span style=\"opacity: 60%; background-color: green; height: 30px; width: 30px; border-radius: 50%; margin: 0 20px; border: 0px black solid;\"></span>"
                   + "<span style=\"opacity: 60%; background-color: blue; height: 30px; width: 30px; border-radius: 50%; margin: 0 20px; border: 0px black solid;\"></span>"
                   + "<span style=\"opacity: 60%; background-color: yellow; height: 30px; width: 30px; border-radius: 50%; margin: 0 20px; border: 0px black solid;\"></span>"
                   + "<span style=\"opacity: 60%; background-color: blue; height: 30px; width: 30px; border-radius: 50%; margin: 0 20px; border: 0px black solid;\"></span>"
                   + "<span style=\"opacity: 60%; background-color: green; height: 30px; width: 30px; border-radius: 50%; margin: 0 20px; border: 0px black solid;\"></span>"
                   + "<span style=\"opacity: 60%; background-color: red; height: 30px; width: 30px; border-radius: 50%; margin: 0 20px; border: 0px black solid;\"></span>"
                   + "</div>"
                   + "</div>"
                   + $"<p>{bodyMessage}</p>"
                   + "</div>"
                   + "</div>"
                   + "</body>"
                   + "</html>");
        }
        private List <Participant> GetParticipants()
        {
            Console.WriteLine();
            WriteSlow(_localeService.Get(LocaleService.QUESTION_PARTICIPANTS));
            Console.WriteLine();
            int participantsCount = GetInteger(GetAnswerFrom(_localeService.Get(LocaleService.QUESTION_PARTICIPANTS_COUNT)));

            var list = new List <Participant>();

            for (int i = 1; i <= participantsCount; i++)
            {
                var participant = new Participant();

                participant.Name = CheckDistinctString(
                    GetAnswerFrom(string.Format(_localeService.Get(LocaleService.QUESTION_PARTICPANT_NAME), i)),
                    list.Select(o => o.Name),
                    _localeService.Get(LocaleService.WARNING_NAME_EXISTS));

                participant.Email = CheckDistinctString(
                    GetAnswerFrom(string.Format(_localeService.Get(LocaleService.QUESTION_PARTICPANT_EMAIL), i)),
                    list.Select(o => o.Email),
                    _localeService.Get(LocaleService.WARNING_EMAIL_EXISTS));

                list.Add(participant);
            }
            return(list);
        }