public PersistPatientResponse PersistPatient(PersistPatientRequest request) { PersistPatientResponse response = new PersistPatientResponse(); // Set correlation Id response.CorrelationId = request.RequestId; try { // Call persistence request via Customer Facade. PatientFacade facade = new PatientFacade(); switch (request.PersistAction) { case PersistType.Insert: { Patient patient = new Patient(); patient.fName = request.Patient.FName; patient.LName = request.Patient.LName; patient.Phone = request.Patient.Phone; patient.UserID = request.Patient.UserID; patient.Email = request.Patient.Email; patient.SecQues = request.Patient.SecQues; patient.SecAns = request.Patient.SecAns; patient.Pass = request.Patient.Password; patient.dOBirth = request.Patient.dOBirth; patient.gender = request.Patient.gender; patient.zip = request.Patient.zip; patient.InsurName = request.Patient.healthIn; patient.LocationOfPolicy = request.Patient.locPolicy; patient.Address = request.Patient.address; patient.City = request.Patient.city; patient.State = request.Patient.state; patient.Provider = request.Patient.provider; facade.AddPatient(patient); response.Patient = request.Patient; response.Patient.PatientID = patient.PatientID; break; } //case PersistType.Update: // { // Customer customer = new Customer(); // customer.CustomerId = DecryptId(request.Customer.CustomerId); // customer.Company = request.Customer.Company; // customer.City = request.Customer.City; // customer.Country = request.Customer.Country; // facade.UpdateCustomer(customer); // response.Customer = request.Customer; // break; // } //case PersistType.Delete: // { // int customerId = DecryptId(request.Customer.CustomerId); // int rowsAffected = facade.DeleteCustomer(customerId); // if (rowsAffected == 0) // throw new Exception("Customer has orders and therefore cannot be deleted. "); // break; // } } } catch (Exception ex) { response.Acknowledge = AcknowledgeType.Failure; response.Message = ex.ToString(); } return response; }
public PatientResponse GetPatient(PatientRequest request) { PatientResponse response = new PatientResponse(); // Set correlation Id response.CorrelationId = request.RequestId; try { // Get customer patient via Patient Facade. PatientFacade facade = new PatientFacade(); response.Name = facade.GetPatient(request.PatientID); } catch // (Exception ex) { response.Acknowledge = AcknowledgeType.Failure; response.Message = "Request cannot be handled at this time."; } return response; }
public PatientResponse GetPatients(PatientRequest request) { PatientResponse response = new PatientResponse(); // Set correlation Id response.CorrelationId = request.RequestId; try { // Get customer list via Customer Facade. PatientFacade facade = new PatientFacade(); IList<Patient> list = facade.GetPatients(request.SortExpression); response.Patients = new PatientTransferObject[list.Count]; Console.WriteLine(list.Count.ToString()); // Package customer data in Customer Transfer Object int index = 0; foreach (Patient patient in list) { PatientTransferObject transfer = new PatientTransferObject(); transfer.PatientID = patient.PatientID; transfer.FName = patient.fName; transfer.LName = patient.LName; transfer.Phone = patient.Phone; response.Patients[index++] = transfer; } } catch // (Exception ex) { response.Acknowledge = AcknowledgeType.Failure; response.Message = "Request cannot be handled at this time."; } return response; }