public SMTPSetting GetSMTPSetting() { try { var settings = _siteSettingRepository.GetSettings(); var serverPort = settings.First(s => s.SettingName == "SMTPServerAndPort").SettingValue; var ssl = settings.First(s => s.SettingName == "SMTPEnableSSL").SettingValue; var authenticationType = settings.First(s => s.SettingName == "SMTPAuthentication").SettingValue; var userName = settings.First(s => s.SettingName == "SMTPUsername").SettingValue; var password = settings.First(s => s.SettingName == "SMTPPassword").SettingValue; var result = new SMTPSetting() { Server = !string.IsNullOrEmpty(serverPort.Split(':')[0]) ? serverPort.Split(':')[0] : "", Port = !string.IsNullOrEmpty(serverPort.Split(':')[1]) ? int.Parse(serverPort.Split(':')[1]) : 25, EnableSSL = !string.IsNullOrEmpty(ssl) ? bool.Parse(ssl) : false, AuthenticationType = authenticationType, Username = userName, Password = password }; return(result); } catch (Exception ex) { _logger.LogError("Error occured while calling Get", ex); } return(null); }
public IActionResult Get() { try { var result = _siteSettingRepository.GetSettings(); if (result != null) { return(Ok(result)); } return(NotFound()); } catch (Exception ex) { _logger.LogError(string.Format("Error occured while getting all site settings"), ex); return(new StatusCodeResult(StatusCodes.Status500InternalServerError)); } }