示例#1
0
        /// <summary>
        /// Get Email Template based on ID
        /// </summary>
        /// <param name="TemplateCode">Template ID</param>
        /// <returns>Obejct of EmailTemplate</returns>
        public TemplateMasterBO GetEmailTemplate(int TemplateCode)
        {
            TemplateMasterBO emailTemplate = new TemplateMasterBO();

            ObjectMapper.Map(EmailRepository.GetEmailTemplate(TemplateCode), emailTemplate);
            return(emailTemplate);
        }
示例#2
0
        public void SendEmailNotification(EmailServiceDTO emailModel, TemplateMasterBO emailTemplate)
        {
            string CCAddress = string.Empty;

            if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["CCAddress"]))
            {
                CCAddress = ConfigurationManager.AppSettings["CCAddress"];
            }
            SendEmail(emailModel, CCAddress);
        }
示例#3
0
        public void SendEmailNotification(EmailServiceDTO emailModel, TemplateMasterBO Template)
        {
            string CCAddress = string.Empty;

            if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["CCAddress"]))
            {
                CCAddress = ConfigurationManager.AppSettings["CCAddress"];
            }
            // string emailBody = PrepareEmailContent(emailModel, Template); //GetHtmlTextByName(templateName, templatelocation, "Content");
            // emailModel.Body = emailBody;
            emailModel.Body = FindReplace(emailModel.Body, "[CUSTOMERNAME]", emailModel.ToName);
            emailModel.Body = FindReplace(emailModel.Body, "[QUERYDATE]", DateTime.Now.ToShortDateString());
            SendEmail(emailModel, CCAddress, emailModel.Body);
        }
示例#4
0
        private List <TemplateImageBO> GetTemplateScreenShots(string path, TemplateMasterBO model)
        {
            List <TemplateImageBO> imagesList = new List <TemplateImageBO>();

            try
            {
                DirectoryInfo directory = new DirectoryInfo(Server.MapPath(path));
                var           files     = directory.GetFiles().ToList();

                if (files.Count > 0)
                {
                    foreach (var item in files.Where(x => x.Name != "Thumbs.db"))
                    {
                        TemplateImageBO image = new TemplateImageBO();

                        image.TemplateID      = model.TemplateID;
                        image.ImageName       = item.Name;
                        image.ImageUrl        = path.Replace("~", "..") + "/" + item.Name;
                        image.IsBannerImage   = false;
                        image.ImageTagLine    = model.TemplateName + "Wedding Theme ScreenShot - " + item.Name;
                        image.ImageFolderPath = path;
                        image.ImageTitle      = "ScreenShot - " + item.Name;
                        image.CreatedDate     = item.CreationTime;
                        image.CreatedBy       = 1;
                        imagesList.Add(image);
                    }

                    imagesList = SystemBusinessInstance.SubmitTemplateImages(imagesList);
                }
                else
                {
                    TemplateImageBO image = new TemplateImageBO();
                    image.ImageName = "Screenshot is Not Available";
                }
            }
            catch (Exception ex)
            {
            }

            return(imagesList);
        }
示例#5
0
        public ActionResult Contact(EmailServiceDTO email)
        {
            try
            {
                int templateCode          = (int)AspectEnums.EmailTemplateCode.ContactUsReply; // DreamWedds Contact Us Reply
                TemplateMasterBO template = new TemplateMasterBO();
                template = SystemBusinessInstance.GetTemplateData(0, templateCode);

                email.TemplateID   = template.TemplateID;
                email.Body         = template.TemplateContent;
                email.CreatedDate  = DateTime.Now;
                email.IsHtml       = true;
                email.Priority     = 2;
                email.IsAttachment = false;
                try
                {
                    EmailNotificationService eNotification = new EmailNotificationService();
                    eNotification.SendEmailNotification(email, template);
                    ViewBag.IsSuccess = true;
                    return(View());
                }
                catch (DbEntityValidationException ex)
                {
                    ViewBag.IsFail = true;
                    var newException = new FormattedDbEntityValidationException(ex);
                }
                catch (Exception ex)
                {
                    ViewBag.IsFail = true;
                }
                return(View(email));
            }
            catch
            {
                return(RedirectToAction("Index", "Error"));
            }
        }
