Пример #1
0
        public async Task <bool> TestMail()
        {
            //long bookingId = 4;
            //CLayer.Address byUser = BLayer.Bookings.GetBookedByUser(bookingId);
            //List<CLayer.Address> forUser = BLayer.Bookings.GetBookedForUser(bookingId);
            //if (byUser == null) return false;
            //if (forUser.Count == 0) return false;
            //CLayer.Role.Roles rle = BLayer.User.GetRole(byUser.ForBookingUserId);
            //CLayer.Booking details = BLayer.Bookings.GetDetails(bookingId);

            try
            {
                string message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("BConfirmationMail") + "11&key=" + BLayer.Settings.GetValue(CLayer.Settings.PUBLIC_PAGE_LOCK));

                Common.Mailer ml = new Common.Mailer();
                System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
                // BLayer.Settings.GetValue(CLayer.Settings.QUERY_MAILID), "*****@*****.**", "Booking Confirmation", message);
                msg.To.Add(new System.Net.Mail.MailAddress("*****@*****.**", "Anoop T P"));
                msg.From       = new System.Net.Mail.MailAddress(BLayer.Settings.GetValue(CLayer.Settings.QUERY_MAILID), "Staybazar Reservation");
                msg.Subject    = "Testing Reservation";
                msg.Body       = message;
                msg.IsBodyHtml = true;
                await ml.SendMailAsync(msg, Common.Mailer.MailType.Reservation);
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }
            return(true);
        }
Пример #2
0
        public async Task <string> FeedbackSave(string email, string feedback)
        {
            try
            {
                MailMessage mm = new MailMessage();
                mm.To.Add(ConfigurationManager.AppSettings.Get("FeedbackEmail"));
                mm.CC.Add(ConfigurationManager.AppSettings.Get("FeedbackCC"));
                mm.From = new MailAddress(ConfigurationManager.AppSettings.Get("FeedbackEmail"));
                mm.ReplyToList.Add(email);
                mm.Subject    = "Feedback";
                mm.Body       = "<strong>Email Id:</strong> " + email + "<br /><strong>Feedback:</strong><br />" + feedback;
                mm.IsBodyHtml = true;

                Common.Mailer mlr = new Common.Mailer();
                await mlr.SendMailAsyncWithoutFields(mm);

                // BLayer.Query.Savefeedback(email, feedback);
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
                return("false");
            }
            return("true");
        }
        public async Task <bool> ResendemailS(long bookingId)
        {
            try
            {
                if (bookingId < 1)
                {
                    return(false);
                }
                CLayer.Booking details  = BLayer.Bookings.GetDetailsSMS(bookingId);
                CLayer.User    supplier = BLayer.Bookings.GetSupplierDetails(bookingId);
                try
                {
                    string        message = "";
                    Common.Mailer ml      = new Common.Mailer();
                    if (supplier.Email != "" || details.PropertyEmail != "")
                    {
                        if (supplier.Email == "")
                        {
                            supplier.Email        = details.PropertyEmail;
                            details.PropertyEmail = "";
                        }
                        message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("SupplierIntimation") + bookingId.ToString() + "&key=" + BLayer.Settings.GetValue(CLayer.Settings.PUBLIC_PAGE_LOCK));

                        System.Net.Mail.MailMessage supplierMsg = new System.Net.Mail.MailMessage();
                        supplierMsg.To.Add(supplier.Email);
                        supplierMsg.Subject = "Booking Confirmation";
                        supplierMsg.Body    = message;

                        if (details.PropertyEmail != "")
                        {
                            supplierMsg.To.Add(details.PropertyEmail);
                        }
                        supplierMsg.IsBodyHtml = true;

                        try
                        {
                            await ml.SendMailAsync(supplierMsg, Common.Mailer.MailType.Reservation);
                        }
                        catch (Exception ex)
                        {
                            Common.LogHandler.HandleError(ex);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Common.LogHandler.HandleError(ex);
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }
            return(true);
        }
Пример #4
0
        public async Task <ActionResult> Save(QueryModel data)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //if (this.IsCaptchaValid("Captcha is not valid"))
                    //{
                    CLayer.Query query = new CLayer.Query()
                    {
                        Name        = data.Name,
                        Email       = data.Email,
                        Phone       = data.Phone,
                        Subject     = data.Subject,
                        Body        = data.Body,
                        MessageType = (CLayer.ObjectStatus.MsgType)data.MsgType
                    };
                    BLayer.Query.Save(query);
                    string querymail = BLayer.Settings.GetValue(CLayer.Settings.QUERY_MAILID);
                    System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();

                    //string BccEmailsforsupp = BLayer.Settings.GetValue(CLayer.Settings.CUSTOMERQUERYCCMAILS);
                    //if (BccEmailsforsupp.Trim() != "")
                    //{
                    //    string[] emails = BccEmailsforsupp.Split(',');
                    //    for (int i = 0; i < emails.Length; ++i)
                    //    {
                    //        msg.Bcc.Add(emails[i]);
                    //    }
                    //}

                    msg.To.Add(querymail);
                    msg.ReplyToList.Add(data.Email);
                    // msg.From = new System.Net.Mail.MailAddress(querymail);
                    msg.Body    = data.Body;
                    msg.Subject = data.Subject;
                    Common.Mailer ml = new Common.Mailer();
                    await ml.SendMailAsync(msg, Common.Mailer.MailType.Query);

                    return(RedirectToAction("Posted"));
                }
                else
                {
                    ViewBag.Message = "Error: captcha is not valid.";
                    return(View("Index", data));
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
                return(Redirect("~/Admin/ErrorPage"));
            }
        }
