YodleeAcctTypesV1.1 code example

Example: YodleeAcctTypesV1.1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
public Tuple<string, string> GetShacAccountTypeV2(string ContainerName,string YodleeAcctType)
{
    if (YodleeAcctType == null)
    {
        return Tuple.Create("UNKNOWN", "");  //if yodlee didn't return an accountTypeId
    }
    BsonDefaults.GuidRepresentation = GuidRepresentation.Standard;
    var id = "YodleeAcctTypesV1.1";
    var collection = _db.GetCollection<BsonDocument>(_config.SingletonsCollection);
    var filter = Builders<BsonDocument>.Filter.Eq("_id", id);
    var shacAccountTypes = collection.Find(filter).SingleOrDefault();
    if (shacAccountTypes == null)
    {
        throw new Exception("AccountTypes not found in Mongo");  // if document is not in db for some reason
    }
    var AcctTypes = shacAccountTypes["AcctTypes"].AsBsonArray;
    foreach (var acctType in AcctTypes)
    {
        if (acctType["Container"].ToString().ToLower() == ContainerName.ToLower() && acctType["AcctType"].ToString().ToLower() == YodleeAcctType.ToLower())
        {
            return Tuple.Create(acctType["ShacAcctType"].ToNullableString(), acctType["AccountRecordCode"].ToNullableString());
        }
    }
    return Tuple.Create("UNKNOWN", ""); //if we don't have the accountId stored in mongo
}