public IPrescription GetPrescriptionByID(int ID)
        {
            Console.WriteLine("{0} is called!", nameof(GetPrescriptionByID));
            IPrescription prescription = Program.Container.Resolve <IPrescription>();

            prescription.ID = ID;

            switch (ID)
            {
            case 1:
                prescription.PatientID      = 1;
                prescription.MedicationName = "Aspirin";
                prescription.Dosage         = "2 tablets each day";
                break;

            case 2:
                prescription.PatientID      = 1;
                prescription.MedicationName = "Unisom";
                prescription.Dosage         = "1 tablet each day";
                break;

            case 3:
                prescription.PatientID      = 2;
                prescription.MedicationName = "Dulcolax";
                prescription.Dosage         = "2 tablets every other day";
                break;

            case 4:
                prescription.PatientID      = 3;
                prescription.MedicationName = "Travatan";
                prescription.Dosage         = "3 drops each day";
                break;

            case 5:
                prescription.PatientID      = 4;
                prescription.MedicationName = "Canesten";
                prescription.Dosage         = "Apply 6 times each day";
                break;

            default:
                throw new ArgumentException(String.Format("{0} has unknown value", nameof(ID)));
            }

            return(prescription);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Container = new UnityContainer();
            Container.AddNewExtension <Interception>();

            Container.RegisterType <IPrescription, Prescription>();
            Container.RegisterType <IPrescriptionService, PrescriptionService>(
                new Interceptor <InterfaceInterceptor>(),
                new InterceptionBehavior <AuditingInterceptionBehavior>());

            IPrescriptionService service = Container.Resolve <IPrescriptionService>();

            IPrescription prescription = service.GetPrescriptionByID(1);

            Console.WriteLine("Retrieved: {0}", prescription);

            Console.ReadKey();
        }
コード例 #3
0
        public Boolean addNewPrescription(string drugName, DateTime dateWritten, DateTime dateProcessed, DateTime dateDispensed, DateTime dateExpires, string instruction, int quantityWritten, int quantityDispensed, string drugCategory, string clientID)
        {
            try
            {
                int maxId     = 0;
                int maxUserID = 0;
                int maxGpID   = 0;

                foreach (Prescription prescription in PrescriptionList)
                {
                    if (prescription.PrescriptionID > maxId)
                    {
                        maxId = prescription.PrescriptionID;
                    }

                    if (prescription.UserID > maxUserID)
                    {
                        maxUserID = prescription.UserID;
                    }

                    if (prescription.GpID > maxGpID)
                    {
                        maxGpID = prescription.GpID;
                    }
                }

                IPrescription thePrescription = PrescriptionFactory.GetPrescription(maxId + 1, drugName, dateWritten, dateProcessed, dateDispensed, dateExpires, instruction, quantityDispensed, quantityWritten, drugCategory, maxUserID + 1, clientID, maxGpID + 1); // Using a Factory to create the user entity object. ie seperating object creation from business logic
                PrescriptionList.Add(thePrescription);                                                                                                                                                                                                                 // Add a reference to the newly created object to the Models UserList
                DataLayer.addNewPrescriptionToDB(thePrescription);                                                                                                                                                                                                     //Gets the DataLayer to add the new user to the DB.
                return(true);
            }
            catch (System.Exception excep)
            {
                return(false);
            }
        }
コード例 #4
0
 public static void SetClient(IPrescription aPrescription)
 {
     Prescription = aPrescription;
 }