Ejemplo n.º 1
0
        public Task Send(FeedbackModel model)
        {
            var smtp = new SmtpClient();

            if (!string.IsNullOrEmpty(config.userName))
            {
                smtp.Credentials = new NetworkCredential(config.userName, config.password);
            }

            var builder = new StringBuilder();

            builder.AppendLine($"name: {model.name}");
            builder.AppendLine($"email: {model.email}");
            builder.AppendLine(string.Empty);
            builder.AppendLine($"{model.comments}");

            var mail = new MailMessage(config.from, config.to, config.subject, builder.ToString());

            smtp.Send(mail);
            return(Task.FromResult(true));
        }
Ejemplo n.º 2
0
 bool ValidateModel(FeedbackModel model)
 {
     if (!config.captcha.Equals(model.captcha))
     {
         Console.WriteLine($"{nameof(FeedbackLoader)} ERROR - captcha");
         return(false);
     }
     if (string.IsNullOrEmpty(model.name))
     {
         Console.WriteLine($"{nameof(FeedbackLoader)} ERROR - name");
         return(false);
     }
     if (string.IsNullOrEmpty(model.email))
     {
         Console.WriteLine($"{nameof(FeedbackLoader)} ERROR - email");
         return(false);
     }
     if (string.IsNullOrEmpty(model.comments))
     {
         Console.WriteLine($"{nameof(FeedbackLoader)} ERROR - comments");
         return(false);
     }
     return(true);
 }