public async void getRevenue(String _status, String token)
        {
            var client  = new ApiClient(ApiConstant.BASE_URL);
            var request = new ApiRequestBuilder();

            var req = request
                      .buildHttpRequest()
                      .addParameters("status", _status)
                      .setEndpoint("api/revenue/count")
                      .setRequestMethod(HttpMethod.Post);

            client.setAuthorizationToken(token);
            if (_status.Equals("paid"))
            {
                client.setOnSuccessRequest(setRevenue);
            }
            else if (_status.Equals("unpaid"))
            {
                client.setOnSuccessRequest(setUnpaidRevenue);
            }
            else if (_status.Equals("pending"))
            {
                client.setOnSuccessRequest(setPendingRevenue);
            }

            var response = await client.sendRequest(request.getApiRequestBundle());

            if (response.getHttpResponseMessage().ReasonPhrase.ToString().Equals("Internal Server Error"))
            {
                getView().callMethod("setFailStatus", "Failed to load statistics");
            }
        }
        public async void execute()
        {
            var    client  = new ApiClient.ApiClient("http://127.0.0.1:8000/");
            var    request = new ApiRequestBuilder();
            string token;

            var req = request
                      .buildHttpRequest()
                      .addParameters("email", "*****@*****.**")
                      .addParameters("password", "password")
                      .setEndpoint("api/login/")
                      .setRequestMethod(HttpMethod.Post);
            var response = await client.sendRequest(request.getApiRequestBundle());

            token = response.getJObject()["access_token"].ToString();

            client.setAuthorizationToken(token);
            MyList <MyFile> files   = new OpenFile().openFile(false);
            MyList <string> fileKey = new MyList <string>()
            {
                "file"
            };

            var formContent = new MultipartFormDataContent();

            formContent.Add(new StringContent("restapis.png"), "title");                                                 //parameters request, "value","key"
            formContent.Add(new StreamContent(new MemoryStream(files[0].byteArray)), fileKey[0], files[0].fullFileName); //file yang diupload

            req = new ApiRequestBuilder().buildMultipartRequest(new MultiPartContent(formContent))
                  .setRequestMethod(HttpMethod.Post)
                  .setEndpoint("api/store-file");
            response = await client.sendRequest(req.getApiRequestBundle());

            Console.WriteLine(response.getHttpResponseMessage().ToString());
        }
