//TODO update urls public static string GetUrlLink(eArea currentStep, string baseAddress, string id) { var urlLink = ""; eArea toStage; switch (currentStep) { case eArea.Admins: toStage = eArea.Users; //TODO determine the correct value destination urlLink = string.Format("{0}{1}/Txn_Module?ParentId={2}&ReturnToParentListURL={0}{1}/Proposal", baseAddress, toStage, id); break; case eArea.Registration: toStage = eArea.UserManagers; urlLink = string.Format("{0}{1}/AspNetUserRole?ParentId={2}&ReturnToParentListURL={0}{1}/AspNetUser", baseAddress, toStage, id); break; case eArea.Users: case eArea.UserManagers: default: throw new Exception("Method: GetUrlLink. CurrentStep not supported: " + currentStep.ToString()); } return(urlLink); }
public static void SendEmail(eArea fromStage, MailMessage message) { eArea toStage; switch (fromStage) { case eArea.Admins: toStage = eArea.Users; RefillMessageTo(message, toStage); break; case eArea.Users: return; //not applicable case eArea.UserManagers: return; //not applicable case eArea.Registration: toStage = eArea.UserManagers; RefillMessageTo(message, toStage); break; default: throw new Exception("Parameter is not yet supported: " + fromStage); } SendEmail(message); }
private static void RefillMessageTo(MailMessage message, eArea ToStage) { var emails = GetEmails(ToStage.ToString()); foreach (var e in emails) { message.To.Add(new MailAddress(e)); } }
private void NotifyUserManagers(string userName) { const eArea currentStep = eArea.Registration; const string lineBreak = "<br>"; const string qoute = "\""; var applicationNameConfig = new ApplicationNameConfig(); var baseAddress = $"{Request.Url?.Scheme}://{Request.Url?.Authority}{Url.Content("~")}"; var urlLink = Mailer.GetUrlLink(currentStep, baseAddress, userName); var emailStyleConfig = new EmailStyleConfig(); var style = emailStyleConfig.Value; var messageBody = $"<p style={qoute}{style}{qoute}>" + $"Dear UserManagers,{lineBreak}{lineBreak}" + $"<b>{userName}</b> is now registered.{lineBreak}{lineBreak}" + $"Click <a href='{urlLink}'>here</a> to grant roles.{lineBreak}{lineBreak}" + "This is an automated message. Do not reply." + "</p>"; var message = new MailMessage { Subject = $"{applicationNameConfig.Value} {eArea.Registration} - {userName}", Body = messageBody }; Mailer.SendEmail(currentStep, message); }