示例#6
0
        private string PrepareEmailContent(EmailServiceDTO model, TemplateMasterBO Template)
        {
            var    MergeFields        = SystemBusinessInstance.GetTemplateMergeFields(Template.TemplateID);
            string emailContent       = model.Body;
            string path               = ConfigurationManager.AppSettings["WeddingTemplatePath"].ToString();
            string welcomeRegisterUrl = string.Empty;

            if (isDebugMode)
            {
                welcomeRegisterUrl = ConfigurationManager.AppSettings["DebugWelcomeLoginURL"].ToString();
            }
            else
            {
                welcomeRegisterUrl = ConfigurationManager.AppSettings["WelcomeLoginURL"].ToString();
            }
            foreach (var field in MergeFields)
            {
                if (field.SRC_FIELD == "{{IDENTIFIER}}")
                {
                    emailContent = FindReplace(emailContent, "{{IDENTIFIER}}", welcomeRegisterUrl + Template.UrlIdentifier);
                }

                else if (field.SRC_FIELD == "{{TONAME}}")
                {
                    emailContent = FindReplace(emailContent, field.SRC_FIELD, model.ToName);
                }

                else if (field.SRC_FIELD == "{{PURCHASE_DATE}}")
                {
                    emailContent = FindReplace(emailContent, field.SRC_FIELD, DateTime.Now.ToShortDateString());
                }

                else if (field.SRC_FIELD == "{{TEMPLATENAME}}")
                {
                    emailContent = FindReplace(emailContent, field.SRC_FIELD, Template.TemplateName);
                }

                else if (field.SRC_FIELD == "{{TEMPLATEPREVIEWIMAGE}}")
                {
                    emailContent = FindReplace(emailContent, field.SRC_FIELD, path + Template.TemplateName + "/images/ScreenShots/1.png");
                }

                else if (field.SRC_FIELD == "{{DEMO_URL}}")
                {
                    emailContent = FindReplace(emailContent, field.SRC_FIELD, path + Template.TemplateName + "/index.html");
                }

                else if (field.SRC_FIELD == "{{PRICE}}")
                {
                    if (Template.IsTrial)
                    {
                        emailContent = FindReplace(emailContent, field.SRC_FIELD, "TRIAL");
                    }
                    else
                    {
                        emailContent = FindReplace(emailContent, field.SRC_FIELD, "INR " + Template.COST.ToString());
                    }
                }

                else if (field.SRC_FIELD == "{{ABOUT_TEMPLATE}}")
                {
                    emailContent = FindReplace(emailContent, field.SRC_FIELD, Template.AboutTemplate);
                }
            }
            model.Body = emailContent;
            return(emailContent);
        }
