예제 #1
0
        //product id eka dunnahama product eke details ganna hadala tinne
        public static async Task <Products> GetProductById(int productId)
        {
            await TokenValidator.CheckTokenValidity();

            var httpClient = new HttpClient();

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", Preferences.Get("accessToken", string.Empty));
            var response = await httpClient.GetStringAsync(AppSetting.ApiURL + "api/Products/" + productId);

            return(JsonConvert.DeserializeObject <Products>(response));
        }
예제 #2
0
        public static async Task <List <Category> > GetCategories()
        {
            await TokenValidator.CheckTokenValidity();

            var httpClient = new HttpClient();

            //authorizede can only access
            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", Preferences.Get("accessToken", string.Empty));
            //get eka hinda
            var response = await httpClient.GetStringAsync(AppSetting.ApiURL + "api/Categories");

            //object ekata convert karanna one. list of category class
            return(JsonConvert.DeserializeObject <List <Category> >(response));
        }