public List<LearnerInfo> ImportCSV(string csvPath)
        {
            List<LearnerInfo> learnerInfos = new List<LearnerInfo>();
            if (File.Exists(csvPath))
            {
                using (TextReader tr = new StreamReader(csvPath))
                {
                    string line = tr.ReadLine();
                    int lineNumber = 0;
                    while (line!=null)
                    {
                        string[] fields = line.Split(',');
                        if (fields.Length != 5 && !(lineNumber==0 ^ fields[0].ToLower().Equals("First Name")) ) return null;                // CSV MALFORMED
                        if (lineNumber > 0)     // the first line contains headers
                        {
                            LearnerInfo li = new LearnerInfo(fields[0], fields[1], fields[2], 0, fields[3], fields[4], 0);
                            learnerInfos.Add(li);
                            _db.AddStudent(li);
                        }
                        line = tr.ReadLine();
                        lineNumber++;

                    }
                }
            }
            return learnerInfos;
        }
 public bool RemoveLearnerFromLearnerModel(LearnerInfo learnerInfo)
 {
     if (_db != null)
     {
         _db.RemoveStudent(learnerInfo);
         return true;
     }
     return false;
 }
 public async Task<bool> AddLearnerToLearnerModel(LearnerInfo learnerInfo)
 {
     if (_db != null)
     {
         _db.AddStudent(learnerInfo);
         await Task.Delay(2000);
         await _db.GetAllStudentsAsync();
         return true;
     }
     return false;
 }
 private async void AddButton_OnClick(object sender, RoutedEventArgs e)
 {
     AddButton.IsEnabled = false;
     if (txtFirstName.Text != "" && txtLastName.Text != "" && DatePickerBirth.Text != "" &&
         cmbSex.SelectedItem != null && cmbSex.SelectedItem.ToString() != "")
     {
         string sex = cmbSex.SelectedIndex==0?"M":"F";
         if (DatePickerBirth.SelectedDate != null)
         {
             var learnerInfo = new LearnerInfo(txtFirstName.Text, txtMiddleName.Text, txtLastName.Text, 0, sex,
                 DatePickerBirth.SelectedDate.Value.ToShortDateString(), 0);
             if (await _controller.AddLearnerToLearnerModel(learnerInfo))
             {
                 _data.Learners.Add(learnerInfo);
             }
             else
             {
                 MessageBox.Show("Can't add the new Learner to the database", "Error", MessageBoxButton.OK,
                     MessageBoxImage.Error);
             }
         }
         else
         {
             MessageBox.Show("Please select a birth date", "Missing birth date", MessageBoxButton.OK,
                     MessageBoxImage.Warning);
         }
     }
     else
     {
         MessageBox.Show("All fields required", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
     AddButton.IsEnabled = true;
 }
 public void RemoveStudent(LearnerInfo learnerInfo)
 {
     // NOT YET IMPLEMENTED
 }
 public void AddStudent(LearnerInfo learnerInfo)
 {
     learnerInfo.thalamusLearnerId = learnerInfo.mapApplicationId = _nextThalamusId++;
     _client.LDBPublisher.SetLearnerInfo(learnerInfo.SerializeToJson());
 }