Ejemplo n.º 1
0
 public static void SendConfirmation(Attendee attendee)
 {
     string email = ConfigurationManager.AppSettings["email"];
         string password = ConfigurationManager.AppSettings["password"];
         MailMessage mail = new MailMessage();
         mail.From = new MailAddress(email);
         SmtpClient smtp = new SmtpClient();
         smtp.EnableSsl = true;
         smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
         smtp.UseDefaultCredentials = false;
         smtp.Credentials = new NetworkCredential(mail.From.ToString(), password);
         smtp.Host = "smtp.gmail.com";
         mail.To.Add(new MailAddress($"{attendee.Email}"));
         mail.Subject = "Thanks for registering for Techtober!";
         mail.IsBodyHtml = true;
         string st = $"<div align='center'><img style='max - width: 150px' src='http://i.imgur.com/DSS1t1X.jpg' /><br /><p>Thanks {attendee.FirstName}. Your registration is confirmed! Please have the below QR code ready when you arrive at each event. If no one is able to scan you in, <a href='techtober.azurewebsites.net/events/chooseevent/{attendee.Id}'>click here</a> to check yourself in.</p><h1>{attendee.FirstName} {attendee.LastName}</h1><br /><img src='https://chart.googleapis.com/chart?cht=qr&chl={attendee.QrCode}&chs=100x100' width='200' height='200' /><p><h2>Looking for an event to attend? Check out the Techtober <a href='http://startuparkansas.com/techtober'>events calendar</a> now!</h2></div><footer>Event check-in backend services created for Techtober by <a href='mailto:[email protected]?Subject=Event%20Check-in%20Service' target='_top'>Scott Ferguson</a> in Little Rock, AR.</footer>";
         mail.Body = st;
         //Attachment attach = new Attachment(memoryStream, new ContentType("application/pdf"));
         //attach.Name = "Check In Badge";
         //mail.Attachments.Add(attach);
         smtp.Port = 587;
         try
         {
             smtp.Send(mail);
         }
         catch (SmtpFailedRecipientException ex)
         {
             SmtpStatusCode statusCode = ex.StatusCode;
             if (statusCode == SmtpStatusCode.MailboxBusy ||
             statusCode == SmtpStatusCode.MailboxUnavailable ||
             statusCode == SmtpStatusCode.TransactionFailed)
             {
                 // wait 5 seconds, try a second time
                 Thread.Sleep(5000);
                 smtp.Send(mail);
             }
             else
             {
                 throw;
             }
         }
         finally
         {
             mail.Dispose();
         }
 }
Ejemplo n.º 2
0
 public static void SendConfirmation(Attendee attendee, Event myEvent)
 {
     string email = ConfigurationManager.AppSettings["email"];
     string password = ConfigurationManager.AppSettings["password"];
     MailMessage mail = new MailMessage();
     mail.From = new MailAddress(email);
     SmtpClient smtp = new SmtpClient();
     smtp.Port = 587;
     smtp.EnableSsl = true;
     smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
     smtp.UseDefaultCredentials = false;
     smtp.Credentials = new NetworkCredential(mail.From.ToString(), password);
     smtp.Host = "smtp.gmail.com";
     mail.To.Add(new MailAddress($"{attendee.Email}"));
     mail.Subject = "Thanks for checking in!";
     mail.IsBodyHtml = true;
     string st = $"<div align='center'><img src='http://i.imgur.com/DSS1t1X.jpg' /></div><br /><div align='justified'><p>Your check-in for {myEvent.Name} is confirmed. You have attended {attendee.Events.Count()} events so far. <strong>Thank you</strong> for supporting the Little Rock tech scene!</p></div><footer><sub>Event check-in backend services created for Techtober by <a href='mailto:[email protected]?Subject=Event%20Check-in%20Service' target='_top'>Scott Ferguson</a> in Little Rock, AR.</sub></footer>";
     mail.Body = st;
     smtp.Send(mail);
 }
Ejemplo n.º 3
0
 private static MemoryStream GenerateBadge(Attendee attendee)
 {
     Document doc = new Document(PageSize.POSTCARD, 10, 10, 42, 35);
     MemoryStream memoryStream = new MemoryStream();
     PdfWriter writer = PdfWriter.GetInstance(doc, memoryStream);
     doc.Open();
     Uri imageLocation = new Uri("http://i.imgur.com/Fqk6Eqk.jpg");
     Image logo = Image.GetInstance(imageLocation);
     logo.Alignment = Element.ALIGN_CENTER;
     logo.ScaleAbsolute(120f, 155.25f);
     doc.Add(logo);
     Paragraph name = new Paragraph($"{attendee.FirstName} {attendee.LastName}");
     name.Alignment = Element.ALIGN_CENTER;
     doc.Add(name);
     Paragraph email = new Paragraph($"{attendee.Email}");
     email.Alignment = Element.ALIGN_CENTER;
     doc.Add(email);
     Image qr = Image.GetInstance(attendee.QrCode);
     qr.Alignment = Element.ALIGN_CENTER;
     doc.Add(qr);
     writer.CloseStream = false;
     doc.Close();
     memoryStream.Position = 0;
     return memoryStream;
 }
Ejemplo n.º 4
0
        public IHttpActionResult PutAttendee(int id, Attendee attendee)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != attendee.Id)
            {
                return BadRequest();
            }

            db.Entry(attendee).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AttendeeExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
Ejemplo n.º 5
0
        public dynamic PostAttendee(Attendee attendee)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Attendees.Add(attendee);
            db.SaveChanges();
            var qrCode = AttendeesController.GenerateCode(attendee.Id);
            attendee.QrCode = qrCode;
            db.SaveChanges();
            //var memoryStream = GenerateBadge(attendee);
            try
            {
                SendConfirmation(attendee);
                var response = new HttpResponseMessage();
                response.Content = new StringContent($"<html><body><div align='center'><img style='max - width: 150px' src='http://i.imgur.com/DSS1t1X.jpg' /><br /><h1>Thanks {attendee.FirstName}!</h1><h2>You should receive a confirmation email shortly.</h2><p><a href='http://techtober.org/#passport'>Go back</a></div></body></html>");
                response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html");
                return response;
                //return Ok();
            }
            catch
            {
                return BadRequest();
            }
        }