예제 #1
0
        public static async Task <List <Movie> > GetAllMovies(int pageNumber, int pageSize)
        {
            await TokenValidator.CheckTokenValidity();

            var httpClient = new HttpClient();

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", Preferences.Get("accessToken", string.Empty));
            var response = await httpClient.GetStringAsync(AppSettings.ApiUrl + String.Format("api/movies/AllMovies?pageNumber={0}&pageSize={1}", pageNumber, pageSize));

            return(JsonConvert.DeserializeObject <List <Movie> >(response));
        }
예제 #2
0
        public static async Task <MovieDetail> GetMovieDetail(int movieId)
        {
            await TokenValidator.CheckTokenValidity();

            var httpClient = new HttpClient();

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", Preferences.Get("accessToken", string.Empty));
            var response = await httpClient.GetStringAsync(AppSettings.ApiUrl + "api/movies/MovieDetail/" + movieId);

            return(JsonConvert.DeserializeObject <MovieDetail>(response));
        }
예제 #3
0
        public static async Task <VehicleDetail> GetVehicleDetail(int id)
        {
            await TokenValidator.CheckTokenValidity();

            var httpClient = new HttpClient();

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", Preferences.Get("accessToken", string.Empty));
            var response = await httpClient.GetStringAsync($"http://cvehicle.azurewebsites.net/api/Vehicles/VehicleDetails?id={id}");

            return(JsonConvert.DeserializeObject <VehicleDetail>(response));
        }
예제 #4
0
        public static async Task <List <ProductByCategory> > GetProductByCategory(int categoryId)
        {
            await TokenValidator.CheckTokenValidity();

            var httpClient = new HttpClient();

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", Preferences.Get("accessToken", string.Empty));
            var response = await httpClient.GetStringAsync(AppSettings.ApiUrl + "api/Products/ProductsByCategory/" + categoryId);

            return(JsonConvert.DeserializeObject <List <ProductByCategory> >(response));
        }
예제 #5
0
        public static async Task <UserImageModel> GetUserProfileImage()
        {
            await TokenValidator.CheckTokenValidity();

            var httpClient = new HttpClient();

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", Preferences.Get("accessToken", string.Empty));
            var response = await httpClient.GetStringAsync("http://cvehicle.azurewebsites.net/api/accounts/UserProfileImage");

            return(JsonConvert.DeserializeObject <UserImageModel>(response));
        }
예제 #6
0
        public static async Task <List <MarqueeBanner> > GetMarqueeBanners()
        {
            await TokenValidator.CheckTokenValidity();

            var httpClient = new HttpClient();

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", Preferences.Get("accessToken", string.Empty));
            var response = await httpClient.GetStringAsync(AppSettings.ApiUrl + "api/MarqueeBanners");

            return(JsonConvert.DeserializeObject <List <MarqueeBanner> >(response));
        }
예제 #7
0
        public static async Task <TotalCartItem> GetTotalCartItems(int userId)
        {
            await TokenValidator.CheckTokenValidity();

            var httpClient = new HttpClient();

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", Preferences.Get("accessToken", string.Empty));
            var response = await httpClient.GetStringAsync(AppSettings.ApiUrl + "api/ShoppingCartItems/TotalItems/" + userId);

            return(JsonConvert.DeserializeObject <TotalCartItem>(response));
        }
예제 #8
0
        public static async Task <List <MasterData> > GetDetectDatas(Guid detectId)
        {
            await TokenValidator.CheckTokenValidity();

            var httpClient = new HttpClient();

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", Preferences.Get("accessToken", string.Empty));
            var response = await httpClient.GetStringAsync("https://weleaderapi.azurewebsites.net/api/MedicalDetect/p/r2/FFA95EB0-2B8A-47B1-AC10-BBEC1710D10D");

            return(JsonConvert.DeserializeObject <List <MasterData> >(response));
        }
예제 #9
0
        public static async Task <List <MyAd> > GetMyAds()
        {
            await TokenValidator.CheckTokenValidity();

            var httpClient = new HttpClient();

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", Preferences.Get("accessToken", string.Empty));
            var response = await httpClient.GetStringAsync("https://cvehicles.azurewebsites.net/api/Vehicles/MyAds");

            return(JsonConvert.DeserializeObject <List <MyAd> >(response));
        }
예제 #10
0
        public static async Task <OrderResponse> PlaceOrder(Order order)
        {
            await TokenValidator.CheckTokenValidity();

            var httpClient = new HttpClient();
            var json       = JsonConvert.SerializeObject(order);
            var content    = new StringContent(json, Encoding.UTF8, "application/json");

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", Preferences.Get("accessToken", string.Empty));
            var response = await httpClient.PostAsync(AppSettings.ApiUrl + "api/Orders", content);

            var jsonResult = await response.Content.ReadAsStringAsync();

            return(JsonConvert.DeserializeObject <OrderResponse>(jsonResult));
        }