Example #3
0
        public async void editData(TextBox id_transaksi, TextBox alamat_pembeli, TextBox namaPembeli, TextBox totalHarga)
        {
            ApiClient client  = UtilProvider.getSession().getClient();
            var       request = new ApiRequestBuilder();

            MessageBox.Show(id.ToString());

            String URL = "transaction/" + id;

            var req = request
                      .buildHttpRequest()
                      .setEndpoint(URL)
                      .addParameters("price", totalHarga.Text)
                      .addParameters("amount", transaction.getAmount().ToString())
                      .setRequestMethod(HttpMethod.Put);

            client.setAuthorizationToken(UtilProvider.getSession().getUser().getData().getToken());
            var response = await client.sendRequest(request.getApiRequestBundle());

            Console.WriteLine(response.getHttpResponseMessage().ToString());

            if (response.getHttpResponseMessage().ReasonPhrase.Equals("Created"))
            {
                MessageBox.Show("Edited");
                UserCredential userCredential = response.getParsedObject <UserCredential>();
            }
            else
            {
                MessageBox.Show(response.getHttpResponseMessage().ReasonPhrase);
            }
        }
        public async void LoadReservationPage(int currentPage)
        {
            var client  = new ApiClient(API.URL);
            var request = new ApiRequestBuilder();
            var req     = request
                          .buildHttpRequest()
                          .setEndpoint(API.reservationPage.Replace("{number}", currentPage.ToString()))
                          .setRequestMethod(HttpMethod.Get);

            client.setAuthorizationToken(File.ReadAllText("jwt.txt"));
            client.setOnSuccessRequest(CallbackSuccess);
            var response = await client.sendRequest(request.getApiRequestBundle());
        }
        public async void SearchReservation(string assetName)
        {
            var client  = new ApiClient(API.URL);
            var request = new ApiRequestBuilder();
            var req     = request
                          .buildHttpRequest()
                          .setEndpoint(API.reservationAsset.Replace("{name}", assetName))
                          .setRequestMethod(HttpMethod.Get);

            client.setAuthorizationToken(File.ReadAllText("jwt.txt"));
            client.setOnSuccessRequest(CallbackSuccess);
            var response = await client.sendRequest(request.getApiRequestBundle());
        }
        public async void deleteProcess(HealthAgency healthAgency)
        {
            ApiClient client  = ApiAntrianSehat.getInstance().GetApiClient();
            var       request = new ApiRequestBuilder();

            var req = request.buildHttpRequest()
                      .setEndpoint("health-agency/" + healthAgency.id)
                      .setRequestMethod(HttpMethod.Delete);

            client.setOnSuccessRequest(setViewSuccessDelete);
            client.setOnFailedRequest(setViewErrorDelete);
            var response = await client.sendRequest(request.getApiRequestBundle());
        }
        public async void deleteProcess(PolyMaster polyMaster)
        {
            ApiClient client  = ApiAntrianSehat.getInstance().GetApiClient();
            var       request = new ApiRequestBuilder();

            var req = request.buildHttpRequest()
                      .setEndpoint("poly-master/" + polyMaster.id)
                      .setRequestMethod(HttpMethod.Delete);

            client.setOnSuccessRequest(setViewSuccessDelete);
            client.setOnFailedRequest(setViewErrorDelete);
            var response = await client.sendRequest(request.getApiRequestBundle());
        }
        public async void fetchDataPolyMaster()
        {
            client = ApiAntrianSehat.getInstance().GetApiClient();
            var request = new ApiRequestBuilder();

            var req = request.buildHttpRequest()
                      .setEndpoint("poly-master/")
                      .setRequestMethod(HttpMethod.Get);

            client.setOnSuccessRequest(setViewSuccessFetch);
            client.setOnFailedRequest(setViewFailedFetch);
            var response = await client.sendRequest(request.getApiRequestBundle());
        }
Example #9
0
        public async void updatePolyMaster(int id, String name)
        {
            var request = new ApiRequestBuilder();
            var req     = request.buildHttpRequest()
                          .addParameters("_method", "PUT")
                          .addParameters("name", name)
                          .setEndpoint("poly-master/" + id.ToString())
                          .setRequestMethod(HttpMethod.Post);

            client.setOnSuccessRequest(setSuccessStorePolyMaster);
            client.setOnFailedRequest(setErrorStorePolyMaster);
            var response = await client.sendRequest(request.getApiRequestBundle());
        }
Example #10
0
        public async void fetchDataHealthAgency()
        {
            var request = new ApiRequestBuilder();

            var req = request
                      .buildHttpRequest()
                      .setEndpoint("health-agency/all")
                      .setRequestMethod(HttpMethod.Get);

            client.setOnSuccessRequest(setViewSuccessFetchHealthAgency);
            client.setOnFailedRequest(setViewErrorFetchHealthAgency);
            var response = await client.sendRequest(request.getApiRequestBundle());
        }