示例#7
0
        private bool SendOTPAndEmail(int UserId)
        {
            bool IsSuccess = false;

            #region Prepare OTP Data

            string UniqueString = AppUtil.GetUniqueGuidString();
            string OTPString    = AppUtil.GetUniqueRandomNumber(100000, 999999); // Generate a Six Digit OTP
            OTPBO  objOTP       = new OTPBO()
            {
                GUID = UniqueString, OTP = OTPString, CreatedDate = DateTime.Now, UserID = UserId, Attempts = 0
            };

            #endregion
            try
            {
                if (SecurityBusinessInstance.SaveOTP(objOTP))
                {
                    #region Send Email Servie and OTP
                    //string hostName = AppUtil.GetAppSettings(AspectEnums.ConfigKeys.HostName);
                    string resetUrl         = AppUtil.GetAppSettings(AspectEnums.ConfigKeys.ForgotPasswordURL);
                    string PasswordResetURL = resetUrl + UniqueString;
                    //string PasswordResetURL = Request.Url.AbsoluteUri.Split('/')[0] + Request.Url.AbsoluteUri.Split('/')[1]  + resetUrl + "?id=" + UniqueString;
                    EmailNotificationService eNotification = new EmailNotificationService();
                    var userProfile = UserBusinessInstance.DisplayUserProfile(UserId); // empBusinessInstance.DisplayEmpProfile(EmpId);
                    TemplateMasterBO            objEmailTemplate = EmailBusinessInstance.GetEmailTemplate((int)AspectEnums.EmailTemplateCode.ResetPassword);
                    List <TemplateMergeFieldBO> mergeFields      = EmailBusinessInstance.GetEmailMergeFields(objEmailTemplate.TemplateID);
                    foreach (var field in mergeFields)
                    {
                        if (field.SRC_FIELD == "{{PASSWORDRESETURL}}")
                        {
                            objEmailTemplate.TemplateContent = eNotification.FindReplace(objEmailTemplate.TemplateContent, "{{PASSWORDRESETURL}}", PasswordResetURL);
                        }

                        else if (field.SRC_FIELD == "{{TONAME}}")
                        {
                            objEmailTemplate.TemplateContent = eNotification.FindReplace(objEmailTemplate.TemplateContent, field.SRC_FIELD, userProfile.FirstName + " " + userProfile.LastName);
                        }
                    }
                    objEmailTemplate.TemplateContent = eNotification.FindReplace(objEmailTemplate.TemplateContent, "{{COMPANY}}", AppUtil.GetAppSettings(AspectEnums.ConfigKeys.CompanyName));


                    EmailServiceDTO emailService = new EmailServiceDTO();
                    emailService.Priority     = 1;
                    emailService.CreatedBy    = userProfile.UserID;
                    emailService.IsHtml       = true;
                    emailService.ToName       = userProfile.FirstName + " " + userProfile.LastName;
                    emailService.Body         = objEmailTemplate.TemplateContent;
                    emailService.Status       = (int)AspectEnums.EmailStatus.Pending;
                    emailService.ToEmail      = userProfile.Email;
                    emailService.FromName     = AppUtil.GetAppSettings(AspectEnums.ConfigKeys.FromName);
                    emailService.FromEmail    = AppUtil.GetAppSettings(AspectEnums.ConfigKeys.FromEmail);
                    emailService.Subject      = eNotification.FindReplace(objEmailTemplate.TemplateSubject, "{{COMPANY}}", AppUtil.GetAppSettings(AspectEnums.ConfigKeys.CompanyName));
                    emailService.IsAttachment = false;
                    emailService.TemplateID   = objEmailTemplate.TemplateID;
                    emailBusinessInstance.InsertEmailRecord(emailService);

                    eNotification.SendEmailNotification(emailService, objEmailTemplate);
                    IsSuccess = true;

                    #endregion
                }
            }
            catch (Exception ex)
            {
                IsSuccess = false;
            }


            return(IsSuccess);
        }
