public ActionResult GuestRespond (string rsvpID)
        {
            List<Guests> guestList = DAL.GetRSVPByID(rsvpID);

            if (guestList.FirstOrDefault().hasRSVPed)
                return View("AlreadyRSVPed");

            RSVPs guestsOnThisRSVP = new RSVPs(guestList);
            guestsOnThisRSVP.SetUpForInitialRSVP();

            return View(guestsOnThisRSVP);
        }
        public ActionResult GuestRespond(RSVPs rsvps)
        {
            rsvps.hasRSVPed = true;

            if (DAL.UpdateRSVP(rsvps) == 1)
            {
                SendEmail(rsvps);
                return View("RSVPSuccess");
            }
            else
                throw new Exception();
        }
        private void SendEmail(RSVPs rsvps)
        {
            SmtpClient smtpClient = new SmtpClient();
            try
            {
                smtpClient.Host = System.Configuration.ConfigurationManager.AppSettings["SMTPserver"];
                smtpClient.Port = 25;
                //smtpClient.Timeout = 10000;
                smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
                smtpClient.UseDefaultCredentials = false;
                smtpClient.Credentials = new NetworkCredential("*****@*****.**", "plastik5");

                //String bodyText = fvm.ContactNumber + "\n" + fvm.EmailAddress + "\n" + fvm.FirstName + " " + fvm.LastName + "\n" + fvm.Comments;

                List<Guests> guestList = DAL.GetGuestsByID(rsvps.RsvpID.ToString());

                string fullGuestNames = "";
                foreach(var g in guestList)
                {
                    fullGuestNames += g.firstName + " " + g.lastName + " ";
                }

                string guestRSVPing = guestList.FirstOrDefault().firstName + " " + guestList.FirstOrDefault().lastName;
                
                string subject = guestRSVPing + " RSVP!";
                string body = "Names: " + fullGuestNames + "\n" +
                              "rsvpID: " + rsvps.RsvpID + "\n" +
                              "isAttending: " + (rsvps.isAttending ? "Yes" : "No") + "\n" +
                              "numPeopleAttending: " + rsvps.NumPeopleAttending + "\n" +
                              "namesOfPeopleAttending: " + rsvps.NamesOfPeopleAttending + "\n" +
                              "rsvpComment: " + rsvps.rsvpComment;

                MailMessage mailMessage = new MailMessage("*****@*****.**", "*****@*****.**", subject, body);
                //mailMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;

                smtpClient.Send(mailMessage);
            }
            catch (Exception ex)
            {
            }
        }
Example #4
0
 public static int UpdateRSVP(RSVPs rsvp)
 {
     using (SqlConnection mycon = new SqlConnection(ConfigurationManager.ConnectionStrings["SqlServerConnection"].ConnectionString))
     {
         return mycon.Execute
         (@"update tblrsvp set hasRSVPed = @hasRSVPed, 
             isAttending = @isAttending, 
             numPeopleAttending = @numPeopleAttending, 
             namesOfPeopleAttending = @namesOfPeopleAttending,
              rsvpComment = @rsvpComment
             where rsvpID = @rsvpID",
             new { rsvpID = rsvp.RsvpID, hasRSVPed = rsvp.hasRSVPed, isAttending = rsvp.isAttending, numPeopleAttending = rsvp.NumPeopleAttending,
             namesOfPeopleAttending = rsvp.NamesOfPeopleAttending, rsvpComment = rsvp.rsvpComment});
     }
 }