Ejemplo n.º 1
0
 public string Post([FromBody] AuthenticationService.loginRequest loginRequest) // user login
 {
     try
     {
         Task <AuthenticationService.loginResponse1> loginResponse1 = this.authPortClient.loginAsync(loginRequest);
         patientApi.Client         client  = new patientApi.Client(this.httpClient);
         Task <patientApi.Patient> patient = client.GetPatientAsync(loginResponse1.Result.loginResponse.token, loginResponse1.Result.loginResponse.userId);
         string healthPro = "";
         foreach (int healthProId in patient.Result.HealthProfessionalIds)
         {
             healthPro = healthPro + healthProId.ToString() + ",";
         }
         healthPro = healthPro.Length > 0 ? healthPro.Substring(0, healthPro.Length - 1) : healthPro;
         return("{'token': '" + loginResponse1.Result.loginResponse.token +
                "', 'userId': '" + loginResponse1.Result.loginResponse.userId.ToString() +
                "', 'username': '******', 'firstname': '" + patient.Result.FirstName +
                "', 'lastname': '" + patient.Result.LastName +
                "', 'dateOfBirth': '" + patient.Result.DateOfBirth +
                "', 'address': '" + patient.Result.Address +
                "', 'contactNumber': '" + patient.Result.ContactNumber +
                "', 'emailAddress': '" + patient.Result.EmailAddress +
                "', 'healthProIds': '" + healthPro +
                "'}"
                );
     }
     catch (Exception e)
     {
         return("{'status': 'failed'}");
     }
 }
Ejemplo n.º 2
0
 public string Put([FromBody] NewPatient newPatient)
 {
     try
     {
         patientApi.Client         client  = new patientApi.Client(this.httpClient);
         Task <patientApi.Patient> patient = client.PutPatientAsync(newPatient.token, newPatient, newPatient.PatientId ?? -200);
         if (patient.Result.PatientId == newPatient.PatientId)
         {
             string healthPro = "";
             foreach (int healthProId in patient.Result.HealthProfessionalIds)
             {
                 healthPro = healthPro + healthProId.ToString() + ",";
             }
             healthPro = healthPro.Length > 0 ? healthPro.Substring(0, healthPro.Length - 1) : healthPro;
             return("{'token': '" + newPatient.token +
                    "', 'userId': '" + newPatient.PatientId.ToString() +
                    "', 'username': '******', 'firstname': '" + patient.Result.FirstName +
                    "', 'lastname': '" + patient.Result.LastName +
                    "', 'dateOfBirth': '" + patient.Result.DateOfBirth +
                    "', 'address': '" + patient.Result.Address +
                    "', 'contactNumber': '" + patient.Result.ContactNumber +
                    "', 'emailAddress': '" + patient.Result.EmailAddress +
                    "', 'healthProIds': '" + healthPro +
                    "'}"
                    );
         }
         else
         {
             return("{'status': 'failed'}");
         }
     } catch (Exception e)
     {
         return("{'status':" + e.Message + "}");
     }
 }