public int SendEmailToCustomer(Customer customer, int EmailTemplateID, Booking booking = null, BookingExtraSelection bes = null)
        {
            try
            {
                StandardEmailTemplate template = new StandardEmailTemplate(customer.EmailAddress, EmailTemplateID, customer, booking, bes);
                template.SendEmail();

                return(0);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
 /// <summary>
 /// There is only one template pattern at the moment - Standard template
 /// </summary>
 /// <param name="anEvent"></param>
 /// <param name="customer"></param>
 /// <param name="documentType"></param>
 /// <param name="booking"></param>
 /// <param name="bes"></param>
 public EventCommandSendEmail(Event anEvent, int EmailTemplateId, Customer customer, Booking booking = null, BookingExtraSelection bes = null)
 {
     this.Event           = anEvent;
     this.customer        = customer;
     this.booking         = booking;
     this.bes             = bes;
     this.EmailTemplateId = EmailTemplateId;
 }
Пример #3
0
 public EventCommandCreateDocument(Event anEvent, Customer customer, PRCDocument.PRCDocumentType documentType, Booking booking = null, BookingExtraSelection bes = null)
 {
     //inject properties
     this.Event        = anEvent;
     this.customer     = customer;
     this.documentType = documentType;
     this.booking      = booking;
     this.bes          = bes;
 }
Пример #4
0
        public PRCDocument(Customer customer, PRCDocumentType type, Booking booking = null, BookingExtraSelection bookingExtraSelection = null)
        {
            this.Type = type;

            this.MainDataTable      = new DataTable();
            this.SecondaryDataTable = new DataTable();

            this.CustomerID = customer.CustomerID;
            if (booking != null)
            {
                BookingID = booking.BookingID;
            }
            if (bookingExtraSelection != null)
            {
                this.BookingExtraSelectionID = bookingExtraSelection.BookingExtraSelectionID;
            }
        }
Пример #5
0
        /// <summary>
        /// Sends an email for 1*1 bookings or extrabookings
        /// </summary>
        /// <param name="customer"></param>
        /// <param name="booking"></param>
        /// <param name="bookingExtraSelection"></param>
        public StandardEmailTemplate(string toEmailAddress, int EmailTemplateID, Customer customer, Booking booking = null, BookingExtraSelection bookingExtraSelection = null)
        {
            EmailTemplate theTemplate;
            EmailTemplate Header;
            EmailTemplate Footer;

            using (PortugalVillasContext db = new PortugalVillasContext())
            {
                theTemplate = db.EmailTemplates.Find(EmailTemplateID);
                Header      = db.EmailTemplates.Find(1);
                Footer      = db.EmailTemplates.Find(2);
            }
            theAsposeMessage = new MailMessage();
            Property     property     = null;
            BookingExtra bookingExtra = null;

            EmailOutType theMainBody = new EmailOutType();

            //map all passed in object fields
            bool bookingToggle          = false;
            bool bookingExtraToggle     = false;
            bool combinedServicesToggle = false;


            //gets necessary

            //assign body
            if (booking == null)
            {
                bookingExtraToggle = true;
                bookingExtra       = BookingExtra.GetBookingExtraByID(bookingExtraSelection.BookingExtraID);
                //theMainBody = new EmailOutType(EmailOutType.EmailOutEmailType.BookingExtraSelectionConfirm);
            }
            else if (booking != null && bookingExtraSelection == null)
            {
                bookingToggle = true;
                long propertyID = (long)booking.PropertyID;
                property = Property.GetPropertyByID(propertyID);
                //theMainBody = new EmailOutType(EmailOutType.EmailOutEmailType.BookingConfirm);//
            }
            else if (booking != null && bookingExtraSelection != null)
            {
                long propertyID = (long)booking.PropertyID;
                property               = Property.GetPropertyByID(propertyID);
                bookingExtra           = BookingExtra.GetBookingExtraByID(bookingExtraSelection.BookingExtraID);
                combinedServicesToggle = true;
                //theMainBody = new EmailOutType(EmailOutType.EmailOutEmailType.BookingAndBookingExtraSelectionConfirm);
            }



            //customer
            var customerFullName = customer.FirstName + " " + customer.LastName;

            //bookings and extras

            var prcRef = booking != null ? property.LegacyReference : bookingExtra.LegacyReference;

            string bookingPropertyOrSelectionName = booking != null ? property.PropertyName : bookingExtra.BookingExtraName;
            string bookingStartDate = booking != null?Convert.ToDateTime(booking.StartDate.ToString()).ToString("dd/MM/yyyy") : Convert.ToDateTime(bookingExtraSelection.ExtraRentalDate.ToString()).ToString("dd/MM/yyyy");

            string bookingEndDate = booking != null?Convert.ToDateTime(booking.EndDate.ToString()).ToString("dd/MM/yyyy") : new DateTime(1901, 01, 01).ToString("dd/MM/yyyy");

            string numberOfNights = booking != null?booking.NumberOfNights.ToString() : "0";


            theAsposeMessage.To   = customer.EmailAddress;
            theAsposeMessage.From = "*****@*****.**";

            theSMTPClient.Host         = "smtp.gmail.com";
            theSMTPClient.Username     = LoginEmailAddress;
            theSMTPClient.Password     = EmailPassword;
            theSMTPClient.Port         = 587;
            theSMTPClient.EnableSsl    = true;
            theSMTPClient.SecurityMode = SmtpSslSecurityMode.Explicit;


            //set some email body
            //set the body
            //subject
            //
            theAsposeMessage.Subject  = theTemplate.EmailSubject;
            theAsposeMessage.HtmlBody = "";

            //get correct email according to emailEnumID


            var temp = "";
            //string merges
            var fullName  = customer != null ? customerFullName : "";
            var legacyRef = property != null ? property.LegacyReference : bookingExtra.LegacyReference;
            var bookStart = bookingStartDate != null ? bookingStartDate : "";
            var bookEnd   = bookingEndDate != null ? bookingEndDate : "";
            var NoNights  = numberOfNights != null ? numberOfNights : "";
            var reference = booking != null ? booking.BookingPRCReference : bookingExtraSelection.BookingExtraPRCReference;
            var bID       = booking != null?booking.BookingID.ToString() : "";

            var besID = bookingExtraSelection != null?bookingExtraSelection.BookingExtraSelectionID.ToString() : "";

            var finalRentalPayment = booking != null?booking.BookingPrice.ToString() : "";

            var finalRentalPaymentDate = "";

            if (booking != null)
            {
                finalRentalPaymentDate = booking.FinalRentalPaymentDueDate != null ? ((DateTime)booking.FinalRentalPaymentDueDate).ToString("dd/MM/yyyy") : "";
            }

            var rentalDeposit = booking != null?booking.BreakageDeposit.ToString() : "";

            temp = String.Format(theTemplate.EmailTemplateBodyHTML, fullName, legacyRef, bookStart, bookEnd, NoNights, reference, finalRentalPaymentDate, bID, besID, finalRentalPayment, rentalDeposit);

            //booking request optional
            //if (bookingToggle == true && EmailTemplateID == 17)
            //{
            //    temp = String.Format(theTemplate.EmailTemplateBodyHTML, customerFullName, property.LegacyReference, bookingStartDate, bookingEndDate, numberOfNights, bookingExtraSelection.BookingExtraSelectionID);
            //}

            ////booking request forms standard
            //else if (bookingToggle == true // && EmailTemplateID == 3 || EmailTemplateID == 4 || EmailTemplateID == 5 || EmailTemplateID == 6
            //    )
            //{


            //    temp = String.Format(theTemplate.EmailTemplateBodyHTML, customerFullName, property.LegacyReference, booking.BookingPRCReference, ((DateTime)booking.FinalRentalPaymentDueDate).ToString("dd/MM/yyyy"));


            //}


            //else if (bookingExtraToggle == true)
            //{
            //    temp = String.Format(theTemplate.EmailTemplateBodyHTML, customerFullName, prcRef, bookingExtraSelection.BookingExtraSelectionID);

            //}
            //else if (combinedServicesToggle == true)
            //{
            //    temp = String.Format(theTemplate.EmailTemplateBodyHTML, customerFullName, booking.BookingID);

            //}



            //set the body
            var completeEmail = Header.EmailTemplateBodyHTML + temp + Footer.EmailTemplateBodyHTML;

            theAsposeMessage.HtmlBody = completeEmail;
        }
        public ActionResult QuickCreate(BookingExtraSelection bes)
        {
            using (var db = new PortugalVillasContext())
            {
                var cus = db.Customers.Find(bes.CustomerID);


                var account      = new AccountController();
                var eventService = new EventController();
                var bookingRepo  = new FinalBookingDetailGatheringController();

                //parent
                BookingParentContainer parentContainer = new BookingParentContainer();
                parentContainer.CustomerID = cus.CustomerID;


                parentContainer = bookingRepo.CreateBookingParentContainer(parentContainer, db);


                var extraType = db.BookingExtras.Find((long)bes.BookingExtraID);
                bes.BookingExtraID = extraType.BookingExtraID;
                //link to parent booking
                bes.BookingParentContainerID = parentContainer.BookingParentContainerID;


                //need
                //reference
                //price fully done
                //all extras on form fully taken care of for each one
                var createdBes = bookingRepo.CreateBookingExtraSelection(bes, extraType, cus, db);

                string EventTypeID = "";
                //car
                if (extraType.BookingExtraTypeID == 1)
                {
                    if (cus.Country.ToLower() == "united kingdom")
                    {
                        EventTypeID = "43";
                    }
                    else
                    {
                        EventTypeID = "62";
                    }
                }
                //wine
                else if (extraType.BookingExtraTypeID == 2)
                {
                    if (cus.Country.ToLower() == "united kingdom")
                    {
                        EventTypeID = "45";
                    }
                    else
                    {
                        EventTypeID = "60";
                    }
                }
                //airport
                else if (extraType.BookingExtraTypeID == 3)
                {
                    if (cus.Country.ToLower() == "united kingdom")
                    {
                        EventTypeID = "31";
                    }
                    else
                    {
                        EventTypeID = "61";
                    }
                }
                //tour
                else if (extraType.BookingExtraTypeID == 4)
                {
                    if (cus.Country.ToLower() == "united kingdom")
                    {
                        EventTypeID = "33";
                    }
                    else
                    {
                        EventTypeID = "63";
                    }
                }

                var form = new FormCollection();
                form.Add("BookingExtraSelectionID", bes.BookingExtraSelectionID.ToString());
                form.Add("EventTypeID", EventTypeID);
            }


            return(View());
        }