示例#8
0
        public ActionResult Purchase(UserPurchaseViewModel model)
        {
            try
            {
                ViewBag.ShowMessage = true;
                ViewBag.IsTrial     = false;


                if (model.subscriptions.SubscriptionType == (int)AspectEnums.SubscriptionType.Trial)
                {
                    ViewBag.IsTrial        = true;
                    model.template.IsTrial = true;
                }

                #region Create NEW USER - SUBMIT USERMASTER

                bool isUserExist = UserBusinessInstance.GetUserByLoginName(model.user.Email).UserID > 0 ? true : false;

                if (isUserExist)
                {
                    ViewBag.Message   = "This email address already exist.";
                    ViewBag.IsSuccess = false;
                    return(View(model));
                }

                model.user.CreatedBy     = 1;
                model.user.CreatedDate   = DateTime.Now;
                model.user.AccountStatus = (int)AspectEnums.UserAccountStatus.Pending;
                model.user.isActive      = true;
                model.user.isDeleted     = false;
                model.user.IsEmployee    = false;
                model.user.LoginName     = model.user.Email;
                model.user.Password      = "******";
                string sessionID = HttpContext.Session.SessionID.ToString();
                int    newUserID = UserBusinessInstance.SubmitNewEmployee(model.user, sessionID);
                #endregion

                #region CREATE NEW ORDER - SUBMIT ORDERMASTER
                model.order.UserID = newUserID;
                decimal cost     = 0;
                int     Discount = Convert.ToInt32(ConfigurationManager.AppSettings["Discount"]);
                if (model.subscriptions.SubscriptionType == (int)AspectEnums.SubscriptionType.Trial)
                {
                    cost = 0;
                    model.subscriptions.EndDate = DateTime.Now.AddDays(10);
                }
                if (model.subscriptions.SubscriptionTypeList == AspectEnums.SubscriptionType.Annual)
                {
                    cost = Convert.ToDecimal(model.template.COST);
                    model.subscriptions.EndDate = DateTime.Now.AddMonths(12);
                }
                else if (model.subscriptions.SubscriptionTypeList == AspectEnums.SubscriptionType.HalfYearly)
                {
                    cost = Convert.ToDecimal(model.template.COST * .60);
                    model.subscriptions.EndDate = DateTime.Now.AddMonths(06);
                }
                else if (model.subscriptions.SubscriptionTypeList == AspectEnums.SubscriptionType.Quarterly)
                {
                    cost = Convert.ToDecimal(model.template.COST * 0.30);
                    model.subscriptions.EndDate = DateTime.Now.AddMonths(3);
                }

                model.order.Discount = Discount;
                model.order.Amount   = cost - (cost * (Discount / 100));
                model.template.COST  = Convert.ToInt32(model.order.Amount);
                int OrderID = SystemBusinessInstance.SubmitNewOrder(model.order);
                #endregion

                #region CREATE NEW SUBSCRIPTION - SUBMIT USERWEDDINGSUBSCRIPTION
                model.subscriptions.UserId    = newUserID;
                model.subscriptions.InvoiceNo = OrderID;


                int SubscriptionID = SystemBusinessInstance.SubmitUserSubscription(model.subscriptions);
                #endregion

                if (newUserID > 1)
                {
                    EmailServiceDTO  email         = new EmailServiceDTO();
                    TemplateMasterBO emailTemplate = new TemplateMasterBO();
                    int emailTemplateCode          = (int)AspectEnums.EmailTemplateCode.WelcomeEmail;

                    if (DreamWeddsData.DreamWeddsWeb == null)
                    {
                        emailTemplate = SystemBusinessInstance.GetTemplateData(0, emailTemplateCode);
                    }
                    else
                    {
                        emailTemplate = DreamWeddsData.DreamWeddsWeb.templateMasters.Where(x => x.TemplateCode == emailTemplateCode).FirstOrDefault();
                    }

                    model.template.UrlIdentifier = EncryptionEngine.Encrypt(newUserID.ToString() + "," + model.user.FirstName + "," + model.user.LastName + "," + model.user.LoginName + "," + model.template.TemplateName);
                    //string encodedValue = HttpUtility.UrlEncode(model.template.UrlIdentifier);
                    string decrypt = EncryptionEngine.Decrypt(model.template.UrlIdentifier);
                    email.ToName         = model.user.FirstName + " " + model.user.LastName;
                    email.Subject        = emailTemplate.TemplateSubject;
                    email.ToEmail        = model.user.Email;
                    email.Status         = (int)AspectEnums.EmailStatus.Pending;
                    email.Message        = emailTemplate.TemplateName;
                    email.Phone          = model.user.Phone;
                    email.Mobile         = model.user.Mobile;
                    email.IsCustomerCopy = false;
                    email.TemplateID     = emailTemplate.TemplateID;
                    email.Body           = emailTemplate.TemplateContent;
                    email.CreatedDate    = DateTime.Now;
                    email.CreatedBy      = newUserID;
                    email.IsHtml         = true;
                    email.Priority       = 2;
                    email.IsAttachment   = false;
                    email.Body           = PrepareEmailContent(email, emailTemplate);
                    EmailNotificationService eNotification = new EmailNotificationService();
                    eNotification.SendEmailNotification(email, model.template);
                    ViewBag.IsSuccess = true;
                }
            }
            catch (DbEntityValidationException ex)
            {
                ViewBag.IsSuccess = false;
                var newException = new FormattedDbEntityValidationException(ex);
                ViewBag.Message = "Error: " + ex;
            }
            catch (Exception e)
            {
                ViewBag.IsSuccess = false;
                ViewBag.Message   = "Error: " + e;
            }
            return(View(model));
        }