예제 #11
0
        public static async Task <bool> ClearShoppingCart(int userId)
        {
            await TokenValidator.CheckTokenValidity();

            var httpClient = new HttpClient();

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", Preferences.Get("accessToken", string.Empty));
            var response = await httpClient.DeleteAsync(AppSettings.ApiUrl + "api/ShoppingCartItems/" + userId);

            if (!response.IsSuccessStatusCode)
            {
                return(false);
            }
            return(true);
        }
예제 #12
0
        public static async Task <VehicleResponse> AddVehicle(Vehicle vehicle)
        {
            await TokenValidator.CheckTokenValidity();

            var httpClient = new HttpClient();
            var json       = JsonConvert.SerializeObject(vehicle);
            var content    = new StringContent(json, Encoding.UTF8, "application/json");

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", Preferences.Get("accessToken", string.Empty));
            var response = await httpClient.PostAsync("https://cvehicles.azurewebsites.net/api/Vehicles", content);

            var jsonResult = await response.Content.ReadAsStringAsync();

            return(JsonConvert.DeserializeObject <VehicleResponse>(jsonResult));
        }
예제 #13
0
        public static async Task <bool> EditPhoneNumber(string phoneNumber)
        {
            await TokenValidator.CheckTokenValidity();

            var httpClient = new HttpClient();
            var content    = new StringContent($"Number={phoneNumber}", Encoding.UTF8, "application/x-www-form-urlencoded");

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", Preferences.Get("accessToken", string.Empty));
            var response = await httpClient.PostAsync("https://cvehicles.azurewebsites.net/api/accounts/EditPhoneNumber", content);

            if (!response.IsSuccessStatusCode)
            {
                return(false);
            }
            return(true);
        }
예제 #14
0
        public static async Task <bool> AddItemsInCart(AddToCart addToCart)
        {
            await TokenValidator.CheckTokenValidity();

            var httpClient = new HttpClient();
            var json       = JsonConvert.SerializeObject(addToCart);
            var content    = new StringContent(json, Encoding.UTF8, "application/json");

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", Preferences.Get("accessToken", string.Empty));
            var response = await httpClient.PostAsync(AppSettings.ApiUrl + "api/ShoppingCartItems", content);

            if (!response.IsSuccessStatusCode)
            {
                return(false);
            }
            return(true);
        }
예제 #15
0
        public static async Task <bool> EditUserProfile(byte[] imageArray)
        {
            await TokenValidator.CheckTokenValidity();

            var httpClient = new HttpClient();
            var json       = JsonConvert.SerializeObject(imageArray);
            var content    = new StringContent(json, Encoding.UTF8, "application/json");

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", Preferences.Get("accessToken", string.Empty));
            var response = await httpClient.PostAsync("https://cvehicles.azurewebsites.net/api/accounts/EditUserProfile", content);

            if (!response.IsSuccessStatusCode)
            {
                return(false);
            }
            return(true);
        }
예제 #16
0
        public static async Task <bool> ChangePassword(string oldPassword, string newPassword, string confirmPassword)
        {
            var changePasswordModel = new ChangePasswordModel()
            {
                OldPassword     = oldPassword,
                NewPassword     = newPassword,
                ConfirmPassword = confirmPassword
            };
            await TokenValidator.CheckTokenValidity();

            var httpClient = new HttpClient();
            var json       = JsonConvert.SerializeObject(changePasswordModel);
            var content    = new StringContent(json, Encoding.UTF8, "application/json");

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", Preferences.Get("accessToken", string.Empty));
            var response = await httpClient.PostAsync("https://cvehicles.azurewebsites.net/api/accounts/ChangePassword", content);

            if (!response.IsSuccessStatusCode)
            {
                return(false);
            }
            return(true);
        }
예제 #17
0
        public static async Task <bool> AddImage(int vehicleId, byte[] imageArray)
        {
            var vehicleImage = new VehicleImage()
            {
                VehicleId  = vehicleId,
                ImageArray = imageArray
            };

            await TokenValidator.CheckTokenValidity();

            var httpClient = new HttpClient();
            var json       = JsonConvert.SerializeObject(vehicleImage);
            var content    = new StringContent(json, Encoding.UTF8, "application/json");

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", Preferences.Get("accessToken", string.Empty));
            var response = await httpClient.PostAsync("http://cvehicle.azurewebsites.net/api/Images", content);

            if (!response.IsSuccessStatusCode)
            {
                return(false);
            }
            return(true);
        }