/// <summary>
 /// Add a new Microsoft Band Temperature data record to the database
 /// </summary>
 /// <param name="msBandTemperature">MSBandTemperature object to add to the database</param>
 public void CreateMSBandTemperature(MSBandTemperature msBandTemperature)
 {
     if(msBandTemperature != null) {
         _repository.Add(msBandTemperature);
     }
 }
Exemple #2
0
        /// <summary>
        /// Create a list of Microsoft Band Temperature objects from the data read from the csv file selected by the user.
        /// </summary>
        /// <param name="csvReader">csv reader object</param>
        /// <param name="patientData">Patient data record that will be referenced by each microsoft band temperature data record.</param>
        /// <param name="date">Date the data in the file was collected.</param>
        /// <returns></returns>
        public static List<MSBandTemperature> BuildMSBandTemperatureDataList(CsvReader csvReader, PatientData patientData, DateTime date)
        {
            List<MSBandTemperature> msBandTemperatureData = null;

            if (csvReader != null && patientData != null && patientData.Id != null) {
                msBandTemperatureData = new List<MSBandTemperature>();

                while (csvReader.ReadNextRecord()) {
                    if (csvReader != null) {
                        //File should read in the following order.
                        //Date | Temperature
                        string dateFormat = "HH:mm:ss";
                        string dateInfo = csvReader[0];
                        DateTime dateTime;
                        if (DateTime.TryParseExact(dateInfo, dateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime)) {
                            date = new DateTime(date.Year, date.Month, date.Day, dateTime.Hour, dateTime.Minute, dateTime.Second);
                            MSBandTemperature msBandTemperature = new MSBandTemperature() {
                                Date = date,
                                Temperature = (float)Convert.ToDouble(csvReader[1]),
                                PatientDataId = patientData.Id
                            };
                            msBandTemperatureData.Add(msBandTemperature);
                        }
                    }
                }
            }

            return msBandTemperatureData;
        }