Example #11
0
        public async void getLocation()
        {
            var client  = new ApiClient("http://api.dolankuy.me/");
            var request = new ApiRequestBuilder();

            var req = request
                      .buildHttpRequest()
                      .setEndpoint("api/acomodation")
                      .setRequestMethod(HttpMethod.Get);

            client.setOnSuccessRequest(setItem);
            var response = await client.sendRequest(request.getApiRequestBundle());
        }
        public async void getCategory()
        {
            var client  = new ApiClient("http://127.0.0.1:8000/");
            var request = new ApiRequestBuilder();

            var req = request
                      .buildHttpRequest()
                      .setEndpoint("api/category")
                      .setRequestMethod(HttpMethod.Get);

            client.setOnSuccessRequest(setItem);
            var response = await client.sendRequest(request.getApiRequestBundle());
        }
        public async void generateData(DataGrid data_grid_transaction)
        {
            if (UtilProvider.getDataTransaction() != null)
            {
                List <DataTransaction> data        = UtilProvider.getDataTransaction().getData();
                List <HistoryData>     dataHistory = new List <HistoryData>();

                for (int i = 0; i < data.Count(); i++)
                {
                    String   po_number = data.ElementAt(i).getPoNumber();
                    DateTime date      = data.ElementAt(i).getCreatedAt();
                    Double   amount    = data.ElementAt(i).getAmount().GetValueOrDefault();

                    ApiClient client  = UtilProvider.getSession().getClient();
                    var       request = new ApiRequestBuilder();

                    String URL = "user/id/" + data.ElementAt(i).getCustomerId().ToString();

                    var req = request
                              .buildHttpRequest()
                              .setEndpoint(URL)
                              .setRequestMethod(HttpMethod.Get);
                    client.setAuthorizationToken(UtilProvider.getSession().getUser().getData().getToken());
                    var response = await client.sendRequest(request.getApiRequestBundle());

                    String name;
                    String phone;

                    if (response.getHttpResponseMessage().ReasonPhrase.Equals("OK"))
                    {
                        UserCredential userCredential = response.getParsedObject <UserCredential>();
                        name  = userCredential.getData().getFullName();
                        phone = userCredential.getData().getPhone();
                    }
                    else
                    {
                        //MessageBox.Show(response.getHttpResponseMessage().ReasonPhrase);
                        phone = name = "unknown";
                    }

                    dataHistory.Add(new HistoryData(po_number, date, name, phone, amount));
                }

                data_grid_transaction.ItemsSource = dataHistory;
            }
            else
            {
                MessageBox.Show("Your Outlet never Have any Transaction History");
            }
        }
        public async void showSparepart(int sparepartId, String token)
        {
            var client  = new ApiClient(ApiConstant.BASE_URL);
            var request = new ApiRequestBuilder();

            var req = request
                      .buildHttpRequest()
                      .setEndpoint("api/sparepart/" + sparepartId + "/")
                      .setRequestMethod(HttpMethod.Get);

            client.setAuthorizationToken(token);
            client.setOnSuccessRequest(setSparepart);
            var response = await client.sendRequest(request.getApiRequestBundle());
        }
        public async void LoadAsset()
        {
            var client         = new ApiClient(API.URL);
            var requestBuilder = new ApiRequestBuilder();

            client.setAuthorizationToken(File.ReadAllText("jwt.txt"));

            var request = requestBuilder.buildHttpRequest()
                          .setEndpoint(API.assets)
                          .setRequestMethod(HttpMethod.Get);

            client.setOnSuccessRequest(CallbackSuccess);
            var response = await client.sendRequest(request.getApiRequestBundle());
        }
Example #16
0
        public async void OnLogout()
        {
            ApiClient client  = UtilProvider.getSession().getClient();
            var       request = new ApiRequestBuilder();

            var req = request
                      .buildHttpRequest()
                      .setEndpoint("logout")
                      .setRequestMethod(HttpMethod.Get);

            client.setAuthorizationToken(UtilProvider.getSession().getUser().getData().getToken());

            var response = await client.sendRequest(request.getApiRequestBundle());
        }
        public async void fetchDataPolyclinic()
        {
            ApiClient client  = ApiAntrianSehat.getInstance().GetApiClient();
            var       request = new ApiRequestBuilder();

            var req = request
                      .buildHttpRequest()
                      .setEndpoint("schedule/of-ha/" + Application.Current.Resources["ha_id"])
                      .setRequestMethod(HttpMethod.Get);

            client.setOnSuccessRequest(setViewSuccessFetch);
            client.setOnFailedRequest(setViewErrorFetch);
            var response = await client.sendRequest(request.getApiRequestBundle());
        }
        public async void fetchHAData(int idHA)
        {
            client = ApiAntrianSehat.getInstance().GetApiClient();
            var request = new ApiRequestBuilder();

            var req = request
                      .buildHttpRequest()
                      .setEndpoint("health-agency/" + idHA.ToString())
                      .setRequestMethod(HttpMethod.Get);

            client.setOnSuccessRequest(setViewSuccessFetchHA);
            client.setOnFailedRequest(setViewErrorFetchHA);
            var response = await client.sendRequest(request.getApiRequestBundle());
        }
