示例#1
0
        /// <summary>
        /// The SyncToOffline.
        /// </summary>
        /// <param name="onlineProd">The onlineProd<see cref="List{Product}"/>.</param>
        /// <returns>The <see cref="Task"/>.</returns>
        private async Task SyncToOffline(List <Product> onlineProd)
        {
            var offTables = Mapper.Map <List <ProductDAO> >(onlineProd);

            foreach (var data in offTables)
            {
                var offentity = await _productDBService.GetProduct(data.Id);

                if (offentity != null)
                {
                    await _productDBService.Updateproduct(data);
                }
                else
                {
                    await _productDBService.AddProducts(data);
                }
            }
        }
示例#2
0
        /// <summary>
        /// The GetProduct.
        /// </summary>
        /// <param name="id">The id<see cref="Guid"/>.</param>
        /// <returns>The <see cref="Task{Product}"/>.</returns>
        public async Task <Product> GetProduct(Guid id)
        {
            var URI = AddParameterToURI(AppConstants.ProductUrl, "Id", id);

            try
            {
                var     current = Connectivity.NetworkAccess;
                Product result  = null;
                if (current != NetworkAccess.Internet || AppConstants.UseLocal)
                {
                    result = await _productDBService.GetProduct(id);
                }
                else
                {
                    result = await _apiRepository.GetAsync <Product>("URI");
                }
                return(result);
            }
            catch (Exception)
            {
                // log exception
            }
            return(null);
        }