Example #1
0
        public async Task <bool> AddItemAsync(SeasonalItem item)
        {
            using (var doc = _db.GetDocument(CoreApp.DocId))
                using (var mdoc = doc.ToMutable())
                    using (MutableArrayObject listItems = mdoc.GetArray(CoreApp.ArrKey)) {
                        var dictObj = new MutableDictionaryObject();
                        dictObj.SetString("key", item.Name);
                        dictObj.SetInt("value", item.Quantity);
                        var blob = new Blob("image/png", item.ImageByteArray);
                        dictObj.SetBlob("image", blob);

                        listItems.AddDictionary(dictObj);
                        _db.Save(mdoc);

                        _items.Add(_items.Count + 1, item);
                    }

            return(await Task.FromResult(true));
        }