Example #19
0
        public async void deleteAkomodasi(String id, String token)
        {
            var client  = new ApiClient("http://api.dolankuy.me/");
            var request = new ApiRequestBuilder();

            var req = request
                      .buildHttpRequest()
                      .setEndpoint("api/locations/delete/" + id)
                      .setRequestMethod(HttpMethod.Delete);

            client.setAuthorizationToken(token);
            client.setOnSuccessRequest(onDelete);
            var response = await client.sendRequest(request.getApiRequestBundle());
        }
Example #20
0
        /*
         * //revisi backend
         * public async void getCategory()
         * {
         *  var client = new ApiClient("http://127.0.0.1:8000/");
         *  var request = new ApiRequestBuilder();
         *
         *  var req = request
         *      .buildHttpRequest()
         *      .setEndpoint("api/category")
         *      .setRequestMethod(HttpMethod.Get);
         *  client.setOnSuccessRequest(setItem);
         *  var response = await client.sendRequest(request.getApiRequestBundle());
         * }*/

        //Update
        public async void putCategory(String _categoryName, int _categoryId)
        {
            var client  = new ApiClient("http://127.0.0.1:8000/");
            var request = new ApiRequestBuilder();

            var req = request
                      .buildHttpRequest()
                      .addParameters("name", _categoryName)
                      .setEndpoint("api/category/update/" + _categoryId)
                      .setRequestMethod(HttpMethod.Put);

            client.setOnSuccessRequest(setItem);
            var response = await client.sendRequest(request.getApiRequestBundle());
        }
Example #21
0
        public async void logout()
        {
            var client  = ApiUtil.Instance.vClient;
            var request = new ApiRequestBuilder();

            var req = request
                      .buildHttpRequest()
                      .setEndpoint("/logout?Authorization=Bearer" + token)
                      .setRequestMethod(HttpMethod.Get);

            client.setAuthorizationToken(token);
            client.setOnSuccessRequest(navigateViewLogout);
            var response = await client.sendRequest(request.getApiRequestBundle());
        }
        public async void getTotal()
        {
            var client         = new ApiClient(Constants.BASE_URL);
            var requestBuilder = new ApiRequestBuilder();
            var request        = requestBuilder
                                 .buildHttpRequest()
                                 .setEndpoint("users")
                                 .setRequestMethod(HttpMethod.Get);
            string token = StorageUtil.Instance.token;

            client.setAuthorizationToken(token);
            client.setOnSuccessRequest(setViewTotal);
            var response = await client.sendRequest(request.getApiRequestBundle());
        }
        public async void fetchDataUser()
        {
            ApiClient client  = ApiAntrianSehat.getInstance().GetApiClient();
            var       request = new ApiRequestBuilder();

            var req = request
                      .buildHttpRequest()
                      .setEndpoint("user/role-admin")
                      .setRequestMethod(HttpMethod.Get);

            client.setOnSuccessRequest(setViewSuccessFetch);
            client.setOnFailedRequest(setViewErrorFetch);
            var response = await client.sendRequest(request.getApiRequestBundle());
        }
