internal static string GetConnectionString(IConfigurationRoot config) { if (config == null) { return(""); } string connStr = null; switch (GetEnvironment(config)) { case SessionEnvironment.Development: connStr = DevSecrets.GetSecretValue("connectionStrings:anahitaProp:local:mysql"); //connStr = Configuration["ConnectionStrings:production:value"]; break; case SessionEnvironment.Staging: connStr = config["ConnectionStrings:staging:value"]; break; default: connStr = config["ConnectionStrings:production:value"]; break; } return(connStr); }
public DevMailService() : base() { _serverName = DevSecrets.GetSecretValue("swappAccount:serverName"); _userName = DevSecrets.GetSecretValue("swappAccount:email"); _fromEmail = DevSecrets.GetSecretValue("swappAccount:email"); _password = DevSecrets.GetSecretValue("swappAccount:emailPassword"); }
public DevMailService() : base() { _serverName = DevSecrets.GetSecretValue("swappAccount:serverName"); _userName = DevSecrets.GetSecretValue("swappAccount:email"); _fromEmail = DevSecrets.GetSecretValue("swappAccount:email"); _password = DevSecrets.GetSecretValue("swappAccount:emailPassword"); _useSSL = true; _port = DEFAULT_PORT; }
public void ConfigureServices(IServiceCollection services) { services.AddSingleton(Configuration); services.AddApplicationInsightsTelemetry(Configuration); services.AddMvc() .AddJsonOptions(options => { options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); options.SerializerSettings.Converters.Add(new SwpDateTimeConverter()); }); if (_env.IsDevelopment()) { services.AddTransient <IMailService, DevMailService>(); services.AddSingleton(ConnectionStringManager.Create( (type) => { switch (type == null ? "" : type.ToLower()) { case "mysql": return(DevSecrets.GetSecretValue("connectionStrings:findme:mysql")); default: return(DevSecrets.GetSecretValue("connectionStrings:findme:mssql")); } })); } else { services.AddTransient <IMailService, MailService>(); if (this.Configuration.IsPublishEnvStaging()) { services.AddSingleton(ConnectionStringManager.Create( (type) => { switch (type == null ? "" : type.ToLower()) { case "mysql": return(Configuration["ConnectionStrings:staging:MySqlConnection"]); default: return(Configuration["ConnectionStrings:staging:MsSqlConnection"]); } })); } else { services.AddSingleton(ConnectionStringManager.Create( (type) => { switch (type == null ? "" : type.ToLower()) { case "mysql": return(Configuration["ConnectionStrings:production:MySqlConnection"]); default: return(Configuration["ConnectionStrings:production:MsSqlConnection"]); } })); } } services.AddDbContext <AppDbContext>(); services.AddSingleton <WebDbRepository>(); services.AddTransient <AppMigrationSeedManager>(); }
public async Task <IActionResult> ManageProfile([FromBody] dynamic param = null) { object result = null; object error = null; string fullName = null; string action = null; bool?skipGet = false; dynamic profile = null; string tokenValue = null; try { profile = param.profile; action = param.action; skipGet = param.skipGet; switch (action == null ? "" : action.ToLower()) { case "cancelemailconfirmation": await _repo.Execute("CancelUserEmailConfirmation"); break; case "resendemailconfirmation": tokenValue = profile.emailToValToken.ToString(); string link = Url.Action("ValidateEmail", "Account", null, this.Request.Scheme); link += (link.EndsWith("/") ? "" : "/") + tokenValue; string fromEmail = _env.IsDevelopment() ? DevSecrets.GetSecretValue("swappAccount:email") : _config["MandrillEmailManagement:noReplyEmail"]; string toEmail = profile.emailToVal.ToString(); string message = this.GetMessage("msg_ValEmail") + link; await Task.WhenAll( _repo.Execute("SetEmailValidationTokenStatus", tokenValue, EmailSatus.Sending), _mailService.SendEmailAsync(this.GetLabel("lbl_FndMeBoValEmail"), message, toEmail: toEmail, fromEmail: fromEmail)); await _repo.Execute("SetEmailValidationTokenStatus", tokenValue, EmailSatus.Sent); break; default: action = null; if (profile != null) { fullName = await _repo.Execute <string>("UpdateTokenUserProfile", profile); } break; } if (skipGet != true) { result = await _repo.Execute("GetTokenUserProfile"); } if (profile != null && string.IsNullOrEmpty(action)) { string str = this.GetCookieValue($"{TOKENS_KEY}:{REFRESH_TOKEN_EXP_DATE_KEY}"); DateTime?expDate = string.IsNullOrEmpty(str) ? null : new DateTime?(str.FromISOFormat()); this.AddCookie($"{TOKENS_KEY}:{USER_FULL_NAME}", fullName, expDate); } } catch (ExceptionID ex) { switch (ex.ErrorID) { case MessageIdentifier.USERNAME_ALREADY_USED: return(BadRequest(this.GetMessage("msg_UsrnmAlrdUsed"))); case MessageIdentifier.USER_EMAIL_ALREADY_USED: return(BadRequest(this.GetMessage("msg_EmailAlrdUsed"))); } return(BadRequestEx(ex)); } catch (Exception ex) { return(BadRequestEx(ex)); } return(Ok(new { result = result, error = error, date = DateTime.Now, fn = fullName })); }