Ejemplo n.º 1
0
        private IList <Token> GenerateTokens(HomeInstallationQuoteModel Model)
        {
            IList <Token> tokens = new List <Token>();

            string additionalMessage = string.IsNullOrWhiteSpace(Model.AdditionalInfo) ?
                                       "N/A" : Model.AdditionalInfo;
            string phone = string.IsNullOrWhiteSpace(Model.Phone) ?
                           "N/A" : Model.Phone;

            string projectStage = GetProjectStageToken(Model);

            projectStage = string.IsNullOrWhiteSpace(projectStage) ? "N/A" : projectStage;

            _messageTokenProvider.AddStoreTokens(tokens);
            tokens.Add(new Token("InstallationQuote.ProductName", Model.ProductName));
            tokens.Add(new Token("InstallationQuote.Name", Model.Name));
            tokens.Add(new Token("InstallationQuote.Email", Model.Email));
            tokens.Add(new Token("InstallationQuote.Phone", phone));
            tokens.Add(new Token("InstallationQuote.PostCode", Model.PostCode));
            tokens.Add(new Token("InstallationQuote.Rooms", Model.Rooms.ToString()));
            tokens.Add(new Token("InstallationQuote.Flooring", Model.Flooring.ToString()));
            tokens.Add(new Token("InstallationQuote.ProjectStage", projectStage));
            tokens.Add(new Token("InstallationQuote.AdditionalInfo", additionalMessage));

            if (Model.FreeCredit)
            {
                tokens.Add(new Token("InstallationQuote.FreeCredit", "Yes"));
            }
            else
            {
                tokens.Add(new Token("InstallationQuote.FreeCredit", "No"));
            }

            return(tokens);
        }
Ejemplo n.º 2
0
        public ActionResult HomeInstallationQuote(int productId)
        {
            Product product = _productService.GetProductById(productId);
            HomeInstallationQuoteModel model = new HomeInstallationQuoteModel();

            if (product != null)
            {
                model.ProductName = product.Name;
            }

            return(View(HOME_INSTALLATION_QUOTE_VIEW, model));
        }
Ejemplo n.º 3
0
        private bool SendFreeSampleMessage(HomeInstallationQuoteModel Model)
        {
            MessageTemplate messageTemplate =
                GetLocalizedActiveMessageTemplate("HomeInstallationQuote.Form");

            if (messageTemplate == null)
            {
                return(false);
            }

            EmailAccount sendTo = GetEmailAccountOfMessageTemplate(messageTemplate,
                                                                   _workContext.WorkingLanguage.Id);
            IList <Token> tokens = GenerateTokens(Model);

            _eventPublisher.MessageTokensAdded(messageTemplate, tokens);
            return(0 != SendMessage(messageTemplate, Model.Name, Model.Email, sendTo,
                                    _workContext.WorkingLanguage.Id, tokens));
        }
Ejemplo n.º 4
0
        public ActionResult HomeInstallationQuote(HomeInstallationQuoteModel Model)
        {
            if (ModelState.IsValid)
            {
                bool successfullySent = SendFreeSampleMessage(Model);

                if (successfullySent)
                {
                    return(RedirectToAction("HomeInstallationQuoteSuccessful"));
                }
                else
                {
                    ModelState.AddModelError("", _localizationService
                                             .GetResource("Plugin.Misc.FreeSample.ErrorOccured"));
                }
            }

            return(View(HOME_INSTALLATION_QUOTE_VIEW, Model));
        }
Ejemplo n.º 5
0
 private string GetProjectStageToken(HomeInstallationQuoteModel Model)
 {
     if (Model.ProjectStageId == 1)
     {
         return("Just looking for price");
     }
     if (Model.ProjectStageId == 2)
     {
         return("Within next 4 weeks");
     }
     if (Model.ProjectStageId == 3)
     {
         return("Within next 3 months");
     }
     if (Model.ProjectStageId == 4)
     {
         return("Within next 6 months");
     }
     else
     {
         return(null);
     }
 }