summaryrefslogtreecommitdiff
path: root/FireBase/Offline/SetHandler.cs
blob: 1efa7b6f0a603758426fe627c19b7bfd2912f316 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
namespace Firebase.Database.Offline
{
    using Firebase.Database.Query;

    using System.Threading.Tasks;

    public class SetHandler<T> : ISetHandler<T>
    {
        public virtual async Task SetAsync(ChildQuery query, string key, OfflineEntry entry)
        {
            using (var child = query.Child(key))
            {
                if (entry.SyncOptions == SyncOptions.Put)
                {
                    await child.PutAsync(entry.Data);
                }
                else
                {
                    await child.PatchAsync(entry.Data);
                }
            }
        }
    }
}