/// <summary>
        /// Gets 
        /// </summary>
        public static CustomerBankDetail GetCustomerBankDetailFromCustomer(Customer aCustomer)
        {
            PortugalVillasContext db = new PortugalVillasContext();
            CustomerBankDetail theBankDetailsToReturn = db.CustomerBankDetails.Where(x => x.CustomerID == aCustomer.CustomerID).FirstOrDefault();
            return theBankDetailsToReturn;

        }
 public bool SetCustomer(Customer aCustomer)
 {
  
         this.Id = aCustomer.CustomerID;
         this.aCustomer = aCustomer;
         return true;                                 
 }
        public CustomerSet(Customer aCustomer)
        {
            this.Id = aCustomer.CustomerID;
            this.aCustomer = aCustomer;
            this.aCustomersBankDetails = CustomerBankDetail.GetCustomerBankDetailFromCustomer(aCustomer);
            this.theEventsChainToComplete = new EventProvider(this);

        }
        /// <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;

        }
 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;
 }
        public ActionResult QuickCreateCustomer(Customer customer)
        {

          
            var redirect = Create(customer);

            return this.RedirectToAction("Edit", customer);

        }
        public ActionResult Create(Customer customer)
        {
            if (ModelState.IsValid)
            {
                db.Customers.Add(customer);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(customer);
        }
        public ActionResult Edit(Customer customer)
        {

            if (ModelState.IsValid)
            {
                using (var db = new PortVillasContext())
                {
                    db.Entry(customer).State = EntityState.Modified;
                    db.SaveChanges();
                    return RedirectToAction("Index");
                }
            }
            return RedirectToAction("Index");
        }
        public ActionResult TestAjaxView()
        {

            var cus = new Customer
            {
                FirstName = "Test",
                LastName = "test"

            };
            ViewBag.Message = "This is a AJAX form";

             
            return View();
        }
        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;
            }

        }
        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;
            }

        }
        //IContactable Wrappers
    /*    public string ContactFirstName { get; set; }
        public string ContactLastName { get; set; }
        public string ContactEmailAddress { get; set; }*/


        /////////////////////
        //static methods
        /////////////////////
        /// 

        public static Customer MapCustomerRegistrationToNewCustomer(CustomerRegistration theCustomerRegistration)
        {
            try
            {
                Customer theCustomer = new Customer
                {
                    Title = theCustomerRegistration.Title,
                    Address1 = theCustomerRegistration.Address1,
                    Address2 = theCustomerRegistration.Address2,
                    AltEmailAddress = theCustomerRegistration.AltEmailAddress,
                    AltTelephone = theCustomerRegistration.AltTelephone,
                    CompanyTelephone = theCustomerRegistration.CompanyTelephone,
                    County = theCustomerRegistration.County,
                    Country = theCustomerRegistration.Country,
                    CreationDate = theCustomerRegistration.CreationDate,
                    DOB = theCustomerRegistration.DOB,
                    DayTimeTelephone = theCustomerRegistration.DayTimeTelephone,
                    HomeTelephone = theCustomerRegistration.HomeTelephone,
                    EmailAddress = theCustomerRegistration.EmailAddress,
                    FirstName = theCustomerRegistration.FirstName,
                    LastName = theCustomerRegistration.LastName,
                    MiddleName = theCustomerRegistration.MiddleName,
                    Town = theCustomerRegistration.Town,
                    Postcode = theCustomerRegistration.Postcode,
                    MobileTelephone = theCustomerRegistration.MobileTelephone,
                    PreferredCurrency = theCustomerRegistration.PreferredCurrency,
                    PreferredCurrencySymbol = theCustomerRegistration.PreferredCurrencySymbol,
                    Test = theCustomerRegistration.Test

                };


                return theCustomer;
            }
            catch (Exception ex)
            {
                
                throw ex;
            }
        }
        public ActionResult Edit(Customer customer)
        {


            var oldCust = db.Customers.Where(x => x.CustomerID == customer.CustomerID).First();
            customer.CreationDate = customer.CreationDate;


            if (ModelState.IsValid)
            {
                using (var _db = new PortugalVillasContext())
                {
                    _db.Customers.Attach(customer);
                    _db.Entry(customer).State = EntityState.Modified;
                    _db.SaveChanges();
                    Session["currentCustomer"] = customer;
                    return RedirectToAction("Edit", customer);
                }

            }
            return View(customer);
        }
        /// <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 ProcessLink()
        {
            var cus = new Customer
            {
                CustomerID = 10000,
                FirstName = "Zog"
            };

            return View("Index", cus);
        }
        public ActionResult GetBookingDetails()
        {
            Customer customer = new Customer();

            var testCus = Session["prc_customer"];

            if (testCus != null)
            {
                customer = (Customer)Session["prc_customer"];
            }

            CustomerBankDetail customerBankDetail = new CustomerBankDetail();
            var testBank = Session["prc_customerBankingDetail"];
            if (testBank != null)
            {
                customerBankDetail = (CustomerBankDetail)Session["prc_customerBankingDetail"];
            }


            var model = new FinalBookingDetailViewModel();
            model.Customer = customer;
            model.CustomerBankDetail = customerBankDetail;


            //test if any booking in the cart, if so pass them into the model
            List<Booking> bookings = new List<Booking>();


            if (Session["Cart_PropertyBookings"] != null)
            {
                bookings = (List<Booking>)Session["Cart_PropertyBookings"];
                model.Bookings = bookings;
                foreach (var booking in bookings)
                {
                    booking.Property = db.Properties.Find(booking.PropertyID);
                }
            }


            List<BookingExtraSelection> bes = new List<BookingExtraSelection>();

            if (Session["Cart_ExtraBookings"] != null)
            {
                bes = (List<BookingExtraSelection>)Session["Cart_ExtraBookings"];
                model.BookingExtraSelections = bes;
                foreach (var b in bes)
                {
                    b.BookingExtra = db.BookingExtras.Find(b.BookingExtraID);
                }
            }




            //test if any bes in the cart, if so pass them into the model

            List<AirportDestination>
                apd = AirportDestination.GetAllAirportDestinations().ToList();
            List<SelectListItem>
                airportDestinations = new List<SelectListItem>
                    ();

            /*   
               foreach (var airportDestination in apd)
               {
                   airportDestinations.Add(new SelectListItem { Text = @airportDestination.AirportPickupLocationName, Value = @airportDestination.AirportPickupLocationID.ToString() })
                       ;
               }*/


            airportDestinations.Add(new SelectListItem { Selected = true, Value = "1", Text="BoggleWoggle"});

            ViewBag.AirportDest = airportDestinations;
            ViewBag.Keywords = "cheap all inclusive holidays to portugal,holiday villa portugal,holiday apartments in portugal,portugal rental cottages,cheap package holidays to portugal, cheap holidays to portugal all inclusive";
            ViewBag.Title = "Search for villas townhouses, apartments in rural, seaside or city break settings. Book holidays in portugal's silver coast, in Foz do Arelho, Salir do Porto, Olho Marinho or Formigal. Book car rental, wine tours, site seeing tours with Portugal Rental Cottages. Rent Hyundai I20, Mitsubishi Lancer, Mitsubishi Grandis, go siteseeing with Lisbon City Tours or Sintra Palace Tours, get 9 Seater Van transport from the airport and have full Cleaning Service, Breakfast and Swimming Towels provided! Visit EXPO 98 & Ocenarium on your Portugal Holiday Rental!";
            return View(model);
        }
        public ActionResult ProcessForm(Customer obj)
        {


            using (var _db = new PortVillasContext())
            {
                var data = _db.Customers.Where(x => x.CustomerID == obj.CustomerID).SingleOrDefault();

                ViewData["currentCustomer"] = data;

                return PartialView("CustomerEdit", data);
            }



        }
        public ActionResult Create(Customer customer)
        {
            customer.CreationDate = DateTime.Now;
            if (customer.Country.ToLower() == "united kingdom")
            {
                customer.PreferredCurrency = "GBP";
                customer.PreferredCurrencySymbol = "£";
            }
            else
            {
                customer.PreferredCurrency = "EUR";
                customer.PreferredCurrencySymbol = "€";
            }

            db.Customers.Add(customer);
            db.SaveChanges();

            return this.RedirectToAction("Edit", customer);
            
        }
        public Customer CreateCustomer(Customer customer, PortugalVillasContext db)
        {




            //CHECK IF THERE'S ALREADY A CUSTOMER WITH THIS EMAIL ADDRESS FIRST!!!

            //end check

            //CHECK we ain't got anything for this customer in the Sessions already

            //end check


            //if not, add customer            

            //set up fields
            customer.CreationDate = DateTime.Now;
            customer.Test = false;



            //end

            db.Customers.Add(customer);

            if (db.SaveChanges() > 0)
            {
                //customer now has an ID if the save has worked
                return customer;

            }

            throw new Exception("Cannot create customer");

        }
        //
        // POST: /FinalBookingDetailGathering/Create


        public bool CreateCustomerAsPartOfSignUp(Customer customer)
        {

            PortugalVillasContext db = new PortugalVillasContext();

            if (ModelState.IsValid)
            {

                //CHECK IF THERE'S ALREADY A CUSTOMER WITH THIS EMAIL ADDRESS FIRST!!!

                //end check

                //CHECK we ain't got anything for this customer in the Sessions already

                //end check


                //if not, add customer            

                //set up fields

                customer.CreationDate = DateTime.Now;
                if (customer.Country.ToLower() == "united kingdom")
                {
                    customer.PreferredCurrency = "GBP";
                    customer.PreferredCurrencySymbol = "£";
                }
                else
                {
                    customer.PreferredCurrency = "EUR";
                    customer.PreferredCurrencySymbol = "€";
                }
                //end

                db.Customers.Add(customer);

                if (db.SaveChanges() > 0)
                {
                    //customer now has an ID if the save has worked
                    System.Web.HttpContext.Current.Session["prc_customer"] = customer;

                    return true;

                }



            }
            return false;
        }
        //  [Authorize(Roles = "Administrator, User")]
        public ActionResult ManageCustomer(Customer customer)
        {


            Customer previousCustomer = (Customer)Session["prc_previouscustomer"];
            customer.CustomerID = previousCustomer.CustomerID;


            if ((!CheckIfCustomerEmailAlreadyExists(customer.EmailAddress) &&
                !CheckIfUserExistsInSimpleMemberProvider(customer.EmailAddress)) || (previousCustomer.EmailAddress.ToLower().Trim() == customer.EmailAddress.ToLower().Trim()))
            {

                PortugalVillasContext _dbContext = new PortugalVillasContext();
                UsersContext _usersContext = new UsersContext();

                //get the old customer detailf from the session



                //update simplemembership provider too
                var user =
                    _usersContext.UserProfiles.Where(
                        x => x.UserName.ToLower().Trim() == previousCustomer.EmailAddress.ToLower().Trim())
                        .FirstOrDefault();

                user.UserName = customer.EmailAddress;

                //update customer and user
                try
                {
                    if (ModelState.IsValid)
                    {
                        _dbContext.Entry(customer).State = EntityState.Modified;
                        var objContext = ((IObjectContextAdapter)_dbContext).ObjectContext;

                        var refreshableObjects = (from entry in objContext.ObjectStateManager.GetObjectStateEntries(
                            EntityState.Added
                            | EntityState.Deleted
                            | EntityState.Modified
                            | EntityState.Unchanged)
                                                  where entry.EntityKey != null
                                                  select entry.Entity);

                        objContext.Refresh(RefreshMode.ClientWins, refreshableObjects);

                        //if it works, do the update for the userContext, else, don't as it failed
                        if (objContext.SaveChanges() > 0)
                        {
                            _usersContext.Entry(user).State = EntityState.Modified;
                            _usersContext.SaveChanges();

                            WebSecurity.Logout();

                            Session["prc_customer"] = customer;
                            //update the customer
                            return View("CustomerUpdateSuccess");
                        }

                    }
                }

                catch
            (DbUpdateConcurrencyException ex)
                {
                    var objContext = ((IObjectContextAdapter)_dbContext).ObjectContext;
                    var entry = ex.Entries.Single();

                    objContext.Refresh(RefreshMode.ClientWins, entry.Entity);
                    _dbContext.SaveChanges();


                }

            }


            //update the customer on result
            ViewBag.Title = "Manage Portugal Holiday Rentals Customer";
            return View("CustomerUpdateFailed");


        }
