private List <string> GetDoctorsForHospital(string BasicAuthentication, string hospitalId) { return(HttpRequest.Of($"https://localhost:44348/api/hospitals/{hospitalId}/doctors", RequestType.GET) .BasicAuthentication(BasicAuthentication) .OnError(MessageBox.ShowMessageBoxError("Warning Data Input", "")) .Execute() .DeserializeBody <List <string> >()); }
private ObservableCollection <Patient> GETAllPatientsRequest(string BasicAuthentication) { return(HttpRequest.Of($"https://localhost:44348/api/patients", RequestType.GET) .BasicAuthentication(BasicAuthentication) .OnError(MessageBox.ShowMessageBoxError("Warning Data Input", "")) .Execute() .DeserializeBody <ObservableCollection <Patient> >()); }
private Doctor GETDoctorInfoRequest(string param, string BasicAuthentication) { return(HttpRequest.Of($"https://localhost:44348/api/doctors/{param}", RequestType.GET) .BasicAuthentication(BasicAuthentication) .OnError(MessageBox.ShowMessageBoxError("Warning Data Input", "")) .Execute() .DeserializeBody <Doctor>()); }
private ObservableCollection <Visit> GETDoctorVisitsRequest(string BasicAuthentication) { VisitList = HttpRequest.Of($"https://localhost:44348/api/visits", RequestType.GET) .BasicAuthentication(BasicAuthentication) .OnError(MessageBox.ShowMessageBoxError("Warning Data Input", "")) .Execute() .DeserializeBody <ObservableCollection <Visit> >(); return(VisitList); }
private ObservableCollection <Hospital> GETAllHospitalsRequest(string BasicAuthentication) { return(new ObservableCollection <Hospital>(HttpRequest.Of($"https://localhost:44348/api/hospitals", RequestType.GET) .BasicAuthentication(BasicAuthentication) .OnError(MessageBox.ShowMessageBoxError("Warning Data Input", "")) .Execute() .DeserializeBody <ObservableCollection <Hospital> >() .Where(hospital => GetDoctorsForHospital(BasicAuthentication, hospital.Guid).Contains(User.Guid)) .ToList())); }
private ObservableCollection <Doctor> GETAllDoctorsRequest(string BasicAuthentication) { var Doctors = HttpRequest.Of($"https://localhost:44348/api/doctors", RequestType.GET) .BasicAuthentication(BasicAuthentication) .OnError(MessageBox.ShowMessageBoxError("Warning Data Input", "")) .Execute() .DeserializeBody <List <Doctor> >(); var doctorsForHospital = GetDoctorsForHospital(User.Guid, BasicAuthentication); return(new ObservableCollection <Doctor>(Doctors.Where(doctor => doctorsForHospital.Contains(doctor.Guid)).ToList())); }
private void DELETEHospitalRequest(string BasicAuthentication, string Guid) { var httpResponse = HttpRequest.Of($"https://localhost:44348/api/hospitals/{Guid}", RequestType.DELETE) .BasicAuthentication(BasicAuthentication) .OnError(MessageBox.ShowMessageBoxError("Warning Data Input", "")) .Execute(); if (httpResponse.IsSuccessful()) { MessageBox.ShowMessageBoxInfo("Deleting Info Message", "The Hospital was successfully deleted!"); } }
private void POSTDoctorInfoRequest(string param, string BasicAuthentication, Doctor Doctor) { var httpResponse = HttpRequest.Of($"https://localhost:44348/api/hospitals/{param}/doctors", RequestType.POST) .BasicAuthentication(BasicAuthentication) .OnError(MessageBox.ShowMessageBoxError("Warning Data Input", "Adding of Doctor cannot be done!")) .BodyData(Doctor.Guid) .Execute(); if (httpResponse.IsSuccessful()) { MessageBox.ShowMessageBoxInfo("Doctor Creation Info", "The Doctor was added successfully!"); } }
private void PUTHospitalRequest(string BasicAuthentication, string Guid, JObject Hospital) { var httpResponse = HttpRequest.Of($"https://localhost:44348/api/hospitals/{Guid}", RequestType.PUT) .BasicAuthentication(BasicAuthentication) .BodyData(Hospital) .OnError(MessageBox.ShowMessageBoxError("Warning Data Input", "")) .Execute(); if (httpResponse.IsSuccessful()) { MessageBox.ShowMessageBoxInfo("Updating Info Message", "The Hospital was successfully updated!"); } }
private void PUTDoctorInfoRequest(string param, string BasicAuthentication) { var response = HttpRequest.Of($"https://localhost:44348/api/doctors/{param}", RequestType.PUT) .BasicAuthentication(BasicAuthentication) .BodyData(Doctor) .OnError(MessageBox.ShowMessageBoxError("Warning Data Input", "Updating of the Doctor Info cannot be done!")) .Execute(); if (response != null) { MessageBox.ShowMessageBoxInfo("Doctor Update Info", "Doctor Information was updated successfully!"); } }
private void PUTHospitalInfoRequest(string hospitalId, string BasicAuthentication) { var httpResponse = HttpRequest.Of($"https://localhost:44348/api/hospitals/{hospitalId}", RequestType.PUT) .BasicAuthentication(BasicAuthentication) .BodyData(HospitalObject) .OnError(MessageBox.ShowMessageBoxError("Warning Data Input", "Updating of the Hospital Info cannot be done!")) .Execute(); if (httpResponse.IsSuccessful()) { MessageBox.ShowMessageBoxInfo("Hospital Update Info", "Hospital Information was updated successfully!"); } }
private void POSTPatientRequest(string BasicAuthentication, JObject Patient) { var newCreatedUser = HttpRequest.Of("https://localhost:44348/api/patients", RequestType.POST) .BasicAuthentication(BasicAuthentication) .BodyData(Patient) .OnError(MessageBox.ShowMessageBoxError("Warning Data Input", "")) .Execute() .DeserializeBody <NewCreatedUser>(); if (newCreatedUser != null) { MessageBox.ShowMessageBoxInfo("Patient Registration Info", $"Username:{newCreatedUser.Username}\nPassword:{newCreatedUser.Password}"); } }
private bool ValidatePatientEGN() { if (Egn.Text.ToString().Length != 10) { MessageBox.ShowMessageBoxError("Wrong Data Input", "The Doctor's EGN should be excatly 10 digits!"); return(false); } else if (!Egn.Text.ToString().All(c => char.IsDigit(c))) { MessageBox.ShowMessageBoxInfo("Wrong Data Input", "The Doctor's EGN should contains only digts!"); return(false); } return(true); }
private void POSTDiagnosisRequest(string BasicAuthentication, JObject diagnosis) { var httpResponse = HttpRequest.Of("https://localhost:44348/api/diagnoses", RequestType.POST) .BasicAuthentication(BasicAuthentication) .BodyData(diagnosis) .OnError(MessageBox.ShowMessageBoxError("Warning Data Input", "")) .Execute(); if (httpResponse.IsSuccessful()) { MessageForm MessageForm = new MessageForm("Info", "The Diagnose is successfully created"); MessageForm.ShowDialog(); this.Close(); } }
private void POSTLoginRequest(string Username, string Password) { User User = null; var BasicAuthentication = Base64Encode($"{Username}:{Password}"); var user = HttpRequest.Of("https://localhost:44348/api/login", RequestType.POST) .BasicAuthentication(BasicAuthentication) .OnError(MessageBox.ShowMessageBoxError("Warning Data Input", "")) .Execute() .DeserializeBody <User>(); if (user != null) { User = user; User.AuthenticationCredentials = BasicAuthentication; // SHOW FORM ShowForm(User); } }