//method yg dijalankan saat request success harus memiliki parameter bertipe HttpResponseBundle private void setViewSuccessLogin(HttpResponseBundle _response) { if (_response.getHttpResponseMessage().Content != null) { Application.Current.Resources["email"] = _response.getJObject()["user"]["email"]; Application.Current.Resources["ha_id"] = _response.getJObject()["user"]["health_agency_id"]; String role = _response.getJObject()["user"]["role"].ToString(); String saveStr = _response.getJObject()["user"]["email"] + "," + _response.getJObject()["access_token"].ToString() + "," + _response.getJObject()["user"]["role"] + "," + _response.getJObject()["user"]["health_agency_id"]; TextOperation.writeToFile("../../assets/user.txt", saveStr); client.setAuthorizationToken(_response.getJObject()["access_token"].ToString()); string status = _response.getHttpResponseMessage().ReasonPhrase; if (role == "Admin" || role == "Super Admin") { getView().callMethod("setLoginSuccess", status, role); } else { getView().callMethod("restrictNoAuthentication", status); } } }
public void CallbackOperationFailed(HttpResponseBundle _response) { if (_response.getHttpResponseMessage().Content != null) { MessageBox.Show("An Asset has alerady exists", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void CallbackOperationSuccess(HttpResponseBundle _response) { if (_response.getHttpResponseMessage().Content != null) { MessageBox.Show(_response.getJObject()["message"].ToString(), "Success", MessageBoxButton.OK, MessageBoxImage.Information); } }
private async void setAddUserStatus(HttpResponseBundle _response) { getView().callMethod("endLoading"); if (_response.getHttpResponseMessage().Content != null) { string status = _response.getHttpResponseMessage().ReasonPhrase; string response = await _response.getHttpResponseMessage().Content.ReadAsStringAsync(); getView().callMethod("setAddUserStatus", status); Trace.WriteLine(response); if (_response.getHttpResponseMessage().IsSuccessStatusCode) { JObject userDataJson = null; if (_response.getJObject() != null) { userDataJson = (JObject)_response.getJObject()["data"]; } if (userDataJson != null) { int staffId = (int)userDataJson["id"]; getView().callMethod("navigateToStaffPage", staffId); } } } }
private void setViewSuccessFetch(HttpResponseBundle _response) { Console.WriteLine("sukses: " + _response.getJObject()); List <User> users = _response.getParsedObject <RootUser>().data; getView().callMethod("setListView", users); }
private void setViewSuccessFetch(HttpResponseBundle _response) { Console.WriteLine("sukses: " + _response.getJObject()); Pagination healthAgencyPagination = _response.getParsedObject <RootHealthAgency>().data; getView().callMethod("setListView", healthAgencyPagination); }
private void setItem(HttpResponseBundle _response) { if (_response.getHttpResponseMessage().Content != null) { getView().callMethod("setService", _response.getParsedObject <Services>().services); } }
private void setItem(HttpResponseBundle _response) { if (_response.getHttpResponseMessage().Content != null) { getView().callMethod("setCategory", _response.getParsedObject <RootCategory>().category); } }
private void viewShowListSubjectofDepartment(HttpResponseBundle _response) { if (_response.getHttpResponseMessage().Content != null) { getView().callMethod("showListSubjectofDepartment", _response.getParsedObject <APIResponse <List <SubjectModel> > >().Data); } }
private void onDelete(HttpResponseBundle _response) { if (_response.getHttpResponseMessage().Content != null) { getView().callMethod("setDelete", _response.getHttpResponseMessage().ToString()); } }
private void setItem(HttpResponseBundle _response) { if (_response.getHttpResponseMessage().Content != null) { getView().callMethod("setLocation", _response.getParsedObject <RootAkomodasi>().acomodation); } }
private void setViewSuccessFetchPolyMaster(HttpResponseBundle _response) { Console.WriteLine("success: " + _response.getHttpResponseMessage() .Content.ReadAsStringAsync().Result); //PolyMaster polyMaster = _response.getParsedObject<RootSinglePolyMaster>().data; //getView().callMethod("setPolyMasterData", polyMaster); }
public async void deleteStaff(int staffId) { ApiClient client = ApiUtil.Instance.vClient; ApiRequestBuilder requestBuilder = new ApiRequestBuilder() .buildHttpRequest() .setRequestMethod(HttpMethod.Delete) .setEndpoint("users/" + staffId.ToString()); ApiRequestBundle requestBundle = requestBuilder.getApiRequestBundle(); HttpResponseBundle response = null; getView().callMethod("startLoading"); client.setAuthorizationToken(StorageUtil.Instance.token); client.setOnSuccessRequest(onSuccessDeleteStaff); client.setOnFailedRequest(onFailedDeleteStaff); try { response = await client.sendRequest(requestBundle); if (response.getHttpResponseMessage().Content != null) { Trace.WriteLine("deleteStaff Response: \n" + await response.getHttpResponseMessage().Content.ReadAsStringAsync()); } } catch (Exception e) { getView().callMethod("endLoading"); getView().callMethod("showErrorMessage", "Failed to delete staff. " + e.Message); } }
private void setViewSuccessFetch(HttpResponseBundle _response) { List <Polyclinic> polyclinics = _response.getParsedObject <Root>().data; foreach (Polyclinic polyclinic in polyclinics) { List <Schedule> schedules = new List <Schedule>(); for (int i = 0; i < 7; i++) { Schedule schedule = new Schedule(); var isExist = polyclinic.sorted.Find(x => x.day == i); if (isExist == null) { schedule.id = -1; schedule.polyclinic_id = -1; schedule.day = i; schedule.time_open = "-"; schedule.time_close = "-"; schedule.charOfDay = "-"; schedule.date = "-"; } else { schedule = isExist; } schedules.Add(schedule); } polyclinic.sorted = schedules; } getView().callMethod("setListView", polyclinics); }
private void setErrorStorePolyMaster(HttpResponseBundle _response) { string message = _response.getHttpResponseMessage().Content.ReadAsStringAsync().Result; Console.WriteLine("error: " + _response.getJObject()); getView().callMethod("setErrorStore", message); }
private void setPickup(HttpResponseBundle _response) { if (_response.getHttpResponseMessage().Content != null) { getView().callMethod("setPickup", _response.getParsedObject <Pickups>().pickups); } }
private void setUserToken(HttpResponseBundle _response) { if (_response.getHttpResponseMessage().Content != null) { getView().callMethod("saveToken", _response.getJObject()["token"].ToString()); } }
private void onSuccessGetStaff(HttpResponseBundle _response) { getView().callMethod("endLoading"); if (_response.getHttpResponseMessage().Content != null) { JObject responseJSON = _response.getJObject(); JObject userDataJSON = (JObject)responseJSON["data"]; User staff = new User() { id = (int)userDataJSON["id"], company_id = (int)userDataJSON["company_id"], name = (string)userDataJSON["name"], email = (string)userDataJSON["email"], image = (string)userDataJSON["image"], role = (string)userDataJSON["role"] }; getView().callMethod("initStaff", staff); getView().callMethod("changeToShowStaffPage"); } else { getView().callMethod("showErrorMessage", "Error initializing staff data."); getView().callMethod("navigateToStaffListPage"); } }
private async void setUserInLocalStorage(int userId) { HttpResponseBundle response = await getUser(userId); if (response != null && response.getHttpResponseMessage().IsSuccessStatusCode) { JObject userDataJson = (JObject)response.getJObject()["data"]; StorageUtil.Instance.user = new User() { id = (int)userDataJson["id"], company_id = (int)userDataJson["company_id"], name = (string)userDataJson["name"], email = (string)userDataJson["email"], role = (string)userDataJson["role"], image = (string)userDataJson["image"] }; } else { getView().callMethod("showErrorMessage", "Failed getting updated user data."); } getView().callMethod("navigateToProfilePage"); }
private void viewListMahasiswaController(HttpResponseBundle _response) { if (_response.getHttpResponseMessage().Content != null) { getView().callMethod("showListMahasiswa", _response.getParsedObject <APIResponse <List <StudentModel> > >().Data); } }
private void viewShowListDetailKehadiranMahasiswa(HttpResponseBundle _response) { List <ScheduleModel> res, finalRes; if (_response.getHttpResponseMessage().Content != null) { res = new List <ScheduleModel>(_response.getParsedObject <APIResponse <List <ScheduleModel> > >().Data); finalRes = new List <ScheduleModel>(); DateTime date; foreach (var key in res) { if (key.Subject.Id.Equals(subjectId)) { date = Convert.ToDateTime(key.Time); key.Time = date.ToString("dd MMM yyyy"); date = Convert.ToDateTime(key.Attendance.Time); key.Attendance.Time = date.ToString("HH:mm"); finalRes.Add(key); } } Console.WriteLine(_response.getJObject()); getView().callMethod("showListDetailKehadiranMahasiswa", finalRes); } }
public async void updateUser(int userId, string name, string email, string currentPassword, string newPassword, string currentImagePath, MyFile newImageFile) { string newImagePath; JObject userDataJson = new JObject(); JObject userJson = new JObject(); ApiClient client = ApiUtil.Instance.vClient; ApiRequestBuilder requestBuilder; ApiRequestBundle requestBundle; HttpResponseBundle response = null; getView().callMethod("startLoading"); if (currentPassword != null && newPassword != null) { bool validatePasswordSuccess = await validatePassword(currentPassword); if (!validatePasswordSuccess) { getView().callMethod("endLoading"); return; } userDataJson.Add("password", newPassword); } newImagePath = await postUserImage(newImageFile); userDataJson.Add("name", name); userDataJson.Add("email", email); userDataJson.Add("role", "owner"); userDataJson.Add("image", newImagePath == null ? currentImagePath : newImagePath); userJson.Add("user", userDataJson); requestBuilder = new ApiRequestBuilder() .buildHttpRequest() .setRequestMethod(HttpMethod.Put) .setEndpoint("users/" + userId.ToString()) .addJSON <JObject>(userJson); requestBundle = requestBuilder.getApiRequestBundle(); client.setAuthorizationToken(StorageUtil.Instance.token); client.setOnSuccessRequest(onSuccessUpdateUser); client.setOnFailedRequest(onFailedUpdateUser); try { response = await client.sendRequest(requestBundle); if (response.getHttpResponseMessage().IsSuccessStatusCode) { setUserInLocalStorage(userId); } } catch (Exception e) { getView().callMethod("endLoading"); getView().callMethod("showErrorMessage", "Failed updating profile. " + e.Message); } }
private void setUser(HttpResponseBundle _response) { if (_response.getHttpResponseMessage().Content != null) { string status = _response.getHttpResponseMessage().ReasonPhrase; getView().callMethod("setUser", _response.getParsedObject <ItemUser>().user); } }
private void setViewRegisterStatus(HttpResponseBundle _response) { if (_response.getHttpResponseMessage().Content != null) { string status = _response.getHttpResponseMessage().ReasonPhrase; getView().callMethod("setRegisterStatus", status); } }
private void setPendingRevenue(HttpResponseBundle _response) { if (_response.getHttpResponseMessage().Content != null) { string status = _response.getHttpResponseMessage().ReasonPhrase; getView().callMethod("setPendingRevenue", _response.getParsedObject <RevenueCount>().count); } }
private void setBookingsCanceled(HttpResponseBundle _response) { if (_response.getHttpResponseMessage().Content != null) { string status = _response.getHttpResponseMessage().ReasonPhrase; getView().callMethod("setCanceled", _response.getParsedObject <BookingCount>().count); } }
public void ViewShowListStudent(HttpResponseBundle _response) { if (_response.getHttpResponseMessage().Content != null) { string status = _response.getHttpResponseMessage().ReasonPhrase; getView().callMethod("ShowListStudent", _response.getParsedObject <APIResponse <List <DepartmentSummaryModel> > >().Data); } }
private void setItem(HttpResponseBundle _response) { if (_response.getHttpResponseMessage().Content != null) { string status = _response.getHttpResponseMessage().ReasonPhrase; getView().callMethod("setBooking", _response.getParsedObject <Bookings>().booking); } }
private void setStatus(HttpResponseBundle _response) { if (_response.getHttpResponseMessage().Content != null) { string status = _response.getHttpResponseMessage().ReasonPhrase; getView().callMethod("setStatus", _response.getJObject()["message"].ToString()); } }
private void viewShowListMahasiswa(HttpResponseBundle _response) { if (_response.getHttpResponseMessage().Content != null) { string status = _response.getHttpResponseMessage().ReasonPhrase; getView().callMethod("showListMahasiswa", _response.getParsedObject <APIResponse <List <DepartmentSummaryModel> > >().Data); } }