public void TestMethod2() { /*IF conditionnel*/ string template = @"Bonjour §model.UserName§,<br /> <br /> §if(model.IsMail)§ mail §else§ sms §endif§! < br /> Titre: §model.Title§<br /> §if(model.IsNotAuthenticated)§ Email: §model.Sender.Email§<br /> Téléphone: §model.Sender.Phone§<br /> §endif§ Message: <br /> §model.Message§<br /> <br /> §if(model.MessageUrl)§ Message disponible sur le site<a href='§model.MessageUrl§'>§model.SiteName§</a><br /><br /> §endif§ Cordialement,<br /> Service Client §model.SiteName§,<br /> <a href = '§model.SiteUrl§' >§model.SiteUrl§</a>"; string result = new StringTemplateRenderer().Render(template, new { Name = "Guillaume", IsMail = true, IsReply = false }); Console.WriteLine(result); // “Bonjour Guillaume, ceci est un sms!” }
public void TestMethod1() { /*IF conditionnel*/ string template = "Bonjour §model.Name§, ceci est un §if(model.IsMail)§" + "mail" + " §else§" + "sms" + " §endif§!"; string result = new StringTemplateRenderer().Render(template, new { Name = "Guillaume", IsMail = true }); Console.WriteLine(result); // “Bonjour Guillaume, ceci est un sms!” }
protected override async Task ActionAsync() { if (Input.UserId != Input.Data.UserId) { await UserSecurity.CheckIsSuperAdministratorAsync(_userService, Input.UserId); } var userId = Input.Data.UserId; var applicationUser = await _userService.FindApplicationUserByIdAsync(Input.Data.UserId); // TODO validation des données if (!string.IsNullOrEmpty(Input.Data.Email)) { var applicationUserEmail = await _userService.FindApplicationUserByEmailAsync(Input.Data.Email); if (applicationUserEmail != null) { Result.ValidationResult.AddError("EMAIL_ALREADY_EXIST"); return; } if (Input.Data.Email.ToLower() != applicationUser.Email.ToLower()) { applicationUser.Email = Input.Data.Email.ToLower().Trim(); applicationUser.EmailConfirmed = false; var code = await _userManager.GenerateEmailConfirmationTokenAsync(applicationUser); var callbackUrl = "https://www.bworld.fr/Account/ConfirmEmail?userId={0}&code={1}"; var createUserMailModel = new UserChangeMailModel(); createUserMailModel.CallbackUrl = string.Format(callbackUrl, WebUtility.UrlEncode(userId), WebUtility.UrlEncode(code)); createUserMailModel.UserName = applicationUser.FullName; var templateMail = new StringTemplateRenderer().Render(ResourcesLoader.Load(Path.Combine("UserCore", "Renderers", "UserChangeMail.st")), createUserMailModel); await SendEmailAsync(_emailService, applicationUser, "[bworld] Confirmation de votre email", templateMail); } } else { applicationUser.FirstName = Input.Data.FirstName; applicationUser.LastName = Input.Data.LastName; applicationUser.AuthorUrl = Input.Data.AuthorUrl; } await _userService.SaveAsync(applicationUser); }
public static async Task SendResetPasswordEmailAsync(IEmailService emailService, ApplicationUser user, string token) { const string callbackUrl = "https://www.bworld.fr/utilisateur/reinit-password?userId={0}&token={1}&dm=false"; var createUserMailModel = new ResetPasswordMailModel(); createUserMailModel.CallbackUrl = string.Format(callbackUrl, WebUtility.UrlEncode(user.Id), WebUtility.UrlEncode(token)); createUserMailModel.UserName = user.FullName; var templateMail = new StringTemplateRenderer().Render(ResourcesLoader.Load(Path.Combine("UserCore", "Renderers", "ResetPassword.st")), createUserMailModel); await SendEmailAsync(emailService, user, "[bworld] Re-initialisation mot de votre mot passe", templateMail); }
public static async Task SendConfirmEmailAsync(IEmailService emailService, UserManager <ApplicationUser> userManager, SendConfirmEmailModel model, ApplicationUser user) { var code = await userManager.GenerateEmailConfirmationTokenAsync(user); const string callbackUrl = "https://www.bworld.fr/Account/ConfirmEmail?userId={0}&code={1}"; var createUserMailModel = new CreateUserMailModel(); createUserMailModel.CallbackUrl = string.Format(callbackUrl, WebUtility.UrlEncode(user.Id), WebUtility.UrlEncode(code)); createUserMailModel.UserName = user.FullName; createUserMailModel.Provider = model.Provider; var templateMail = new StringTemplateRenderer().Render(ResourcesLoader.Load(Path.Combine("UserCore", "Renderers", "CreateUser.st")), createUserMailModel); await SendEmailAsync(emailService, user, "[bworld] Confirmation de votre email", templateMail); }
public override async Task GetInfoAsync(GeMenuItemInput geMenuItemInput) { var itemDataModel = geMenuItemInput.ItemDataModel; var moduleFree = (MasterBusinessModel)geMenuItemInput.ItemDataModel.Data; var masterInfo = new Master(); masterInfo.Id = itemDataModel.Id; masterInfo.ImageIcones = GetImages(moduleFree, "ImageIcone"); if (masterInfo.ImageIcones != null && masterInfo.ImageIcones.Count > 0) { var imageIcone = masterInfo.ImageIcones.First(); masterInfo.ImageIconeId = imageIcone.Id; masterInfo.ImageIconeFileName = imageIcone.Name; } masterInfo.ImageLogos = GetImages(moduleFree, "ImageLogo"); if (masterInfo.ImageLogos != null && masterInfo.ImageLogos.Count > 0) { var imageLogo = masterInfo.ImageLogos.First(); masterInfo.ImageLogoId = imageLogo.Id; masterInfo.ImageLogoFileName = imageLogo.Name; } var jumbotron = moduleFree.Elements.FirstOrDefault(e => e.Property == "Jumbotron"); if (jumbotron != null) { masterInfo.IsJumbotron = jumbotron.Data == "true"; } masterInfo.Title = moduleFree.Elements.First(e => e.Property == "Title").Data; var colorBackgroundMenu = GetData(moduleFree, "ColorBackgroundMenu"); masterInfo.ColorBackgroundMenu = colorBackgroundMenu; masterInfo.ColorHoverBackgroundMenu = ColorHelper.Grayer(colorBackgroundMenu, 50); masterInfo.ColorSelectedBackgroundMenu = ColorHelper.Grayer(colorBackgroundMenu, 32); masterInfo.ColorH1 = GetData(moduleFree, "ColorH1"); masterInfo.ColorH2 = GetData(moduleFree, "ColorH2"); masterInfo.ColorH3 = GetData(moduleFree, "ColorH3"); masterInfo.ColorJumbotron = GetData(moduleFree, "ColorJumbotron"); masterInfo.ColorBackgroundMenuBottom = GetData(moduleFree, "ColorBackgroundMenuBottom"); var color = GetData(moduleFree, "Color"); masterInfo.Color = color; var colorBackground = GetData(moduleFree, "ColorBackground"); masterInfo.ColorBackground = colorBackground; var colorH1 = GetData(moduleFree, "ColorH1"); var styleModel = new StyleModel { Color = color, ColorBackground = colorBackground, ColorBackgroundMenu = colorBackgroundMenu, ColorHoverBackgroundMenu = ColorHelper.Grayer(colorBackgroundMenu, 50), ColorBackgroundTableHeader = ColorHelper.Grayer(colorBackgroundMenu, -20), ColorBackgroundTableFooter = ColorHelper.Grayer(colorBackgroundMenu, -40), ColorSelectedBackgroundMenu = ColorHelper.Grayer(colorBackgroundMenu, 32), ColorH1 = colorH1, ColorH2 = GetData(moduleFree, "ColorH2"), ColorJumbotron = GetData(moduleFree, "ColorJumbotron"), ColorBackgroundMenuBottom = GetData(moduleFree, "ColorBackgroundMenuBottom"), ColorLoader = ColorHelper.Grayer(colorBackgroundMenu, -20), ColorSeparator = ColorHelper.Grayer(colorBackgroundMenu, -70, 0, 220) }; var template = ResourcesLoader.Load(Path.Combine("Renderers", "Style.st")); var styleTemplate = new StringTemplateRenderer().Render(template, styleModel); masterInfo.StyleTemplate = styleTemplate; //var theme = moduleFree.Elements.FirstOrDefault(e => e.Property == "Theme"); //TODO masterInfo.Theme = "theme1"; /* if (theme != null) * { * masterInfo.Theme = theme.Data; * } * else * { * masterInfo.Theme = "default"; * }*/ masterInfo.Seo = new SeoBusinessMaster(); masterInfo.FacebookAuthenticationAppId = _routeProvider.Domains.Where(d => d.Id == geMenuItemInput.CurrentRequest.DomainId) .Select(d => d.FacebookAppId) .FirstOrDefault(); ModuleManager.Add(geMenuItemInput.Master, itemDataModel.PropertyName, masterInfo, itemDataModel.PropertyType); }