Пример #1
0
        //retrieves a single, unique prescription using the prescription ID
        public Prescription GetPrescription(int pID)
        {
            //get filepath of prescription file located in internal storage
            string internalStoragePath = Application.Context.FilesDir.Path;
            string prescriptionPath    = Path.Combine(internalStoragePath, prescriptionFileName);

            //return null if file doesn't exist
            if (!DoesPrescriptionExist(pID))
            {
                return(null);
            }

            string[] prescriptionData = File.ReadAllLines(prescriptionPath);
            foreach (string prescriptionLine in prescriptionData)
            {
                //if prescription ID matches pID, return the data of the current prescription
                if (GetRXIDFromPrescriptionData(prescriptionLine) == pID)
                {
                    ParserData newParserData = new ParserData(prescriptionLine);
                    return(newParserData.CreatePrescription());
                }
            }
            //if no matches found, return null
            return(null);
        }
Пример #2
0
        //returns a list of all the user's prescriptions
        public List <Prescription> GetAllPrescriptions()
        {
            List <Prescription> prescriptionList = new List <Prescription>();

            foreach (string p in GetAllPrescriptionData())
            {
                ParserData parse = new ParserData(p);
                prescriptionList.Add(parse.CreatePrescription());
            }

            return(prescriptionList);
        }