public object FromEntry(DynamoDBEntry entry) { var list = new List <Coffee>(); foreach (var coffeeMap in entry.AsListOfDocument()) { var description = coffeeMap.ContainsKey(DESCRIPTION) ? (string)coffeeMap[DESCRIPTION] : string.Empty; var image = coffeeMap.ContainsKey(IMAGE) ? (string)coffeeMap[IMAGE] : string.Empty; var title = coffeeMap.ContainsKey(TITLE) ? (string)coffeeMap[TITLE] : string.Empty; list.Add(new Coffee(coffeeMap[ID], description, image, title)); } return(list); }
private async Task AddAccountsToUser(DynamoDBEntry item, object id, IEnumerable <AccountInfo> accounts) { var table = Table.LoadTable(_dynamoDb, "Users"); var doc = new Document(); var list = item != null ? item.AsListOfDocument() : new List <Document>(); list.AddRange(accounts .Where(x => list.All(d => d["AccountId"].AsString() != x.AccountId)) .Select(x => Document.FromAttributeMap(UserModelFactory.MapAccountInfoToAWS(x)))); doc["Accounts"] = list; await table.UpdateItemAsync(doc, new Primitive(id.ToString(), true)); }