Beispiel #1
0
        public async Task <Int64> CreateOrderIdAsync()
        {
            IDocumentSnapshot document = await fireStoreInstance.GetDocument("/OrderIds/unCmzg3mr1W9U9pAQQSk").GetDocumentAsync();

            OrderId orderId        = document.ToObject <OrderId>();
            Int64   currentOrderId = orderId.Id;

            orderId.Id = currentOrderId + 1;
            await fireStoreInstance.GetDocument("/OrderIds/unCmzg3mr1W9U9pAQQSk").UpdateDataAsync(orderId);

            return(await Task.FromResult(orderId.Id));
        }
Beispiel #2
0
        public async Task LoadAsync(string id)
        {
            try
            {
                _isLoaded.Value = false;

                var itemDocument = await _firestore.GetCollection(Models.Item.CollectionPath)
                                   .GetDocument(id)
                                   .GetDocumentAsync()
                                   .ConfigureAwait(false);

                var item = itemDocument.ToObject <Item>();

                if (item != null)
                {
                    _item.Value = item;

                    var likeTask = _firestore.GetDocument($"{User.CollectionPath}/{_accountService.UserId}/{Like.CollectionPath}/{id}")
                                   .GetDocumentAsync();

                    if (!string.IsNullOrEmpty(item.OwnerId))
                    {
                        var ownerDocument = await _firestore.GetCollection(User.CollectionPath)
                                            .GetDocument(item.OwnerId)
                                            .GetDocumentAsync()
                                            .ConfigureAwait(false);

                        _owner.Value = ownerDocument.ToObject <User>();
                    }

                    var likeDocument = await likeTask.ConfigureAwait(false);

                    _isLiked.Value = likeDocument.Exists;

                    _isLoaded.Value = true;

                    CrossFirebaseAnalytics.Current.LogEvent(EventName.ViewItem, new Parameter(ParameterName.ItemId, id));
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e);
                _loadErrorNotifier.OnNext(e.Message);
            }
        }