//private async Task InitLocalStoreAsync()
        //{
        //    // new code to initialize the SQLite store
        //    string path = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "eshopelocaldb.db");

        //    if (!File.Exists(path))
        //    {
        //        File.Create(path).Dispose();
        //    }

        //    var store = new MobileServiceSQLiteStore(path);
        //    store.DefineTable<Product>();

        //    // Uses the default conflict handler, which fails on conflict
        //    await _client.SyncContext.InitializeAsync(store);
        //}
        async Task <List <JObject> > GetProductsAsyncAPI()
        {
            var uriBuilder = new UriBuilder($"{_api.DefaultEndPoint}")
            {
                Path = "tables/product",
            };

            return(await _api.GetAsync <List <JObject> >(uriBuilder.Uri.AbsoluteUri));
        }
Ejemplo n.º 2
0
        public async Task <List <Order> > GetUserOrdersAsync(Guid userId)
        {
            var uriBuilder = new UriBuilder($"{_api.DefaultEndPoint}")
            {
                Path  = "tables/order",
                Query = $"userId={userId}"
            };

            return(await _api.GetAsync <List <Order> >(uriBuilder.Uri.AbsoluteUri));
        }
Ejemplo n.º 3
0
        public async Task <AuthenticationResponse> Authenticate(string userName, string password)
        {
            var uriBuilder = new UriBuilder($"{_api.DefaultEndPoint}")
            {
                Path  = $"api/users",
                Query = $"username={userName}"
            };

            //var uri = new Uri($"{_api.DefaultEndPoint}/api/users/{userName}");

            var user = await _api.GetAsync <User>(uriBuilder.Uri.AbsoluteUri);

            return(new AuthenticationResponse
            {
                User = user,
                IsAuthenticated = user != null
            });
        }