Example #24
0
        public async void logout(string _token)
        {
            var client  = new ApiClient("http://api.dolankuy.me/");
            var request = new ApiRequestBuilder();

            this.token = _token;
            var req = request
                      .buildHttpRequest()
                      .setEndpoint("api/logout")
                      .setRequestMethod(HttpMethod.Post);

            client.setAuthorizationToken(_token);
            client.setOnSuccessRequest(setViewStatus);
            var response = await client.sendRequest(request.getApiRequestBundle());
        }
        public async void CountReturnedReservation()
        {
            var client         = new ApiClient(API.URL);
            var requestBuilder = new ApiRequestBuilder();

            client.setAuthorizationToken(File.ReadAllText("jwt.txt"));

            var request = requestBuilder.buildHttpRequest()
                          .setEndpoint(API.countStatusReservation.Replace("{status}", "return"))
                          .setRequestMethod(HttpMethod.Get);

            var response = await client.sendRequest(request.getApiRequestBundle());

            getView().callMethod("SetReturnedReservationLabel", (int)response.getJObject()["count"]);
        }
        public async void postCategory(string _name)
        {
            var client  = new ApiClient("http://127.0.0.1:8000/");
            var request = new ApiRequestBuilder();

            //string token = "";
            var req = request
                      .buildHttpRequest()
                      .addParameters("name", _name)
                      .setEndpoint("api/category/create")
                      .setRequestMethod(HttpMethod.Post);

            client.setOnSuccessRequest(setViewCategoryStatus);
            var response = await client.sendRequest(request.getApiRequestBundle());
        }
        public async void DeleteAsset(string id)
        {
            var client         = new ApiClient(API.URL);
            var requestBuilder = new ApiRequestBuilder();

            client.setAuthorizationToken(File.ReadAllText("jwt.txt"));

            var request = requestBuilder.buildHttpRequest()
                          .setEndpoint(API.assetId.Replace("{id}", id))
                          .setRequestMethod(HttpMethod.Delete);
            var response = await client.sendRequest(request.getApiRequestBundle());

            MessageBox.Show(response.getJObject()["message"].ToString(), "Success", MessageBoxButton.OK, MessageBoxImage.Information);
            getView().callMethod("RouteToAssetPage");
        }
Example #28
0
        public async void CreatePolyclinic(int _polyMasterId)
        {
            var request = new ApiRequestBuilder();

            Console.WriteLine("ha_id", Application.Current.Resources["ha_id"]);
            var req = request
                      .buildHttpRequest()
                      .addParameters("poly_master_id", _polyMasterId.ToString())
                      .addParameters("health_agency_id", (string)Application.Current.Resources["ha_id"])
                      .setEndpoint("polyclinic/")
                      .setRequestMethod(HttpMethod.Post);

            client.setOnSuccessRequest(setSuccessCreatePolyclinic);
            client.setOnFailedRequest(setErrorCreatePolyclinic);
            var response = await client.sendRequest(request.getApiRequestBundle());
        }
Example #29
0
        public async void getUser(String filter)
        {
            var client  = ApiUtil.Instance.vClient;
            var request = new ApiRequestBuilder();

            var req = request
                      .buildHttpRequest()
                      .setEndpoint("/users" + filter)
                      .setRequestMethod(HttpMethod.Get);
            String token = StorageUtil.Instance.token;

            //Console.WriteLine(req.getApiRequestBundle().ToString());
            client.setAuthorizationToken(token);
            client.setOnSuccessRequest(setUser);
            var response = await client.sendRequest(request.getApiRequestBundle());
        }
        public async void SearchAsset(string name)
        {
            var client         = new ApiClient(API.URL);
            var requestBuilder = new ApiRequestBuilder();

            client.setAuthorizationToken(File.ReadAllText("jwt.txt"));

            var request = requestBuilder.buildHttpRequest()
                          .setEndpoint(API.assetName.Replace("{name}", name))
                          .setRequestMethod(HttpMethod.Get);
            var response = await client.sendRequest(request.getApiRequestBundle());

            List <Model.Asset> assets = response.getParsedObject <List <Model.Asset> >();

            getView().callMethod("SetSearchAsset", SetImagePath(assets));
        }