Exemplo n.º 22
0
 public ActionResult Edit(Customer customer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(customer).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(customer);
 }
 public ActionResult EditCustomer(Customer customer)
 {
     PortugalVillasContext db = new PortugalVillasContext();
     if (ModelState.IsValid)
     {
         db.Entry(customer).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(customer);
 }
        public void TestNewClassesAndInterfaces()
        {
            ///create a new concrete implementation of the 
            ///
            Customer testCusti = Customer.GetSingleCustomer(1);

            Customer blankCust = new Customer();
            CustomerBankDetail aBankDetail = CustomerBankDetail.GetCustomerBankDetailFromCustomer(testCusti);

            testCusti.EmailAddress = "*****@*****.**";
            testCusti.Town = "london";


            ICustomerSet testMeCustomer = new CustomerSet(testCusti);

            //right, so do we have the right events dere eh?

            var theEvents = testMeCustomer.theEventsChainToComplete.CheckRemainingEvents();
            var isItFalse = testMeCustomer.theEventsChainToComplete.CheckIfBookingComplete();
            var nextEvent = testMeCustomer.theEventsChainToComplete.CheckNextEvent();

            testMeCustomer.theEventsChainToComplete.EventComplete_RemoveFromRemainingEvents(nextEvent);


            var howManyEventsWeGot = testMeCustomer.theEventsChainToComplete.CheckRemainingEvents().Count();


        }
        public Booking CreateBooking(Booking booking, Property property, Customer theCustomer, PortugalVillasContext db)
        {

            //set default currency

            booking.BookingCurrencyConversionSymbol = theCustomer.PreferredCurrencySymbol;
            booking.BookingPreferredCurrency = theCustomer.PreferredCurrency;

            var cc = new CurrencyConverterController();



            //if the booking is not in GBP convert to EUROS



            //NEED TO CONVERT THE CURRENCY BASED ON WHETHER IT NEEDS TO BE EU OR UK





            int adults, kids, infants;

            adults = booking.NumberOfAdults ?? 0;
            kids = booking.NumberOfChildren ?? 0;
            infants = booking.NumberOfInfants ?? 0;


            booking.NumberOfAdults = adults;
            booking.NumberOfChildren = kids;
            booking.NumberOfInfants = infants;



            booking.CustomerID = theCustomer.CustomerID;
            booking.BookingTypeID = 1; //always a property booking

            booking.NumberOfGuests = adults + kids + infants;
            booking.TotalNumberOfMinors = kids + infants;
            booking.NumberOfNights = GeneralStaticHelperMethods.CalculateNoofNights(booking.StartDate, booking.EndDate);


            try
            {
                var exchangeRateFromDB = new CurrencyExchange();
                var baseCurrency = "";
                var newCurrency = "";

                booking.NumberOfNights = GeneralStaticHelperMethods.CalculateNoofNights(booking.StartDate,
                    booking.EndDate);
                booking.CalculateBookingPricingForAPropertyBooking(db);
                booking.CalculateExtrasPriceForAPropertyBooking(property, booking, db);
                //set this now because need to convert it
                booking.SetBreakageDepositDueDate(); //1 month before
                booking.SetBreakageDepositAmount(); //depends on property

                booking.BookingCurrencyLongName = "G.B. Pounds Sterling";
                //NOW CONVERT CURRENCY IF NECESSARY SO OTHER CALCS ARE CORRECT
                //CHANGE THIS!!! IT'S USING HIDDEN EXTERNAL DEPENDENY
                booking.BookingCurrencyConversionSymbol = "£";
                booking.BookingCurrencyExchangeRate = 1.00M;
                booking.BookingPreferredCurrency = "GBP";


                if (theCustomer.Country.ToLower() != "united kingdom" && ConfigurationManager.AppSettings["defaultCurrency"] == "GBP")
                {

                    //euro strategy
                    baseCurrency = "GBP";
                    newCurrency = "EUR";


                    //set exchange rate
                    booking.BookingCurrencyExchangeRate = exchangeRateFromDB.CurrencyExchangeRate;
                    booking.BookingCurrencyLongName = "Euros";
                    booking.BookingCurrencyConversionSymbol = exchangeRateFromDB.CurrencyExchangeSymbol;
                    booking.BookingCurrencyExchangeRate = exchangeRateFromDB.CurrencyExchangeRate;
                    booking.BookingPreferredCurrency = "EUR";

                    try
                    {
                        booking.BookingPrice = cc.ConvertCurrency(baseCurrency, newCurrency, (decimal)booking.BookingPrice);
                        booking.BookingCurrencyConversionPrice = booking.BookingPrice;

                        booking.TowelsPrice = cc.ConvertCurrency(baseCurrency, newCurrency, (decimal)booking.TowelsPrice);
                        booking.MidVactionCleaningPrice = cc.ConvertCurrency(baseCurrency, newCurrency,
                            (decimal)booking.MidVactionCleaningPrice);
                        booking.SwimmingPoolHeatingPrice = cc.ConvertCurrency(baseCurrency, newCurrency,
                            (decimal)booking.SwimmingPoolHeatingPrice);
                        booking.ExtraLininSetPrice = cc.ConvertCurrency(baseCurrency, newCurrency,
                            (decimal)booking.ExtraLininSetPrice);
                        booking.BreakageDeposit = cc.ConvertCurrency(baseCurrency, newCurrency,
                            (decimal)booking.BreakageDeposit);
                        booking.CleaningPostVisitPrice = cc.ConvertCurrency(baseCurrency, newCurrency,
                            (decimal)booking.CleaningPostVisitPrice);
                        booking.HeatingPrice = cc.ConvertCurrency(baseCurrency, newCurrency,
                            (decimal)booking.HeatingPrice);





                    }
                    catch (Exception)
                    {

                        throw;
                    }

                }

                //ALL BOOKINGS FOR US SYSTEM IN USD
                else if (ConfigurationManager.AppSettings["defaultCurrency"] == "USD")
                {
                    baseCurrency = "GBP";
                    newCurrency = "USD";

                    exchangeRateFromDB =
                        db.CurrencyExchanges.First(x => x.CurrencyExchangeName == "GBP-USD");

                    //set exchange rate and currencies
                    booking.BookingCurrencyExchangeRate = exchangeRateFromDB.CurrencyExchangeRate;
                    booking.BookingCurrencyLongName = "U.S. Dollars";
                    booking.BookingCurrencyConversionSymbol = exchangeRateFromDB.CurrencyExchangeSymbol;
                    booking.BookingCurrencyExchangeRate = exchangeRateFromDB.CurrencyExchangeRate;
                    booking.BookingPreferredCurrency = "USD";




                }

                //do all cuurency conversions if not a UK booking
                if (theCustomer.Country.ToLower() != "united kingdom" || !ConfigurationManager.AppSettings["defaultCurrency"].Equals("GBP"))
                {
                    try
                    {
                        booking.BookingPrice = cc.ConvertCurrency(baseCurrency, newCurrency,
                            (decimal)booking.BookingPrice);
                        booking.BookingCurrencyConversionPrice = booking.BookingPrice;

                        booking.TowelsPrice = cc.ConvertCurrency(baseCurrency, newCurrency,
                            (decimal)booking.TowelsPrice);
                        booking.MidVactionCleaningPrice = cc.ConvertCurrency(baseCurrency, newCurrency,
                            (decimal)booking.MidVactionCleaningPrice);
                        booking.SwimmingPoolHeatingPrice = cc.ConvertCurrency(baseCurrency, newCurrency,
                            (decimal)booking.SwimmingPoolHeatingPrice);
                        booking.ExtraLininSetPrice = cc.ConvertCurrency(baseCurrency, newCurrency,
                            (decimal)booking.ExtraLininSetPrice);
                        booking.BreakageDeposit = cc.ConvertCurrency(baseCurrency, newCurrency,
                            (decimal)booking.BreakageDeposit);
                        booking.CleaningPostVisitPrice = cc.ConvertCurrency(baseCurrency, newCurrency,
                            (decimal)booking.CleaningPostVisitPrice);
                        booking.HeatingPrice = cc.ConvertCurrency(baseCurrency, newCurrency,
                            (decimal)booking.HeatingPrice);


                        booking.HeatingUnitPrice = cc.ConvertCurrency(baseCurrency, newCurrency,
                            (decimal)booking.HeatingUnitPrice);
                        booking.CleaningPostVisitUnitPrice = cc.ConvertCurrency(baseCurrency, newCurrency,
                            (decimal)booking.CleaningPostVisitUnitPrice);
                        booking.ExtraLininSetUnitPrice = cc.ConvertCurrency(baseCurrency, newCurrency,
                            (decimal)booking.ExtraLininSetUnitPrice);
                        booking.MidVactionCleaningUnitPrice = cc.ConvertCurrency(baseCurrency, newCurrency,
                            (decimal)booking.MidVactionCleaningUnitPrice);
                        booking.SwimmingPoolHeatingUnitPrice = cc.ConvertCurrency(baseCurrency, newCurrency,
                            (decimal)booking.SwimmingPoolHeatingUnitPrice);
                        booking.TowelsUnitPrice = cc.ConvertCurrency(baseCurrency, newCurrency,
                            (decimal)booking.TowelsUnitPrice);
                        booking.FirewoodUnitPrice = cc.ConvertCurrency(baseCurrency, newCurrency,
                            (decimal)booking.FirewoodUnitPrice);

                    }
                    catch (Exception)
                    {

                        throw;
                    }
                }

            }
            catch (Exception ex)
            {
                /*Response.Redirect("http://" + Request.Url.Authority + "/Error/PropertyErrorSelection");*/
                //return RedirectToAction("PropertyErrorSelection", "Error", new { propID = CartBooking.PropertyID });                    
            }


            //CURRENCY MUST BE CONVERTED BEFORE THESE METHODS ARE CALLED

            //call meths to set dates
            booking.SetInitalDepositDate();
            booking.SetInitialDepositAmount();

            booking.SetRentalBalanceDueDate(); //1 month before
            booking.CalculateFinalRentalPaymentAmount(); //extrasSummedPrice + price - deposit


            booking.SetBreakageDepositRemittanceDate();
            booking.SetBreakageDepositRemittanceAmount();//1 month after trip end?
            //booking.SetFinalRentalPayment(); //price - deposit

            booking.SetHomeownerAndPRCComissionAmount(db);

            booking.CreationDate = DateTime.Now;


            booking.Cancelled = false;
            booking.Confirmed = false; //if they pay by paypal later, we can update;




            var refGenService = new ReferenceGenerationService();
            booking.BookingPRCReference = refGenService.GenerateBookingReference(booking, property);


            //if (ModelState.IsValid)
            //{

            db.Bookings.Add(booking);

            if (db.SaveChanges() > 0)
            {

                if (booking.BookingID > 0)
                {
                    booking.BookingPRCReference = refGenService.GenerateBookingReference(booking, property);

                    db.Entry(booking).State = EntityState.Modified;
                    db.SaveChanges();

                }





            }
            return booking;
        }
        public BookingExtraSelection CreateBookingExtraSelection(BookingExtraSelection bookingExtraSelection, BookingExtra extra, Customer theCustomer, PortugalVillasContext db)
        {
            bookingExtraSelection.BESCurrencyConversionSymbol = theCustomer.PreferredCurrencySymbol;
            bookingExtraSelection.BESPreferredCurrency = theCustomer.PreferredCurrency;

            var cc = new CurrencyConverterController();


            long? currentBookingTypeID = bookingExtraSelection.GetBookingExtraTypeIDFromBookingExtraSelection();
            bookingExtraSelection.CustomerID = theCustomer.CustomerID;

            //the price already needs to be assigned
            bookingExtraSelection.BESPrice = BookingExtraSelection.GetBookingExtraPrice(bookingExtraSelection, db);
            bookingExtraSelection.BESExtraServicesPrice = BookingExtraSelection.CalculateBookingExtraAdditionalCostsAndAssignToThisBooking(bookingExtraSelection, db);

            bookingExtraSelection.BESTotalServicesPrice = BookingExtraSelection.GetBookingExtraTotalServicesPrice(bookingExtraSelection, db);


            bookingExtraSelection.WhenCreated = DateTime.Now;

            //calc number of guests
            if (bookingExtraSelection.NumberOfGuests == null || bookingExtraSelection.NumberOfGuests == 0)
            {
                bookingExtraSelection.CalculateNoOfGuests();
            }

            //if not UK need to do currency conversion
            if (theCustomer.Country.ToLower() != "united kingdom" && ConfigurationManager.AppSettings["defaultCurrency"] == "GBP")
            {
                var baseCurrency = "GBP";
                var newCurrency = "EUR";

                var exchangeRateFromDB =
                    db.CurrencyExchanges.First(x => x.CurrencyExchangeName == "GBP-EUR");

                try
                {
                    bookingExtraSelection.BESPrice = cc.ConvertCurrency(baseCurrency, newCurrency, (decimal)bookingExtraSelection.BESPrice);
                    bookingExtraSelection.BESCurrencyConversionPrice = bookingExtraSelection.BESPrice;
                    bookingExtraSelection.BESExtraServicesPrice = cc.ConvertCurrency(baseCurrency, newCurrency, (decimal)bookingExtraSelection.BESExtraServicesPrice);
                    bookingExtraSelection.BESTotalServicesPrice = cc.ConvertCurrency(baseCurrency, newCurrency, (decimal)bookingExtraSelection.BESTotalServicesPrice);

                

                    //set exchange rate
                    bookingExtraSelection.BESCurrencyConversionSymbol = exchangeRateFromDB.CurrencyExchangeSymbol;
                    bookingExtraSelection.BESCurrencyExchangeRate = exchangeRateFromDB.CurrencyExchangeRate;
                    bookingExtraSelection.BESPreferredCurrency = "EUR";
                }
                catch (Exception)
                {

                    throw;
                }

            }

            else if (ConfigurationManager.AppSettings["defaultCurrency"] == "USD")
            {
                var baseCurrency = "GBP";
                var newCurrency = "USD";

                var exchangeRateFromDB =
                    db.CurrencyExchanges.First(x => x.CurrencyExchangeName == "GBP-USD");

                try
                {
                    bookingExtraSelection.BESPrice = cc.ConvertCurrency(baseCurrency, newCurrency, (decimal)bookingExtraSelection.BESPrice);
                    bookingExtraSelection.BESCurrencyConversionPrice = bookingExtraSelection.BESPrice;
                    bookingExtraSelection.BESExtraServicesPrice = cc.ConvertCurrency(baseCurrency, newCurrency, (decimal)bookingExtraSelection.BESExtraServicesPrice);
                    bookingExtraSelection.BESTotalServicesPrice = cc.ConvertCurrency(baseCurrency, newCurrency, (decimal)bookingExtraSelection.BESTotalServicesPrice);


                    //set exchange rate
                    bookingExtraSelection.BESCurrencyConversionSymbol = exchangeRateFromDB.CurrencyExchangeSymbol;
                    bookingExtraSelection.BESCurrencyExchangeRate = exchangeRateFromDB.CurrencyExchangeRate;
                    bookingExtraSelection.BESPreferredCurrency = "USD";
                }
                catch (Exception)
                {

                    throw;
                }
            }

            //generate reference
            var refGenService = new ReferenceGenerationService();
            bookingExtraSelection.BookingExtraPRCReference = refGenService.GenerateBESReference(bookingExtraSelection, extra);


            if (ModelState.IsValid)
            {
                db.BookingExtraSelections.Add(bookingExtraSelection);
                if (db.SaveChanges() > 0)
                {
                    //generate reference with ID
                    bookingExtraSelection.BookingExtraPRCReference = refGenService.GenerateBESReference(bookingExtraSelection, extra);

                    db.Entry(bookingExtraSelection).State = EntityState.Modified;
                    db.SaveChanges();
                    return bookingExtraSelection;

                }


            }
            throw new Exception();

        }
        public void TestNewMailAllTemplates()
        {
            Customer testCust = new Customer();
            testCust.FirstName = "Test";
            testCust.LastName = "Customer";
            testCust.EmailAddress = "*****@*****.**";

            Booking booking = new Booking();
            booking.StartDate = new DateTime(2014, 01, 04);
            booking.EndDate = new DateTime(2014, 01, 10);
            booking.NumberOfNights = 5;
            booking.PropertyID = 220;
            booking.BookingID = 513;


            BookingExtraSelection bes = new BookingExtraSelection();
            bes.ExtraRentalDate = new DateTime(2014, 01, 04);
            bes.ExtraReturnDate = new DateTime(2014, 01, 09);
            bes.BookingExtraID = 1;
            bes.BookingExtraSelectionID = 1; //primary key





            EmailController ec = new EmailController();
            /*var ok = ec.SendEmailToCustomer(testCust, , booking, bes);
            ok = ec.SendEmailToCustomer(testCust, EmailOutType.EmailOutEmailType.BookingConfirm, booking);
            ok = ec.SendEmailToCustomer(testCust, EmailOutType.EmailOutEmailType.BookingExtraSelectionConfirm, null, bes);*/




        }
        public CustomerBankDetail CreateCustomerBankDetail(CustomerBankDetail customerBankDetail, Customer customer, PortugalVillasContext db)
        {
            customer.CustomerID = customer.CustomerID;

            db.CustomerBankDetails.Add(customerBankDetail);
            //whack it in the session
            if (db.SaveChanges() > 0)
            {
                //customer now has an ID if the save has worked

            }



            return customerBankDetail;
        }
        public ActionResult TestBookingSteps(Customer cus, CustomerBankDetail bank, List<Booking> bookings = null, List<BookingExtraSelection> bookingExtraSelections = null, List<BookingParticipant> bookingParticipants = null)
        {
            Session["prc_customer"] = new Customer();


            using (var db = new PortugalVillasContext())
            {
                var eventService = new EventController();
                var bookingRepo = new FinalBookingDetailGatheringController();
                //CUSTOMER
                //does customer have ID? if not create new Customer
                if (cus.CustomerID.Equals(0))
                {
                    bookingRepo.CreateCustomer(cus, db);
                }
                else
                {
                    //update customer with new details
                    /*cus.BookingExtraSelections = null;
                    cus.Bookings = null;
                    cus.CreationDate = cus.CreationDate;

                    db.Customers.Attach(cus);
                    db.Entry(cus).State = EntityState.Modified;

                    try
                    {
                        db.SaveChanges();
                    }
                    catch (OptimisticConcurrencyException)
                    {
                       
                    }
                    */
                }

                //BANK DETAIL
                if (bank.CustomerBankDetailID.Equals(0))
                {
                    bookingRepo.CreateCustomerBankDetail(bank, cus, db);
                }
                else
                {
                    //update customer with new details
                    db.CustomerBankDetails.Attach(bank);
                    db.Entry(bank).State = EntityState.Modified;
                    db.SaveChanges();
                }




                //////////////////
                //BOOKING
                //create a parent booking thingy and link it
                BookingParentContainer parentContainer = new BookingParentContainer();
                parentContainer.CustomerID = cus.CustomerID;

                parentContainer = bookingRepo.CreateBookingParentContainer(parentContainer, db);


                foreach (var booking in bookings)
                {   //link to parent booking
                    booking.BookingParentContainerID = parentContainer.BookingParentContainerID;
                    //fill em out and push them to the DB


                  /*  bookingRepo.CreateBooking(booking, cus, db);*/

                    
                    var participantsThisRound =
                        bookingParticipants.Where(x => x.StepNo.Equals(bookingParticipants.Min(y => y.StepNo))).ToList();
                    //create the participants

                    foreach (var bookingParticipant in participantsThisRound)
                    {
                        if (bookingParticipant.BookingParticipantFirstName != "" && bookingParticipant.BookingParticipantFirstName != null 
                            && bookingParticipant.BookingParticipantLastName != "" &&
                             bookingParticipant.BookingParticipantLastName != null)
                        {
                            bookingRepo.CreateBookingParticipant(participantsThisRound, booking, db);
                        }        
                    }
                    


                    foreach (var bookingParticipant in participantsThisRound)
                    {
                        bookingParticipants.Remove(bookingParticipant);               
                    }
         

                    


                    //now check which booking form to send depending on location
                    string EventTypeID;
                    if (cus.Country.ToUpper() == "GB")
                    {
                        EventTypeID = "17";
                    }
                    else
                    {
                        EventTypeID = "20";
                    }

                    //email all docs
                    var form = new FormCollection();
                    form.Add("BookingID", booking.BookingID.ToString());
                    form.Add("EventTypeID", EventTypeID);

                    eventService.AddBookingEvent(form);

                    //email the user of the system 

                }


                foreach (var bes in bookingExtraSelections)
                {
                    //link to parent booking

                }
             

                //wipe cars = booking and bes
                Session["Cart_PropertyBookings"] = null;
                Session["Cart_ExtraBookings"] = null;


                return RedirectToAction("EndOfBookingProcess", "EndOfProcess");
            }

        }
        public ActionResult GetBookingDetails(Customer cus, CustomerBankDetail bank, List<Booking> bookings = null, List<BookingExtraSelection> bookingExtraSelections = null, List<BookingParticipant> bookingParticipants = null)
        {
            //set customer preferred currency symbol and currency

            using (var db = new PortugalVillasContext())
            {

                var account = new AccountController();
                var eventService = new EventController();
                var bookingRepo = new FinalBookingDetailGatheringController();
                //CUSTOMER
                //does customer have ID? if not create new Customer
                if (cus.CustomerID.Equals(0))
                {
                    var returnedCus = bookingRepo.CreateCustomer(cus, db);
                    cus = returnedCus;
                    Session["prc_customer"] = returnedCus;
                }
                else
                {
                    //update customer with new details
                    cus.BookingExtraSelections = null;
                    cus.Bookings = null;

                    //Do the UPDATE
                    if (ModelState.IsValid)
                    {
                        db.Entry(cus).State = EntityState.Modified;
                        var objContextCus = ((IObjectContextAdapter)db).ObjectContext;

                        var refreshableObjectsCus =
                            (from entry in objContextCus.ObjectStateManager.GetObjectStateEntries(
                                EntityState.Added
                                | EntityState.Deleted
                                | EntityState.Modified
                                | EntityState.Unchanged)
                             where entry.EntityKey != null
                             select entry.Entity);

                        objContextCus.Refresh(RefreshMode.ClientWins, refreshableObjectsCus);

                        //if it works, do the update for the userContext, else, don't as it failed
                        if (objContextCus.SaveChanges() > 0)
                        {
                            /*_usersContext.Entry(user).State = EntityState.Modified;
                            _usersContext.SaveChanges();*/
                        }



                    }
                }

                //BANK DETAIL
                if (bank.CustomerBankDetailID.Equals(0))
                {
                    var returnedBank = bookingRepo.CreateCustomerBankDetail(bank, cus, db);
                    Session["prc_customerBankingDetail"] = returnedBank;
                }
                else
                {
                    bank.CustomerID = cus.CustomerID;
                    db.Entry(bank).State = EntityState.Modified;

                    var objContext = ((IObjectContextAdapter)db).ObjectContext;

                    var refreshableObjects = (from entry in objContext.ObjectStateManager.GetObjectStateEntries(
                        EntityState.Added
                        | EntityState.Deleted
                        | EntityState.Modified
                        | EntityState.Unchanged)
                                              where entry.EntityKey != null
                                              select entry.Entity);

                    objContext.Refresh(RefreshMode.ClientWins, refreshableObjects);


                    if (ModelState.IsValid)
                    {

                        if (objContext.SaveChanges() > 0) ;
                        {
                            //great it worked
                        }
                    }

                }


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


                parentContainer = bookingRepo.CreateBookingParentContainer(parentContainer, db);
                //need to add booking reference then propagate to all others below


                //////////////////
                //BOOKING
                //create a parent booking thingy and link i
                if (bookings != null)
                {
                    foreach (var booking in bookings)
                    {
                        booking.Test = false; //it's real, from a customer
                        //convert if neededed

                        //link to parent booking
                        booking.BookingParentContainerID = parentContainer.BookingParentContainerID;
                        //fill em out and push them to the DB

                        var property = db.Properties.Find(booking.PropertyID);

                        booking.Property = property;

                        booking.BookingParticipants = null;
                        bookingRepo.CreateBooking(booking, property, cus, db);



                        var participantsThisRound =
                            bookingParticipants.Where(x => x.StepNo.Equals(bookingParticipants.Min(y => y.StepNo)))
                                .ToList();
                        //create the participants

                        var partstoAdd = new List<BookingParticipant>();
                        foreach (var bookingParticipant in participantsThisRound)
                        {
                            if (bookingParticipant.BookingParticipantFirstName != "" &&
                                bookingParticipant.BookingParticipantFirstName != null
                                && bookingParticipant.BookingParticipantLastName != "" &&
                                bookingParticipant.BookingParticipantLastName != null)
                            {
                                partstoAdd.Add(bookingParticipant);


                            }
                        }



                        foreach (var bookingParticipant in participantsThisRound)
                        {
                            bookingParticipants.Remove(bookingParticipant);
                        }

                        if (partstoAdd.Count > 0)
                        {
                            bookingRepo.CreateBookingParticipant(partstoAdd, booking, db); //create all ones we need
                        }


                        //now check which booking form to send depending on location
                        string EventTypeID;

                        TimeSpan dateRemainder = ((DateTime)booking.StartDate).Subtract(DateTime.Now);
                        int dateRemainderDays = dateRemainder.Days;


                        //late booking form

                        if (cus.Country.ToLower() == "united kingdom" && ConfigurationManager.AppSettings["defaultCurrency"] == "GBP")
                        {
                            if (dateRemainderDays <= 30)
                            {
                                //late uk
                                EventTypeID = "51";
                            }
                            else
                            {
                                //standard UK
                                EventTypeID = "37";
                            }

                        }
                        else
                        {

                            //convert all the bookings to euros                         
                            if (dateRemainderDays <= 30)
                            {
                                //late EU
                                EventTypeID = "52";
                            }
                            else
                            {
                                //standard EU
                                EventTypeID = "20";
                            }

                        }

                        //email all docs
                        var form = new FormCollection();
                        form.Add("BookingID", booking.BookingID.ToString());
                        form.Add("EventTypeID", EventTypeID);

                        eventService.AddBookingEvent(form);

                        //email the user of the system 

                    }
                }



                if (bookingExtraSelections != null)
                {
                    foreach (var bes in bookingExtraSelections)
                    {
                        //?????//convert all BES to EUROS 



                        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);

                        eventService.AddBookingExtraSelectionEvent(form);



                    }
                }


                //wipe cars = booking and bes
                Session["Cart_PropertyBookings"] = null;
                Session["Cart_ExtraBookings"] = null;


                //email the main user with the new services and bookings
                var prc = db.PRCInformations.First();

                MaintainanceMailer mail = new MaintainanceMailer();
                mail.theAsposeMessage.Subject = "You have new bookings:";
                mail.theAsposeMessage.HtmlBody =
                    "<h1>Automated email: You have a new booking</h1><br><p>Customer: ID - " + cus.CustomerID + "-" + cus.FirstName + " " +
                    cus.LastName
                    + "</p>";


                if (bookings != null)
                {
                    foreach (var booking in bookings)
                    {
                        mail.theAsposeMessage.HtmlBody += "<p>Booking: ID - " + booking.BookingID + "-" +
                                                          booking.Property.LegacyReference + " for " +
                                                          booking.NumberOfNights + " " + "nights starting " +
                                                          booking.StartDate.ToString().Substring(0, 10)
                                                          + "</p>";
                    }
                }


                if (bookingExtraSelections != null)
                {
                    foreach (var bes in bookingExtraSelections)
                    {
                        mail.theAsposeMessage.HtmlBody += "<p>Booking: ID - " + bes.BookingExtraSelectionID + " - " +
                                                          bes.BookingExtra.BookingExtraName + " for " + bes.NumberOfDays +
                                                          " " + "days starting " +
                                                          bes.ExtraRentalDate.ToString().Substring(0, 10) + " for " +
                                                          bes.NumberOfGuests + " people"
                                                          + "</p>";
                    }
                }

                var addressees = new MailAddressCollection();
                    addressees.Add(prc.PRCNotificationEmailAddress);
                    if (prc.PRCNotificationEmailAddress2 != null)
                        if (prc.PRCNotificationEmailAddress2 != "")
                        {
                            addressees.Add(prc.PRCNotificationEmailAddress2);
                        }
                    if (prc.PRCNotificationEmailAddress3 != null)
                        if (prc.PRCNotificationEmailAddress3 != "")
                        {
                            addressees.Add(prc.PRCNotificationEmailAddress3);
                        }

                    mail.SendEmail();
               


                return RedirectToAction("EndOfBookingProcess", "EndOfProcess");
            }

        }