Пример #5
0
        public async Task <bool> SendMailsAndSmsForSupplierImport(string SuEmailList)
        {
            try
            {
                string        message = "";
                Common.Mailer ml      = new Common.Mailer();

                System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();

                string emailids = ConfigurationManager.AppSettings.Get("CustomerCareMail");
                if (emailids != "")
                {
                    string[] emails = emailids.Split(',');
                    for (int i = 0; i < emails.Length; ++i)
                    {
                        msg.Bcc.Add(emails[i]);
                    }
                }

                msg.Subject    = "Supplier Confirmation";
                msg.IsBodyHtml = true;


                string[] SuEmails = SuEmailList.Split(',');
                foreach (string email in SuEmails)
                {
                    if (email != "")
                    {
                        msg.To.Add(email);
                        long userid = BLayer.User.GetUserId(email);

                        //string pass = "******";
                        message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("SupImportRegistration") + userid);

                        msg.Body = message;
                        try
                        {
                            // await ml.SendMailAsync(msg, Common.Mailer.MailType.Reservation);
                        }
                        catch (Exception ex)
                        {
                            Common.LogHandler.HandleError(ex);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }

            return(true);
        }
        //public async Task<bool> Sendemail(long UserId, string Email)
        public async Task <bool> Sendemail(long UserId, string Email)
        {
            try
            {
                if (UserId < 1)
                {
                    return(false);
                }
                //CLayer.OfflineBooking data = BLayer.OfflineBooking.GetOfflineBookingCustomerDetailsByID(UserId);
                try
                {
                    string        message = "";
                    Common.Mailer ml      = new Common.Mailer();

                    //if (data.CustomerEmail != "")
                    //{
                    LogHandler.AddLog("Mail process starts:-" + DateTime.Now.ToString());
                    message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("PaymentRequest")
                                                                  + (Guid)Session["PaymentGuid"]);

                    System.Net.Mail.MailMessage PaymentMsg = new System.Net.Mail.MailMessage();
                    //PaymentMsg.To.Add(Session["CustomerEmail"].ToString());
                    PaymentMsg.To.Add(Email);
                    PaymentMsg.Subject    = "Request for Payment";
                    PaymentMsg.Body       = message;
                    PaymentMsg.IsBodyHtml = true;
                    try
                    {
                        LogHandler.AddLog("Mail Sending to reservation starts:-" + DateTime.Now.ToString());
                        await ml.SendMailAsync(PaymentMsg, Common.Mailer.MailType.Reservation);

                        LogHandler.AddLog("Mail Sending to reservation Ends:-" + DateTime.Now.ToString());
                    }
                    catch (Exception ex)
                    {
                        LogHandler.AddLog("Mail Sending Exception Eror(244):-" + DateTime.Now.ToString());
                        Common.LogHandler.HandleError(ex);
                    }
                    //}
                }
                catch (Exception ex)
                {
                    LogHandler.AddLog("Mail Sending Exception Eror(252):-" + DateTime.Now.ToString());
                    Common.LogHandler.HandleError(ex);
                }
            }
            catch (Exception ex)
            {
                LogHandler.AddLog("Mail Sending Exception Eror(258):-" + DateTime.Now.ToString());
                Common.LogHandler.HandleError(ex);
            }
            return(true);
        }
Пример #7
0
        public async Task <string> CustomerInvoiceEmail()
        {
            WebClient wc = new WebClient();

            try
            {
                Models.OfflinePaymentModel   data = new Models.OfflinePaymentModel();
                List <CLayer.OfflineBooking> dt   = BLayer.OfflineBooking.GetBookingDetailsAfterSubmitForCustomer();
                long        OfflineBookingId      = 0;
                MailMessage mm = new MailMessage();

                string BccEmailsforcususer = BLayer.Settings.GetValue(CLayer.Settings.CC_CUSTOMERCOMMUNICATION);
                if (BccEmailsforcususer != "")
                {
                    string[] emails = BccEmailsforcususer.Split(',');
                    for (int i = 0; i < emails.Length; ++i)
                    {
                        mm.Bcc.Add(emails[i]);
                    }
                }


                mm.From = new MailAddress(ConfigurationManager.AppSettings.Get("CustomerCareMail"));
                Common.Mailer mlr = new Common.Mailer();
                mm.IsBodyHtml = true;
                mm.Subject    = "Invoice";
                foreach (CLayer.OfflineBooking offbook in dt)
                {
                    OfflineBookingId = offbook.OfflineBookingId;
                    string result = await GetMailBody(OfflineBookingId);

                    mm.To.Clear();
                    mm.To.Add(offbook.CustomerEmail);
                    mm.Body = result;
                    await mlr.SendMailAsyncWithoutFields(mm);
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
                return("false");
            }
            return("true");
        }
Пример #8
0
        public async Task <bool> BookingDeleteRequestAlertMail(long OfflineBookingId)
        {
            try
            {
                string        message = "";
                Common.Mailer ml      = new Common.Mailer();
                System.Net.Mail.MailMessage MailMsg = new System.Net.Mail.MailMessage();
                message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("OfflineBookingDeleteRequest")
                                                              + OfflineBookingId.ToString());

                string AccountMail = BLayer.Settings.GetValue(CLayer.Settings.BOOK_DELETE_ALERT_EMAILS);
                if (AccountMail != "")
                {
                    string[] Accemails = AccountMail.Split(',');
                    for (int i = 0; i < Accemails.Length; ++i)
                    {
                        MailMsg.To.Add(Accemails[i]);
                    }
                }

                MailMsg.Subject    = "Booking Delete Request";
                MailMsg.Body       = message;
                MailMsg.IsBodyHtml = true;
                try
                {
                    await ml.SendMailAsync(MailMsg, Common.Mailer.MailType.Support);
                }
                catch (Exception ex)
                {
                    Common.LogHandler.HandleError(ex);
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }
            return(true);
        }
Пример #9
0
        public async Task <string> SendQuery(string name, string email, string phone, string body, long PropertyId)
        {
            try
            {
                CLayer.Property data = new CLayer.Property();
                if (PropertyId > 0)
                {
                    data = BLayer.Property.Get(PropertyId);
                }
                MailMessage mm = new MailMessage();
                mm.To.Add(ConfigurationManager.AppSettings.Get("CustomerCareMail"));
                string emailids = ConfigurationManager.AppSettings.Get("EnquiryCC");
                if (emailids != "")
                {
                    string[] emails = emailids.Split(',');
                    for (int i = 0; i < emails.Length; ++i)
                    {
                        mm.CC.Add(emails[i]);
                    }
                }
                mm.From = new MailAddress(ConfigurationManager.AppSettings.Get("CustomerCareMail"));
                mm.ReplyToList.Add(email);
                mm.Subject    = "Enquiry";
                mm.Body       = "<strong>Name:</strong> " + name + "<br /><strong>Email Id:</strong> " + email + "<br /><strong>Phone No:</strong> " + phone + "<br /><strong>Property:</strong> " + "<a href='https://www.staybazar.com/property/Index/" + PropertyId + "' >" + data.Title + "</a>" + "," + data.Location + "<br /><strong>Comment:</strong><br/> " + body;
                mm.IsBodyHtml = true;
                Common.Mailer mlr = new Common.Mailer();
                await mlr.SendMailAsyncWithoutFields(mm);

                // BLayer.Query.Savefeedback(email, feedback);
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
                return("false");
            }
            return("true");
        }
Пример #10
0
        public async Task <string> Email()
        {
            WebClient wc = new WebClient();

            try
            {
                Models.BookingModel   data    = new Models.BookingModel();
                List <CLayer.Booking> dt      = BLayer.Bookings.GetPartialBookingDetails();
                string         url            = ConfigurationManager.AppSettings.Get(URL_PARTIALPAYMENT);
                long           BookId         = 0;
                CLayer.Booking PaymentDetails = null;
                MailMessage    mm             = new MailMessage();
                mm.Bcc.Add(ConfigurationManager.AppSettings.Get("CustomerCareMail"));
                mm.From = new MailAddress(ConfigurationManager.AppSettings.Get("CustomerCareMail"));
                Common.Mailer mlr = new Common.Mailer();
                mm.IsBodyHtml = true;
                mm.Subject    = "Reminder: Payment pending";
                foreach (CLayer.Booking book in dt)
                {
                    PaymentDetails = book;
                    BookId         = book.BookingId;
                    string result = wc.DownloadString(url + BookId);
                    mm.To.Clear();
                    mm.To.Add(book.Email);
                    //mm.ReplyToList.Add("*****@*****.**");
                    mm.Body = result;
                    await mlr.SendMailAsyncWithoutFields(mm);
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
                return("false");
            }
            return("true");
            //return View();
        }
Пример #11
0
        public async Task <bool> ResendregemailCorp(long UserId, string Password)
        {
            try
            {
                string        message = "";
                Common.Mailer ml      = new Common.Mailer();
                CLayer.B2B    data    = BLayer.B2B.Get(UserId);

                UserManager <StayBazar.Lib.Security.IdentityUser> usrmngr = new UserManager <StayBazar.Lib.Security.IdentityUser>(new UserStore());
                String hashedNewPassword = usrmngr.PasswordHasher.HashPassword(Password);
                BLayer.User.SetPassword(UserId, hashedNewPassword);
                System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
                message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("B2BRegistration") + UserId.ToString() + "&pass="******"*****@*****.**");
                msg.Subject    = "Staybazar Account";
                msg.Body       = message;
                msg.IsBodyHtml = true;
                try
                {
                    await ml.SendMailAsyncForBooking(msg, Common.Mailer.MailType.Reservation);
                }
                catch (Exception ex)
                {
                    Common.LogHandler.HandleError(ex);
                }
                return(true);
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
                return(false);
            }
        }
Пример #12
0
        public async Task <bool> SupplierInvoiceToSupplier()
        {
            List <CLayer.OfflineBooking> BookingList = BLayer.OfflineBooking.GetOfflinebookingsAtCheckInOutNow();

            foreach (CLayer.OfflineBooking dt in BookingList)
            {
                string        message  = "";
                string        Filename = "";
                Common.Mailer ml       = new Common.Mailer();
                try
                {
                    if (dt.PropertyEmail != "" || dt.SupplierEmail != "")
                    {
                        message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("SupplierInvoiceOfflineBookGST") + dt.OfflineBookingId.ToString() + "&key=" + BLayer.Settings.GetValue(CLayer.Settings.PUBLIC_PAGE_LOCK));

                        System.Net.Mail.MailMessage supplierMsg = new System.Net.Mail.MailMessage();

                        supplierMsg.Subject = "Supplier Invoice";
                        supplierMsg.Body    = message;

                        if (dt.PropertyEmail != null)
                        {
                            if (dt.PropertyEmail != "")
                            {
                                supplierMsg.CC.Add(dt.PropertyEmail);
                            }
                        }

                        if (dt.SupplierEmail != null)
                        {
                            if (dt.SupplierEmail != "")
                            {
                                supplierMsg.To.Add(dt.SupplierEmail);
                            }
                        }

                        string AccountMail = BLayer.Settings.GetValue(CLayer.Settings.SUPPLIER_INVOICE_REQUEST_MAILS);
                        if (AccountMail != "")
                        {
                            string[] Accemails = AccountMail.Split(',');
                            for (int i = 0; i < Accemails.Length; ++i)
                            {
                                supplierMsg.CC.Add(Accemails[i]);
                            }
                        }


                        supplierMsg.IsBodyHtml = true;

                        //add atachment
                        try
                        {
                            Areas.Admin.Models.OfflineBookingModel data = new Areas.Admin.Models.OfflineBookingModel();
                            data.OfflineBookingId = dt.OfflineBookingId;
                            var PDFResult = new ViewAsPdf("~/Areas/Admin/Views/OfflineBookingGST/SupplierInvoice.cshtml", data)
                            {
                                CustomSwitches =
                                    "--footer-center \"  DOS: " +
                                    DateTime.Now.Date.ToString("MM/dd/yyyy") + "  Page: [page]/[toPage]\"" +
                                    " --footer-line --footer-font-size \"9\" --footer-spacing 6 --footer-font-name \"calibri light\""
                            };
                            string newdirectory = "Files\\Temp\\SupplierInvoice\\" + dt.OfflineBookingId;
                            if (!Directory.Exists(Server.MapPath("~") + "\\" + newdirectory))
                            {
                                Directory.CreateDirectory(Server.MapPath("~") + "\\" + newdirectory);
                            }
                            Filename = Server.MapPath("~") + "\\" + newdirectory + "\\" + "SupplierInvoice_" + dt.ConfirmationNumber + ".pdf";
                            var byteArray  = PDFResult.BuildPdf(ControllerContext);
                            var fileStream = new FileStream(Filename, FileMode.Create, FileAccess.Write);
                            fileStream.Write(byteArray, 0, byteArray.Length);
                            fileStream.Close();
                            fileStream.Dispose();
                            Attachment attacht = new Attachment(Filename, MediaTypeNames.Application.Octet);
                            supplierMsg.Attachments.Add(attacht);
                        }
                        catch (Exception ex)
                        {
                            Common.LogHandler.HandleError(ex);
                        }



                        try
                        {
                            await ml.SendMailAsync(supplierMsg, Common.Mailer.MailType.Reservation);
                        }
                        catch (Exception ex)
                        {
                            Common.LogHandler.HandleError(ex);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Common.LogHandler.HandleError(ex);
                }
            }
            return(true);
        }
Пример #13
0
        //RESEND EMAIL
        public async Task <bool> ResendemailC(long bookingId)
        {
            //send customer email/message
            //email
            if (bookingId < 1)
            {
                return(false);
            }
            CLayer.Address        byUser  = BLayer.Bookings.GetBookedByUser(bookingId);
            List <CLayer.Address> forUser = BLayer.Bookings.GetBookedForUser(bookingId);

            CLayer.Booking details  = BLayer.Bookings.GetDetailsSMS(bookingId);
            CLayer.User    supplier = BLayer.Bookings.GetSupplierDetails(bookingId);
            if (byUser == null)
            {
                return(false);
            }
            if (forUser.Count == 0)
            {
                return(false);
            }
            CLayer.Role.Roles rle = BLayer.User.GetRole(byUser.UserId);
            try
            {
                string        message = "";
                Common.Mailer ml      = new Common.Mailer();
                message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("Bofflinebookconfirm") + bookingId.ToString());

                System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
                //guest mail added
                msg.To.Add(forUser[0].Email);
                if (forUser[0].Email != byUser.Email)
                {
                    msg.CC.Add(byUser.Email);
                }

                string BccEmailsforcususer = BLayer.Settings.GetValue(CLayer.Settings.CC_CUSTOMERCOMMUNICATION);
                if (BccEmailsforcususer != "")
                {
                    string[] emails = BccEmailsforcususer.Split(',');
                    for (int i = 0; i < emails.Length; ++i)
                    {
                        msg.Bcc.Add(emails[i]);
                    }
                }
                msg.Subject = "Booking Payment";
                msg.Body    = message;

                msg.IsBodyHtml = true;

                try
                {
                    await ml.SendMailAsync(msg, Common.Mailer.MailType.Reservation);
                }
                catch (Exception ex)
                {
                    Common.LogHandler.HandleError(ex);
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }
            return(true);
        }
Пример #14
0
        public async Task <bool> ResendemailSGST(long OfflineBookingId, long BookingDetailsId, string key)
        {
            try
            {
                string lck = BLayer.Settings.GetValue(CLayer.Settings.PUBLIC_PAGE_LOCK);
                if (key != lck)
                {
                    return(true);
                }



                if (OfflineBookingId < 1)
                {
                    return(false);
                }
                CLayer.OfflineBooking Offlinedata         = BLayer.OfflineBooking.GetAllDetailsById(OfflineBookingId);
                CLayer.OfflineBooking OfflinePropertydata = BLayer.OfflineBooking.GetAllpropertyDetails(OfflineBookingId);
                CLayer.OfflineBooking CustomerDetails     = BLayer.OfflineBooking.GetAllCustomerDetails(OfflineBookingId);

                if (CustomerDetails == null)
                {
                    return(false);
                }
                if (OfflinePropertydata == null)
                {
                    return(false);
                }

                CLayer.StayCategory      Staycategorydetails      = BLayer.StayCategory.Get(Convert.ToInt32(Offlinedata.StayCategoryid));
                CLayer.AccommodationType AccommodationTypedetails = BLayer.AccommodationType.Get(Convert.ToInt32(Offlinedata.Accommodationtypeid));

                CLayer.Role.Roles rle = BLayer.User.GetRole(Offlinedata.CustomerId);

                string        message = "";
                Common.Mailer ml      = new Common.Mailer();

                if (OfflineBookingId < 1)
                {
                    return(false);
                }
                try
                {
                    if (OfflinePropertydata.PropertyEmail != "")
                    {
                        message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("SupplierIntemationOfflineBookGST") + OfflineBookingId.ToString() + "&key=" + BLayer.Settings.GetValue(CLayer.Settings.PUBLIC_PAGE_LOCK) + "&BookingDetailsId=" + BookingDetailsId);

                        System.Net.Mail.MailMessage supplierMsg = new System.Net.Mail.MailMessage();

                        string BccEmailsforsupp = BLayer.Settings.GetValue(CLayer.Settings.CC_SUPPLIERCOMMUNICATION);
                        if (BccEmailsforsupp != "")
                        {
                            string[] emails = BccEmailsforsupp.Split(',');
                            for (int i = 0; i < emails.Length; ++i)
                            {
                                supplierMsg.Bcc.Add(emails[i]);
                            }
                        }

                        supplierMsg.Subject = "Booking Confirmation";
                        supplierMsg.Body    = message;

                        if (OfflinePropertydata.PropertyEmail != "")
                        {
                            supplierMsg.To.Add(OfflinePropertydata.PropertyEmail);
                        }
                        supplierMsg.IsBodyHtml = true;

                        try
                        {
                            await ml.SendMailAsync(supplierMsg, Common.Mailer.MailType.Reservation);
                        }
                        catch (Exception ex)
                        {
                            Common.LogHandler.HandleError(ex);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Common.LogHandler.HandleError(ex);
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }
            return(true);
        }
Пример #15
0
        //Confirm Booking
        public async Task <bool> BookingConfirm(long bookingId)
        {
            try
            {
                BLayer.Bookings.SetStatus((int)CLayer.ObjectStatus.BookingStatus.offlineconfirm, bookingId);

                //send customer email/message
                //email
                if (bookingId < 1)
                {
                    return(false);
                }
                CLayer.Address        byUser   = BLayer.Bookings.GetBookedByUser(bookingId);
                List <CLayer.Address> forUser  = BLayer.Bookings.GetBookedForUser(bookingId);
                CLayer.Booking        details  = BLayer.Bookings.GetDetailsSMS(bookingId);
                CLayer.User           supplier = BLayer.Bookings.GetSupplierDetails(bookingId);
                if (byUser == null)
                {
                    return(false);
                }
                if (forUser.Count == 0)
                {
                    return(false);
                }
                CLayer.Role.Roles rle = BLayer.User.GetRole(byUser.UserId);
                try
                {
                    string        message = "";
                    Common.Mailer ml      = new Common.Mailer();
                    //for normal user mail body
                    //message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("Bofflinebookconfirm") + bookingId.ToString() + "&key=" + BLayer.Settings.GetValue(CLayer.Settings.PUBLIC_PAGE_LOCK));
                    message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("Bofflinebookconfirm") + bookingId.ToString());

                    System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
                    //guest mail added
                    msg.To.Add(forUser[0].Email);
                    if (forUser[0].Email != byUser.Email)
                    {
                        msg.CC.Add(byUser.Email);
                    }

                    string BccEmailsforcususer = BLayer.Settings.GetValue(CLayer.Settings.CC_CUSTOMERCOMMUNICATION);
                    if (BccEmailsforcususer != "")
                    {
                        string[] emails = BccEmailsforcususer.Split(',');
                        for (int i = 0; i < emails.Length; ++i)
                        {
                            msg.Bcc.Add(emails[i]);
                        }
                    }

                    //for corporate admins
                    if (rle == CLayer.Role.Roles.CorporateUser)
                    {
                        long cid = BLayer.B2B.GetCorporateIdOfUser(byUser.UserId);
                        if (cid > 0)
                        {
                            string em = BLayer.User.GetEmail(cid);
                            if (em != null && em != "")
                            {
                                msg.CC.Add(em);
                            }
                        }
                    }
                    msg.Subject = "Booking Payment";
                    msg.Body    = message;

                    msg.IsBodyHtml = true;

                    try
                    {
                        await ml.SendMailAsync(msg, Common.Mailer.MailType.Reservation);
                    }
                    catch (Exception ex)
                    {
                        Common.LogHandler.HandleError(ex);
                    }

                    //message
                    //if (bookingId < 1) return false;
                    //if (byUser == null) return false;
                    //if (forUser.Count == 0) return false;
                    //try
                    //{
                    //    string phone = forUser[0].Mobile;
                    //    if (phone == "") phone = forUser[0].Phone;
                    //    string smsmsg = Common.SMSGateway.GetNewBookingMessage(forUser[0].Firstname + " " + forUser[0].Lastname, details.OrderNo, details.CheckIn.ToString("MMM dd,yyyy"),
                    //        details.CheckOut.ToString("MMM dd,yyyy"), details.PropertyTitle, details.propertyCity, details.AccommodationTypeTitle, BLayer.Settings.GetValue(CLayer.Settings.STAYB_CONTACTNO));
                    //    bool b = false;
                    //    phone = Common.Utils.GetMobileNo(phone);

                    //    if (phone != "")
                    //    {
                    //        b = await Common.SMSGateway.Send(smsmsg, phone);
                    //    }
                    //}
                    //catch (Exception ex)
                    //{
                    //    Common.LogHandler.HandleError(ex);
                    //}

                    //send supplier email/message
                    //message
                    //if (bookingId < 1) return false;
                    //if (byUser == null) return false;
                    //if (forUser.Count == 0) return false;
                    //try
                    //{
                    //    string phone = forUser[0].Mobile;
                    //    if (phone == "") phone = forUser[0].Phone;
                    //    string smsmsg = Common.SMSGateway.GetNewBookingMessage(forUser[0].Firstname + " " + forUser[0].Lastname, details.OrderNo, details.CheckIn.ToString("MMM dd,yyyy"),
                    //        details.CheckOut.ToString("MMM dd,yyyy"), details.PropertyTitle, details.propertyCity, details.AccommodationTypeTitle, BLayer.Settings.GetValue(CLayer.Settings.STAYB_CONTACTNO));
                    //    bool b = false;
                    //    phone = Common.Utils.GetMobileNo(phone);

                    //    if (phone != "")
                    //    {
                    //        b = await Common.SMSGateway.Send(smsmsg, phone);
                    //    }
                    //}
                    //catch (Exception ex)
                    //{
                    //    Common.LogHandler.HandleError(ex);
                    //}

                    //email
                    //if (bookingId < 1) return false;
                    //try
                    //{
                    //    if (supplier.Email != "" || details.PropertyEmail != "")
                    //    {
                    //        if (supplier.Email == "")
                    //        {
                    //            supplier.Email = details.PropertyEmail;
                    //            details.PropertyEmail = "";
                    //        }
                    //        //   message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("SupplierIntimation") + bookingId.ToString() + "&key=" + BLayer.Settings.GetValue(CLayer.Settings.PUBLIC_PAGE_LOCK));
                    //        message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("SupplierIntimation") + bookingId.ToString());
                    //        System.Net.Mail.MailMessage supplierMsg = new System.Net.Mail.MailMessage();
                    //        supplierMsg.To.Add(supplier.Email);
                    //        supplierMsg.Subject = "Booking Confirmation";
                    //        supplierMsg.Body = message;

                    //        string BccEmailsforsupp = BLayer.Settings.GetValue("CCSuppliercommunications ");
                    //        if (BccEmailsforsupp != "")
                    //        {
                    //            string[] emails = BccEmailsforsupp.Split(',');
                    //            for (int i = 0; i < emails.Length; ++i)
                    //            {
                    //                supplierMsg.Bcc.Add(emails[i]);
                    //            }
                    //        }


                    //        if (details.PropertyEmail != "") supplierMsg.To.Add(details.PropertyEmail);
                    //        supplierMsg.IsBodyHtml = true;

                    //        try
                    //        {
                    //            await ml.SendMailAsync(supplierMsg, Common.Mailer.MailType.Reservation);
                    //        }
                    //        catch (Exception ex)
                    //        {
                    //            Common.LogHandler.HandleError(ex);
                    //        }

                    //    }

                    //}
                    //catch (Exception ex)
                    //{
                    //    Common.LogHandler.HandleError(ex);
                    //}
                }
                catch (Exception ex)
                {
                    Common.LogHandler.HandleError(ex);
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }
            return(true);
        }
Пример #16
0
        public async Task <bool> ResendemailC(long OfflineBookingId)
        {
            return(true);

            try
            {
                if (OfflineBookingId < 1)
                {
                    return(false);
                }
                CLayer.OfflineBooking Offlinedata         = BLayer.OfflineBooking.GetAllDetailsById(OfflineBookingId);
                CLayer.OfflineBooking OfflinePropertydata = BLayer.OfflineBooking.GetAllpropertyDetails(OfflineBookingId);
                CLayer.OfflineBooking CustomerDetails     = BLayer.OfflineBooking.GetAllCustomerDetails(OfflineBookingId);

                if (CustomerDetails == null)
                {
                    return(false);
                }
                if (OfflinePropertydata == null)
                {
                    return(false);
                }

                CLayer.StayCategory      Staycategorydetails      = BLayer.StayCategory.Get(Convert.ToInt32(Offlinedata.StayCategoryid));
                CLayer.AccommodationType AccommodationTypedetails = BLayer.AccommodationType.Get(Convert.ToInt32(Offlinedata.Accommodationtypeid));

                CLayer.Role.Roles rle = BLayer.User.GetRole(Offlinedata.CustomerId);

                string        message = "";
                Common.Mailer ml      = new Common.Mailer();

                string link = System.Configuration.ConfigurationManager.AppSettings.Get("OfflineBookingConfirmation") + OfflineBookingId.ToString() + "&key=" + BLayer.Settings.GetValue(CLayer.Settings.PUBLIC_PAGE_LOCK);
                //for normal user mail body
                message = await Common.Mailer.MessageFromHtml(link);

                System.Net.Mail.MailMessage customerMsg = new System.Net.Mail.MailMessage();
                //guest mail added
                customerMsg.To.Add(CustomerDetails.CustomerEmail);

                string BccEmailsforcususer = BLayer.Settings.GetValue(CLayer.Settings.CC_CUSTOMERCOMMUNICATION);
                if (BccEmailsforcususer != "")
                {
                    string[] emails = BccEmailsforcususer.Split(',');
                    for (int i = 0; i < emails.Length; ++i)
                    {
                        customerMsg.Bcc.Add(emails[i]);
                    }
                }
                customerMsg.Subject = "Booking Confirmation";
                customerMsg.Body    = message;

                customerMsg.IsBodyHtml = true;
                try
                {
                    await ml.SendMailAsync(customerMsg, Common.Mailer.MailType.Reservation);
                }
                catch (Exception ex)
                {
                    Common.LogHandler.HandleError(ex);
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }
            return(true);
        }
        public async Task <ActionResult> Accept(long Id)
        {
            try
            {
                CLayer.B2B data = BLayer.B2B.Get(Id);
                BLayer.B2B.SetStatus(Id, (int)CLayer.ObjectStatus.StatusType.Accepted);
                string Password = Guid.NewGuid().ToString().Substring(0, 6);
                UserManager <StayBazar.Lib.Security.IdentityUser> usrmngr = new UserManager <StayBazar.Lib.Security.IdentityUser>(new UserStore());
                String hashedNewPassword = usrmngr.PasswordHasher.HashPassword(Password);
                BLayer.User.SetPassword(data.UserId, hashedNewPassword);
                BLayer.User.SetStatus(data.UserId.ToString(), (int)Models.HostModel.StatusTypes.Active);
                BLayer.B2B.SetApprovalDate(data.UserId, DateTime.Today);
                //string querymail = BLayer.Settings.GetValue(CLayer.Settings.QUERY_MAILID);
                System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
                msg.To.Add(data.Email);
                // msg.From = new System.Net.Mail.MailAddress(querymail);
                msg.Body = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("B2BRegistration") + Id.ToString() + "&pass="******"&key=" + BLayer.Settings.GetValue(CLayer.Settings.PUBLIC_PAGE_LOCK));

                //"Your staybazar account request has been accepted. User Name: " + data.Email + " , Password:"******"Staybazar Account";
                Common.Mailer ml = new Common.Mailer();

                if (data.UserType == (int)CLayer.Role.Roles.Supplier)
                {
                    // add bcc only for Suppliercommunications
                    string BccEmailsforsupp = BLayer.Settings.GetValue(CLayer.Settings.CC_SUPPLIERCOMMUNICATION);
                    if (BccEmailsforsupp != "")
                    {
                        string[] emails = BccEmailsforsupp.Split(',');
                        for (int i = 0; i < emails.Length; ++i)
                        {
                            msg.Bcc.Add(emails[i]);
                        }
                    }
                }
                else
                {
                    // add bcc for Customercommunications
                    string BccEmailsforcus = BLayer.Settings.GetValue(CLayer.Settings.CC_CUSTOMERCOMMUNICATION);
                    if (BccEmailsforcus != "")
                    {
                        string[] emails = BccEmailsforcus.Split(',');
                        for (int i = 0; i < emails.Length; ++i)
                        {
                            msg.Bcc.Add(emails[i]);
                        }
                    }
                }

                await ml.SendMailAsyncForBooking(msg, Common.Mailer.MailType.Query);

                if (data.UserType == (int)CLayer.Role.Roles.Supplier)
                {
                    return(RedirectToAction("Supplier"));
                }
                else if (data.UserType == (int)CLayer.Role.Roles.Agent)
                {
                    return(RedirectToAction("TravelAgent"));
                }
                else if (data.UserType == (int)CLayer.Role.Roles.Affiliate)
                {
                    return(RedirectToAction("Affiliates"));
                }
                return(RedirectToAction("Corporate"));
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
                return(Redirect("~/Admin/ErrorPage"));
            }
        }
        //RESEND EMAIL
        public async Task <bool> ResendemailC(long bookingId)
        {
            try
            {
                if (bookingId < 1)
                {
                    return(false);
                }
                CLayer.Address        byUser  = BLayer.Bookings.GetBookedByUser(bookingId);
                List <CLayer.Address> forUser = BLayer.Bookings.GetBookedForUser(bookingId);
                if (byUser == null)
                {
                    return(false);
                }
                if (forUser.Count == 0)
                {
                    return(false);
                }
                CLayer.Role.Roles rle = BLayer.User.GetRole(byUser.UserId);
                try
                {
                    string        message = "";
                    Common.Mailer ml      = new Common.Mailer();
                    //for normal user mail body
                    message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("BConfirmationMail") + bookingId.ToString() + "&key=" + BLayer.Settings.GetValue(CLayer.Settings.PUBLIC_PAGE_LOCK));

                    System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
                    //guest mail added
                    msg.To.Add(forUser[0].Email);
                    if (forUser[0].Email != byUser.Email)
                    {
                        msg.CC.Add(byUser.Email);
                    }
                    //for corporate admins
                    if (rle == CLayer.Role.Roles.CorporateUser)
                    {
                        //  message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("CorpIntimation") + bookingId.ToString() + "&key=" + BLayer.Settings.GetValue(CLayer.Settings.PUBLIC_PAGE_LOCK));
                        long cid = BLayer.B2B.GetCorporateIdOfUser(byUser.UserId);
                        if (cid > 0)
                        {
                            string em = BLayer.User.GetEmail(cid);
                            if (em != null && em != "")
                            {
                                msg.CC.Add(em);
                            }
                        }
                    }
                    msg.Subject = "Booking Confirmation";
                    msg.Body    = message;

                    msg.IsBodyHtml = true;
                    try
                    {
                        await ml.SendMailAsync(msg, Common.Mailer.MailType.Reservation);
                    }
                    catch (Exception ex)
                    {
                        Common.LogHandler.HandleError(ex);
                    }
                }
                catch (Exception ex)
                {
                    Common.LogHandler.HandleError(ex);
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }
            return(true);
        }
Пример #19
0
        public async Task <ActionResult> FormSubmit(Models.FormSubmitModel Model)
        {
            try
            {
                try
                {
                    if (Model != null)
                    {
                        CLayer.FormSubmitcs data = new CLayer.FormSubmitcs();
                        data.Name          = Model.Name;
                        data.ContactNo     = Model.ContactNo;
                        data.Email         = Model.Email;
                        data.EventName     = Model.EventName;
                        data.EventLocation = Model.EventLocation;
                        data.CheckIn       = Convert.ToDateTime(Model.CheckIn).ToString("yyyy-MM-dd");
                        data.CheckOut      = Convert.ToDateTime(Model.CheckOut).ToString("yyyy-MM-dd");
                        data.NoOfAdult     = Model.NoOfAdult;
                        data.NoOfChild     = Model.NoOfChild;
                        data.Website       = Model.Website;
                        data.NoOfRooms     = Model.NoOfRooms;
                        BLayer.Query.SaveQueryForm(data);
                    }
                }
                catch (Exception ex)
                {
                    Common.LogHandler.HandleError(ex);
                }


                MailMessage mm         = new MailMessage();
                string      emailidsto = ConfigurationManager.AppSettings.Get("QueryMailTo");
                if (emailidsto != "")
                {
                    string[] emailsto = emailidsto.Split(',');
                    for (int i = 0; i < emailsto.Length; ++i)
                    {
                        mm.To.Add(emailsto[i]);
                    }
                }



                string emailidsbcc = ConfigurationManager.AppSettings.Get("QueryMailBcc");
                if (emailidsbcc != "")
                {
                    string[] emailsbcc = emailidsbcc.Split(',');
                    for (int i = 0; i < emailsbcc.Length; ++i)
                    {
                        mm.CC.Add(emailsbcc[i]);
                    }
                }
                string QuerySwimindiaTo = ConfigurationManager.AppSettings.Get("QuerySwimindiato");
                mm.CC.Add(QuerySwimindiaTo);


                mm.From       = new MailAddress(ConfigurationManager.AppSettings.Get("CustomerCareMail"));
                mm.Subject    = "Query from SwimIndia User";
                mm.Body       = "<strong>Name:</strong> " + Model.Name + "<br /><strong>Email Address:</strong> " + Model.Email + "<br /><strong>Contact No:</strong> " + Model.ContactNo + "<br /><strong>Meet Name:</strong> " + Model.EventName + "<br /><strong>Meet Location:</strong> " + Model.EventLocation + "<br /><strong>No Of Travellers:- </strong>" + "<br /><strong style='margin-left: 25px;'>Adult:</strong> " + Model.NoOfAdult + "<br /><strong style='margin-left: 25px;'>Children:</strong> " + Model.NoOfChild + "<br /><strong>No Of Rooms Required:</strong> " + Model.NoOfRooms + "<br /><strong>Check In Date:</strong> " + Model.CheckIn + "<br /><strong>Check Out Date:</strong> " + Model.CheckOut;
                mm.IsBodyHtml = true;
                Common.Mailer mlr = new Common.Mailer();
                await mlr.SendMailAsyncWithoutFields(mm);
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }



            string message = "";

            message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("QueryMailCustomer") + Model.Name.ToString());

            MailMessage mm1 = new MailMessage();

            mm1.To.Add(Model.Email);


            string emailidsto1 = ConfigurationManager.AppSettings.Get("QueryMailTo");

            if (emailidsto1 != "")
            {
                string[] emailsto1 = emailidsto1.Split(',');
                for (int i = 0; i < emailsto1.Length; ++i)
                {
                    mm1.To.Add(emailsto1[i]);
                }
            }

            string emailidsbcc1 = ConfigurationManager.AppSettings.Get("QueryMailBcc");

            if (emailidsbcc1 != "")
            {
                string[] emailsbcc1 = emailidsbcc1.Split(',');
                for (int i = 0; i < emailsbcc1.Length; ++i)
                {
                    mm1.CC.Add(emailsbcc1[i]);
                }
            }

            mm1.From       = new MailAddress(ConfigurationManager.AppSettings.Get("CustomerCareMail"));
            mm1.Subject    = "Query Recieved";
            mm1.Body       = message;
            mm1.IsBodyHtml = true;
            Common.Mailer mlr1 = new Common.Mailer();

            try
            {
                await mlr1.SendMailAsyncWithoutFields(mm1);
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }

            return(RedirectToAction("ThankYou", "SubmitForm"));
        }
Пример #20
0
        public async Task <string> InvoicePendingEmail()
        {
            WebClient wc = new WebClient();

            try
            {
                Models.OfflinePaymentModel data = new Models.OfflinePaymentModel();
                List <CLayer.Invoice>      dt   = BLayer.OfflineBooking.GetDetailsNotSubmittedandGenerated();
                MailMessage mm = new MailMessage();

                string Toemailids = ConfigurationManager.AppSettings.Get("InvoicePendingListSendToMailids");
                if (Toemailids != "")
                {
                    string[] emails = Toemailids.Split(',');
                    for (int i = 0; i < emails.Length; ++i)
                    {
                        mm.To.Add(emails[i]);
                    }
                }

                string Ccemailids = ConfigurationManager.AppSettings.Get("InvoicePendingListSendCcMailids");
                if (Ccemailids != "")
                {
                    string[] emails = Ccemailids.Split(',');
                    for (int i = 0; i < emails.Length; ++i)
                    {
                        mm.CC.Add(emails[i]);
                    }
                }


                //string BccEmailsforcususer = BLayer.Settings.GetValue(CLayer.Settings.CC_CUSTOMERCOMMUNICATION);
                //if (BccEmailsforcususer != "")
                //{
                //    string[] emails = BccEmailsforcususer.Split(',');
                //    for (int i = 0; i < emails.Length; ++i)
                //    {
                //        mm.Bcc.Add(emails[i]);
                //    }
                //}

                //mm.To.Add(BLayer.Settings.GetValue(CLayer.Settings.SUPPORT_EMAIL));



                mm.From = new MailAddress(ConfigurationManager.AppSettings.Get("CustomerCareMail"));
                Common.Mailer mlr = new Common.Mailer();
                mm.IsBodyHtml = true;
                mm.Subject    = "Invoice Pending";
                string result = await GetMailBodyForNotSubmittedandGeneratedList();

                mm.Body = result;

                if (dt != null)
                {
                    if (dt.Count > 0)
                    {
                        await mlr.SendMailAsyncWithoutFields(mm);
                    }
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
                return("false");
            }
            return("true");
        }
Пример #21
0
        public async Task <bool> SendMailInvoice(long OfflineBookingId)
        {
            string Filename = "";
            // send mail to customer -- after save
            string msg = await GetMailBody(OfflineBookingId);

            Common.Mailer ml = new Common.Mailer();
            System.Net.Mail.MailMessage mail     = new System.Net.Mail.MailMessage();
            CLayer.OfflineBooking       booking  = BLayer.OfflineBooking.GetAllDetailsById(OfflineBookingId);
            CLayer.OfflineBooking       customer = new CLayer.OfflineBooking();

            int bookingType = BLayer.OfflineBooking.GetBookingType(OfflineBookingId);

            if (bookingType == (int)CLayer.ObjectStatus.OfflineBookingType.TAC)
            {
                //Mail To Supplier
                if (OfflineBookingId > 0)
                {
                    CLayer.OfflineBooking OfflinePropertydata = BLayer.OfflineBooking.GetAllpropertyDetails(OfflineBookingId);
                    if (OfflinePropertydata != null)
                    {
                        if (OfflinePropertydata.SupplierEmail != null && OfflinePropertydata.SupplierEmail != "")
                        {
                            mail.To.Add(OfflinePropertydata.SupplierEmail);
                        }
                    }
                }
                string BccEmailsforSup = BLayer.Settings.GetValue(CLayer.Settings.CC_SUPPLIERCOMMUNICATION);
                if (BccEmailsforSup.Trim() != "")
                {
                    string[] emails = BccEmailsforSup.Split(',');
                    for (int i = 0; i < emails.Length; ++i)
                    {
                        mail.CC.Add(emails[i]);
                    }
                }
            }
            else
            {
                //Mail To Customer
                if (OfflineBookingId > 0)
                {
                    customer = BLayer.OfflineBooking.GetAllCustomerDetails(OfflineBookingId);
                }
                if (customer != null)
                {
                    if (customer.CustomerEmail != "")
                    {
                        mail.To.Add(customer.CustomerEmail);
                    }
                }
                #region for corporate
                //for corporate admins
                //long userid = BLayer.User.GetUserId(customer.CustomerEmail);
                //if (userid > 0)
                //{
                //    CLayer.Role.Roles rle = BLayer.User.GetRole(userid);
                //    if (rle == CLayer.Role.Roles.CorporateUser)
                //    {
                //        long cid = BLayer.B2B.GetCorporateIdOfUser(userid);
                //    }
                //}
                //message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("CorpIntimation") + bookingId.ToString() + "&key=" + BLayer.Settings.GetValue(CLayer.Settings.PUBLIC_PAGE_LOCK));
                //long cid = BLayer.B2B.GetCorporateIdOfUser(byUser.UserId);
                //if (cid > 0)
                //{
                //    string em = BLayer.User.GetEmail(cid);
                //    if (em != null && em != "")
                //    {
                //        msg.CC.Add(em);
                //    }
                //}
                //mail.To.Add(BLayer.Settings.GetValue(CLayer.Settings.SUPPORT_EMAIL));
                #endregion
                string BccEmailsforcus = BLayer.Settings.GetValue(CLayer.Settings.CC_CUSTOMERCOMMUNICATION);
                if (BccEmailsforcus.Trim() != "")
                {
                    string[] emails = BccEmailsforcus.Split(',');
                    for (int i = 0; i < emails.Length; ++i)
                    {
                        mail.CC.Add(emails[i]);
                    }
                }
            }



            CLayer.Invoice data = BLayer.Invoice.GetInvoiceByOfflineBooking(OfflineBookingId);

            if (data != null)
            {
                mail.Subject = "Invoice against Booking ID: " + booking.ConfirmationNumber + ", Invoice No. " + data.InvoiceNumber;
            }

            mail.Body       = msg;
            mail.IsBodyHtml = true;



            //add atachment
            try
            {
                Areas.Admin.Models.Invoice inv = new Areas.Admin.Models.Invoice();

                if (data != null)
                {
                    inv.InvoiceId        = data.InvoiceId;
                    inv.OfflineBookingId = data.OfflineBookingId;
                    inv.IsMailed         = (data.MailedDate <= DateTime.Today);
                    inv.HtmlSection1     = data.HtmlSection1;
                    inv.HtmlSection2     = data.HtmlSection2;
                    inv.HtmlSection3     = data.HtmlSection3;

                    ViewAsPdf v = new ViewAsPdf("~/Areas/Admin/Views/ManageOfflineBooking/Mail.cshtml", inv)
                    {
                        PageMargins     = new Rotativa.Options.Margins(1, 1, 1, 1),
                        PageOrientation = Rotativa.Options.Orientation.Portrait,
                        PageSize        = Rotativa.Options.Size.Letter
                    };
                    string newdirectory = "Files\\Temp\\" + inv.InvoiceId;
                    if (!Directory.Exists(Server.MapPath("~") + "\\" + newdirectory))
                    {
                        Directory.CreateDirectory(Server.MapPath("~") + "\\" + newdirectory);
                    }
                    Filename = Server.MapPath("~") + "\\" + newdirectory + "\\" + "Invoice_" + data.InvoiceNumber + ".pdf";
                    var byteArray  = v.BuildPdf(ControllerContext);
                    var fileStream = new FileStream(Filename, FileMode.Create, FileAccess.Write);
                    fileStream.Write(byteArray, 0, byteArray.Length);
                    fileStream.Close();
                    fileStream.Dispose();

                    // System.Net.Mail.Attachment attachment;
                    Attachment attacht = new Attachment(Filename, MediaTypeNames.Application.Octet);
                    mail.Attachments.Add(attacht);
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }


            string AccountMail = BLayer.Settings.GetValue(CLayer.Settings.ACCOUNT_EMAILS);
            if (AccountMail != "")
            {
                string[] Accemails = AccountMail.Split(',');
                for (int i = 0; i < Accemails.Length; ++i)
                {
                    mail.CC.Add(Accemails[i]);
                }
            }



            //send to ops mail
            string SalesPersonOPSMails = "";
            if (OfflineBookingId > 0)
            {
                CLayer.OfflineBooking OffdataStaff = BLayer.OfflineBooking.GetAllDetailsById(OfflineBookingId);
                if (OffdataStaff != null)
                {
                    if (OffdataStaff.SalesPersonId > 0)
                    {
                        CLayer.User usrstaff = BLayer.User.Get(OffdataStaff.SalesPersonId);
                        if (usrstaff != null)
                        {
                            if (usrstaff.OPSEmail != null && usrstaff.OPSEmail != "")
                            {
                                SalesPersonOPSMails = usrstaff.OPSEmail;
                            }
                        }
                    }
                }
            }
            if (SalesPersonOPSMails != "")
            {
                string CcOPSEmails = SalesPersonOPSMails.Trim();
                if (CcOPSEmails != "")
                {
                    string[] emails = CcOPSEmails.Split(',');
                    for (int i = 0; i < emails.Length; ++i)
                    {
                        mail.CC.Add(emails[i]);
                    }
                }
            }

            try
            {
                await ml.SendMailAsyncForBooking(mail, Common.Mailer.MailType.Reservation);
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }
            return(true);
        }
Пример #22
0
        public async Task <string> SupplierPaymentEmail()
        {
            WebClient wc = new WebClient();

            try
            {
                Models.OfflinePaymentModel   data = new Models.OfflinePaymentModel();
                List <CLayer.OfflineBooking> dt   = BLayer.OfflineBooking.GetAllOfflineDetails();
                long        OfflineBookingId      = 0;
                MailMessage mm = new MailMessage();

                string BccEmailsforcususer = BLayer.Settings.GetValue(CLayer.Settings.SUPPLIERPAYMENTSCHEDULEEMAIL);
                if (BccEmailsforcususer != "")
                {
                    mm.To.Clear();
                    string[] emails = BccEmailsforcususer.Split(',');
                    for (int i = 0; i < emails.Length; ++i)
                    {
                        mm.To.Add(emails[i]);
                    }
                }


                mm.From = new MailAddress(ConfigurationManager.AppSettings.Get("CustomerCareMail"));
                Common.Mailer mlr = new Common.Mailer();
                mm.IsBodyHtml = true;


                foreach (CLayer.OfflineBooking offbook in dt)
                {
                    CLayer.OfflineBooking offedit = BLayer.OfflineBooking.GetAllDetailsById(offbook.OfflineBookingId);

                    if (offedit.IsSupplierPaymentMailSend)
                    {
                        mm.Subject = "SUPPLIER PAYMENT SCHEDULE EMAIL [Revised]";
                    }
                    else
                    {
                        mm.Subject = "SUPPLIER PAYMENT SCHEDULE EMAIL";
                    }


                    if (offbook.SupplierPaymentScheduleList.Count > 0)
                    {
                        int exit = 0;
                        foreach (var schedule in offbook.SupplierPaymentScheduleList)
                        {
                            if (schedule.SupplierPaymentMode == (int)CLayer.OfflineBooking.SupplierPaymentModelist.OnInstalments)
                            {
                                foreach (var date in offbook.SupplierPaymentScheduleList)
                                {
                                    if (date.SupplierPaymentModeDate.ToShortDateString() == System.DateTime.Now.ToShortDateString() && exit == 0)
                                    {
                                        OfflineBookingId = offbook.OfflineBookingId;
                                        string link = System.Configuration.ConfigurationManager.AppSettings.Get("OfflinebookingSupplierPaymentSchedule") + OfflineBookingId.ToString();
                                        //for normal user mail body
                                        string result = await Common.Mailer.MessageFromHtml(link);


                                        mm.Body = result;
                                        await mlr.SendMailAsyncWithoutFields(mm);

                                        //Update supplier payment mail send data
                                        BLayer.OfflineBooking.UpdateSupplierPaymentmailsendData(OfflineBookingId);
                                        exit = 1;
                                        break;
                                    }
                                }
                            }
                            if (schedule.SupplierPaymentMode == (int)CLayer.OfflineBooking.SupplierPaymentModelist.Credit)
                            {
                                DateTime dtDate = offbook.CheckOut.AddDays(schedule.SupplierCreditDays);
                                if (dtDate.ToShortDateString() == System.DateTime.Now.ToShortDateString())
                                {
                                    OfflineBookingId = offbook.OfflineBookingId;
                                    string link = System.Configuration.ConfigurationManager.AppSettings.Get("OfflinebookingSupplierPaymentSchedule") + OfflineBookingId.ToString();
                                    //for normal user mail body
                                    string result = await Common.Mailer.MessageFromHtml(link);


                                    mm.Body = result;
                                    await mlr.SendMailAsyncWithoutFields(mm);

                                    //Update supplier payment mail send data
                                    BLayer.OfflineBooking.UpdateSupplierPaymentmailsendData(OfflineBookingId);
                                }
                            }
                            if (schedule.SupplierPaymentMode == (int)CLayer.OfflineBooking.SupplierPaymentModelist.FullAmountBeforeCheckin)
                            {
                                if (offbook.CheckIn.ToShortDateString() == System.DateTime.Now.ToShortDateString())
                                {
                                    OfflineBookingId = offbook.OfflineBookingId;
                                    string link = System.Configuration.ConfigurationManager.AppSettings.Get("OfflinebookingSupplierPaymentSchedule") + OfflineBookingId.ToString();
                                    //for normal user mail body
                                    string result = await Common.Mailer.MessageFromHtml(link);


                                    mm.Body = result;
                                    await mlr.SendMailAsyncWithoutFields(mm);

                                    //Update supplier payment mail send data
                                    BLayer.OfflineBooking.UpdateSupplierPaymentmailsendData(OfflineBookingId);
                                }
                            }
                            if (schedule.SupplierPaymentMode == (int)CLayer.OfflineBooking.SupplierPaymentModelist.FullAmountBeforeCheckout)
                            {
                                if (offbook.CheckOut.ToShortDateString() == System.DateTime.Now.ToShortDateString())
                                {
                                    OfflineBookingId = offbook.OfflineBookingId;
                                    string link = System.Configuration.ConfigurationManager.AppSettings.Get("OfflinebookingSupplierPaymentSchedule") + OfflineBookingId.ToString();
                                    //for normal user mail body
                                    string result = await Common.Mailer.MessageFromHtml(link);


                                    mm.Body = result;
                                    await mlr.SendMailAsyncWithoutFields(mm);

                                    //Update supplier payment mail send data
                                    BLayer.OfflineBooking.UpdateSupplierPaymentmailsendData(OfflineBookingId);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
                return("false");
            }
            return("true");
        }
        //Confirm Booking
        public async Task <bool> BookingConfirm(long bookingId)
        {
            try
            {
                BLayer.Bookings.SetStatus((int)CLayer.ObjectStatus.BookingStatus.Success, bookingId);

                //send customer email/message
                //email
                if (bookingId < 1)
                {
                    return(false);
                }
                CLayer.Address        byUser   = BLayer.Bookings.GetBookedByUser(bookingId);
                List <CLayer.Address> forUser  = BLayer.Bookings.GetBookedForUser(bookingId);
                CLayer.Booking        details  = BLayer.Bookings.GetDetailsSMS(bookingId);
                CLayer.User           supplier = BLayer.Bookings.GetSupplierDetails(bookingId);
                if (byUser == null)
                {
                    return(false);
                }
                if (forUser.Count == 0)
                {
                    return(false);
                }
                CLayer.Role.Roles rle = BLayer.User.GetRole(byUser.UserId);
                try
                {
                    string        message = "";
                    Common.Mailer ml      = new Common.Mailer();
                    //for normal user mail body
                    message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("BConfirmationMail") + bookingId.ToString() + "&key=" + BLayer.Settings.GetValue(CLayer.Settings.PUBLIC_PAGE_LOCK));

                    System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
                    //guest mail added
                    msg.To.Add(forUser[0].Email);
                    if (forUser[0].Email != byUser.Email)
                    {
                        msg.CC.Add(byUser.Email);
                    }
                    //for corporate admins
                    if (rle == CLayer.Role.Roles.CorporateUser)
                    {
                        //  message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("CorpIntimation") + bookingId.ToString() + "&key=" + BLayer.Settings.GetValue(CLayer.Settings.PUBLIC_PAGE_LOCK));
                        long cid = BLayer.B2B.GetCorporateIdOfUser(byUser.UserId);
                        if (cid > 0)
                        {
                            string em = BLayer.User.GetEmail(cid);
                            if (em != null && em != "")
                            {
                                msg.CC.Add(em);
                            }
                        }
                    }
                    msg.Subject = "Booking Confirmation";
                    msg.Body    = message;

                    msg.IsBodyHtml = true;

                    try
                    {
                        await ml.SendMailAsync(msg, Common.Mailer.MailType.Reservation);
                    }
                    catch (Exception ex)
                    {
                        Common.LogHandler.HandleError(ex);
                    }

                    //message
                    if (bookingId < 1)
                    {
                        return(false);
                    }
                    if (byUser == null)
                    {
                        return(false);
                    }
                    if (forUser.Count == 0)
                    {
                        return(false);
                    }
                    try
                    {
                        string phone = forUser[0].Mobile;
                        if (phone == "")
                        {
                            phone = forUser[0].Phone;
                        }
                        string smsmsg = Common.SMSGateway.GetNewBookingMessage(forUser[0].Firstname + " " + forUser[0].Lastname, details.OrderNo, details.CheckIn.ToString("MMM dd,yyyy"),
                                                                               details.CheckOut.ToString("MMM dd,yyyy"), details.PropertyTitle, details.propertyCity, details.AccommodationTypeTitle, BLayer.Settings.GetValue(CLayer.Settings.STAYB_CONTACTNO));
                        bool b = false;
                        phone = Common.Utils.GetMobileNo(phone);

                        if (phone != "")
                        {
                            b = await Common.SMSGateway.Send(smsmsg, phone);
                        }
                    }
                    catch (Exception ex)
                    {
                        Common.LogHandler.HandleError(ex);
                    }


                    //send supplier email/message

                    //message
                    if (bookingId < 1)
                    {
                        return(false);
                    }
                    if (byUser == null)
                    {
                        return(false);
                    }
                    if (forUser.Count == 0)
                    {
                        return(false);
                    }
                    try
                    {
                        string phone = forUser[0].Mobile;
                        if (phone == "")
                        {
                            phone = forUser[0].Phone;
                        }
                        string smsmsg = Common.SMSGateway.GetNewBookingMessage(forUser[0].Firstname + " " + forUser[0].Lastname, details.OrderNo, details.CheckIn.ToString("MMM dd,yyyy"),
                                                                               details.CheckOut.ToString("MMM dd,yyyy"), details.PropertyTitle, details.propertyCity, details.AccommodationTypeTitle, BLayer.Settings.GetValue(CLayer.Settings.STAYB_CONTACTNO));
                        bool b = false;
                        phone = Common.Utils.GetMobileNo(phone);

                        if (phone != "")
                        {
                            b = await Common.SMSGateway.Send(smsmsg, phone);
                        }
                    }
                    catch (Exception ex)
                    {
                        Common.LogHandler.HandleError(ex);
                    }

                    //email
                    if (bookingId < 1)
                    {
                        return(false);
                    }
                    try
                    {
                        if (supplier.Email != "" || details.PropertyEmail != "")
                        {
                            if (supplier.Email == "")
                            {
                                supplier.Email        = details.PropertyEmail;
                                details.PropertyEmail = "";
                            }
                            message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("SupplierIntimation") + bookingId.ToString() + "&key=" + BLayer.Settings.GetValue(CLayer.Settings.PUBLIC_PAGE_LOCK));

                            System.Net.Mail.MailMessage supplierMsg = new System.Net.Mail.MailMessage();
                            supplierMsg.To.Add(supplier.Email);
                            supplierMsg.Subject = "Booking Confirmation";
                            supplierMsg.Body    = message;

                            if (details.PropertyEmail != "")
                            {
                                supplierMsg.To.Add(details.PropertyEmail);
                            }
                            supplierMsg.IsBodyHtml = true;

                            try
                            {
                                await ml.SendMailAsync(supplierMsg, Common.Mailer.MailType.Reservation);
                            }
                            catch (Exception ex)
                            {
                                Common.LogHandler.HandleError(ex);
                            }
                        }
                    }


                    catch (Exception ex)
                    {
                        Common.LogHandler.HandleError(ex);
                    }
                }
                catch (Exception ex)
                {
                    Common.LogHandler.HandleError(ex);
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }
            return(true);
        }
Пример #24
0
        public async Task <bool> OfflineBookingConfirmGST(long OfflineBookId, long BookingDetailsId, string GuestEmail)
        {
            try
            {
                if (OfflineBookId < 1)
                {
                    return(false);
                }
                if (BookingDetailsId < 1)
                {
                    return(false);
                }
                CLayer.OfflineBooking Offlinedata = BLayer.OfflineBooking.GetAllDetailsById(OfflineBookId);

                CLayer.OfflineBooking OfflinePropertydata = BLayer.OfflineBooking.GetAllpropertyDetails(OfflineBookId);

                CLayer.OfflineBooking CustomerDetails = BLayer.OfflineBooking.GetAllCustomerDetails(OfflineBookId);

                if (CustomerDetails == null)
                {
                    return(false);
                }
                if (OfflinePropertydata == null)
                {
                    return(false);
                }

                CLayer.StayCategory      Staycategorydetails      = BLayer.StayCategory.Get(Convert.ToInt32(Offlinedata.StayCategoryid));
                CLayer.AccommodationType AccommodationTypedetails = BLayer.AccommodationType.Get(Convert.ToInt32(Offlinedata.Accommodationtypeid));

                CLayer.Role.Roles rle = BLayer.User.GetRole(Offlinedata.CustomerId);

                string        message = "";
                Common.Mailer ml      = new Common.Mailer();

                try
                {
                    #region Repeat portion

                    //List<CLayer.OfflineBooking> BListGST = BLayer.OfflineBooking.GetMultipleBookingDetailsGST(OfflineBookId);
                    //foreach (CLayer.OfflineBooking dt in BListGST)
                    //{

                    System.Net.Mail.MailMessage customerMsg = new System.Net.Mail.MailMessage();
                    //customerMsg.To.Add(CustomerDetails.CustomerEmail);
                    string BccEmailsforcususer = BLayer.Settings.GetValue(CLayer.Settings.CC_CUSTOMERCOMMUNICATION);
                    if (BccEmailsforcususer.Trim() != "")
                    {
                        string[] emails = Common.Utils.SplitEmails(BccEmailsforcususer);
                        //BccEmailsforcususer.Split(',');
                        for (int i = 0; i < emails.Length; ++i)
                        {
                            customerMsg.CC.Add(emails[i]);
                        }
                    }


                    customerMsg.Subject    = "CHECK-IN REMINDER";
                    customerMsg.IsBodyHtml = true;

                    if (GuestEmail != null)
                    {
                        if (GuestEmail != null && GuestEmail != "")
                        {
                            string[] emails = Common.Utils.SplitEmails(GuestEmail);
                            for (int i = 0; i < emails.Length; ++i)
                            {
                                customerMsg.To.Add(emails[i]);
                            }
                        }
                    }

                    string link = System.Configuration.ConfigurationManager.AppSettings.Get("OfflineBookingConfirmationBeforeCheckin") + OfflineBookId.ToString() + "&BookingDetailsId=" + BookingDetailsId + "&key=" + BLayer.Settings.GetValue(CLayer.Settings.PUBLIC_PAGE_LOCK);
                    message = await Common.Mailer.MessageFromHtml(link);

                    customerMsg.Body = message;



                    //Select Distinct Mail address in To mails

                    System.Net.Mail.MailAddress[] DistinctTo = customerMsg.To.Distinct().ToArray();
                    customerMsg.To.Clear();
                    for (int i = 0; i < DistinctTo.Length; ++i)
                    {
                        customerMsg.To.Add(DistinctTo[i]);
                    }

                    //Select Distinct Mail address in CC mails

                    System.Net.Mail.MailAddress[] DistinctCC = customerMsg.CC.Distinct().Except(DistinctTo).ToArray();
                    customerMsg.CC.Clear();
                    for (int i = 0; i < DistinctCC.Length; ++i)
                    {
                        customerMsg.CC.Add(DistinctCC[i]);
                    }



                    try
                    {
                        await ml.SendMailAsync(customerMsg, Common.Mailer.MailType.Reservation);
                    }
                    catch (Exception ex)
                    {
                        Common.LogHandler.HandleError(ex);
                    }

                    //}
                    #endregion
                }
                catch (Exception ex)
                {
                    Common.LogHandler.HandleError(ex);
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }

            return(true);
        }
Пример #25
0
        public async Task <ActionResult> SaveDetails(Models.Invoice data)
        {
            CLayer.Invoice sdata = null;
            if (data.OfflineBookingId > 0)
            {
                sdata = BLayer.Invoice.GetProformaByOfflineBooking(data.OfflineBookingId);
            }
            if (sdata == null)
            {
                sdata = new CLayer.Invoice();
            }

            sdata.OfflineBookingId = data.OfflineBookingId;
            sdata.InvoiceId        = data.InvoiceId;
            DateTime dt = DateTime.Today;

            DateTime.TryParse(data.InvoiceDate, out dt);
            sdata.InvoiceDate  = dt;
            sdata.HtmlSection1 = data.HtmlSection1;
            sdata.HtmlSection2 = data.HtmlSection2;
            sdata.HtmlSection3 = data.HtmlSection3;
            //Common.Utils.
            // sdata.InvoiceDate = DateTime.Today;
            sdata.DueDate = DateTime.Today.AddDays(10);
            string prNumber = BLayer.NumberGenerator.GetProformaNumber();

            sdata.InvoiceNumber = prNumber;
            sdata.InvoiceType   = (int)CLayer.ObjectStatus.InvoiceType.Proforma;
            if (data.OPType == 1)//save btn
            {
                BLayer.Invoice.Save(sdata);
                // BLayer.Invoice.Save(sdata);
            }
            else if (data.OPType == 2)//mail btn
            {
                data.OPType = 1;
                BLayer.Invoice.Save(sdata);


                if (sdata != null)
                {
                    if (sdata.InvoiceId > 0)
                    {
                        BLayer.Invoice.SetMailedDate(sdata.InvoiceId, DateTime.Today);
                    }
                }


                // send mail to customer -- after save
                string msg = await GetMailBody(sdata.OfflineBookingId);

                //send mail here using msg as body

                Common.Mailer ml = new Common.Mailer();
                System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();

                CLayer.OfflineBooking customer = new CLayer.OfflineBooking();
                if (data.OfflineBookingId > 0)
                {
                    customer = BLayer.OfflineBooking.GetAllCustomerDetails(data.OfflineBookingId);
                }

                if (customer != null)
                {
                    if (customer.CustomerEmail != "")
                    {
                        mail.To.Add(customer.CustomerEmail);
                    }
                }


                //mail.To.Add(BLayer.Settings.GetValue(CLayer.Settings.SUPPORT_EMAIL));

                string BccEmailsforcus = BLayer.Settings.GetValue(CLayer.Settings.CC_CUSTOMERCOMMUNICATION);
                if (BccEmailsforcus != "")
                {
                    string[] emails = BccEmailsforcus.Split(',');
                    for (int i = 0; i < emails.Length; ++i)
                    {
                        mail.Bcc.Add(emails[i]);
                    }
                }

                mail.Subject    = "Invoice";
                mail.Body       = msg;
                mail.IsBodyHtml = true;
                try
                {
                    await ml.SendMailAsyncForBooking(mail, Common.Mailer.MailType.Reservation);
                }
                catch (Exception ex)
                {
                    Common.LogHandler.HandleError(ex);
                }
            }
            else if (data.OPType == 3) //reset
            {
                sdata.HtmlSection1 = "";
                sdata.HtmlSection2 = "";
                BLayer.Invoice.Save(sdata);
            }



            return(await Edit(data.OfflineBookingId));
        }
Пример #26
0
        public async Task <ActionResult> Guest(Models.GuestModel data)
        {
            try
            {
                InitViewBag();
                if (ModelState.IsValid)
                {
                    long guestId = BLayer.User.CreateGuest(data.Email, data.Phone);
                    if (guestId > 0)
                    {
                        if (BLayer.User.GetStatus(guestId) == CLayer.ObjectStatus.StatusType.NotVerified)
                        {
                            string gd = Guid.NewGuid().ToString().Substring(0, 10);
                            UserManager <StayBazar.Lib.Security.IdentityUser> UserManager = new UserManager <StayBazar.Lib.Security.IdentityUser>(new UserStore());
                            string hashedNewPassword = UserManager.PasswordHasher.HashPassword(gd);
                            BLayer.User.SetPassword(guestId, hashedNewPassword);
                            try
                            {
                                System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
                                msg.To.Add(data.Email);
                                //Send guest mail
                                string url = System.Configuration.ConfigurationManager.AppSettings.Get("GuestMail");
                                url = url + guestId.ToString() + "&key=" + BLayer.Settings.GetValue(CLayer.Settings.PUBLIC_PAGE_LOCK) + "&pass="******"Staybazar Account";
                                msg.IsBodyHtml = true;
                                Common.Mailer ml = new Common.Mailer();
                                try
                                {
                                    await ml.SendMailAsync(msg, Common.Mailer.MailType.Query);
                                }
                                catch (Exception ex)
                                { //TODO add the exception to mailer list
                                    Common.LogHandler.LogError(ex);
                                }
                            }
                            catch (Exception ex) { Common.LogHandler.LogError(ex); }
                        }
                        Session[CLayer.ObjectStatus.GUEST_ID_SESSION] = guestId;
                        CLayer.Address ad = BLayer.Address.GetOnUserId(guestId, (int)CLayer.Address.AddressTypes.Primary);
                        if (ad == null)
                        {
                            return(RedirectToAction("SetAddress", "Continue"));
                        }
                        if (ad.CountryId < 1 && ad.State < 1)
                        {
                            return(RedirectToAction("SetAddress", "Continue"));
                        }
                        return(RedirectToAction("Book", "Booking"));
                    }
                    ViewBag.GuestError = true;
                    ViewBag.Message    = "Sorry we could not create a guest account. Try again later.";
                }
                else
                {
                    ViewBag.GuestError = true;
                    ViewBag.Message    = "Sorry we could not create a guest account. Try again.";
                }
            }catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
                ViewBag.GuestError = true;
                ViewBag.Message    = "Could not create guest login. Technical failure.";
            }
            return(View("Index"));
        }