public MpDonorStatement GetDonorStatement(string token) { var records = _ministryPlatformService.GetRecordsDict(_myDonorPageId, token); if (records.Count > 1) { throw new ApplicationException("More than 1 donor for the current contact"); } if (records.Count == 0) { return(null); } var postalStatementId = _configurationWrapper.GetConfigValue("PostalMailStatement"); var statementMethod = new MpDonorStatement(); statementMethod.DonorId = records[0].ToInt("dp_RecordID"); statementMethod.Paperless = records[0].ToString("Statement_Method_ID") != postalStatementId; return(statementMethod); }
public void UpdateDonorStatement(string token, MpDonorStatement statement) { var onlineStatementId = _configurationWrapper.GetConfigValue("EmailOnlineStatement"); var postalStatementId = _configurationWrapper.GetConfigValue("PostalMailStatement"); var dictionary = new Dictionary <string, object> { { "Donor_ID", statement.DonorId }, { "Statement_Method_ID", statement.Paperless ? onlineStatementId : postalStatementId }, }; try { _ministryPlatformService.UpdateRecord(_myDonorPageId, dictionary, token); } catch (Exception e) { var msg = string.Format("Error updating statement method attribute, donor: {0} paperless: {1}", statement.DonorId, statement.Paperless); _logger.Error(msg, e); throw (new ApplicationException(msg, e)); } }