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> >());
 }
Esempio n. 3
0
 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>());
 }
Esempio n. 4
0
 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()));
 }
Esempio n. 6
0
        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()));
        }
Esempio n. 7
0
        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!");
            }
        }
Esempio n. 8
0
        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!");
            }
        }
Esempio n. 9
0
        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!");
            }
        }
Esempio n. 10
0
        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!");
            }
        }
Esempio n. 11
0
        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!");
            }
        }
Esempio n. 12
0
        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}");
            }
        }
Esempio n. 13
0
        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);
        }
Esempio n. 14
0
        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();
            }
        }
Esempio n. 15
0
        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);
            }
        }