/// <summary> /// Open therapist window /// </summary> public void OpenAddTherapistWindow() { if (_group == null || _group.Length < 1 || _indiv == null | _indiv.Length < 1) { return; } var dialog = new Dialog.Dialog(); dialog.Title = "Add New Therapist"; dialog.QuestionText = "Please give a name to the new therapist."; if (dialog.ShowDialog() == true) { try { string mKeySetName = dialog.ResponseText; therapistListViewModel.AllTherapists.Add(Therapist.CreateTherapist(mKeySetName)); using (StreamWriter file = new StreamWriter(Path.Combine(Properties.Settings.Default.SaveLocation, _group, _indiv, "Therapists.json"), false)) { Therapists mCollector = new Therapists(); mCollector.PrimaryTherapists = therapistListViewModel.AllTherapists; file.WriteLine(JsonConvert.SerializeObject(mCollector)); } MessageBox.Show("Successfully added: " + dialog.ResponseText); } catch (IOException e) { Console.WriteLine(e.ToString()); } } }
/// <summary> /// Default constructor /// </summary> public TherapistRepository() { if (_mCollObj == null) { _mCollObj = new Therapists(); _mCollObj.PrimaryTherapists = new ObservableCollection <Therapist>(); } }
/// <summary> /// Build collection /// </summary> /// <param name="groupName"></param> /// <param name="indivName"></param> /// <returns></returns> public ObservableCollection <Therapist> GetCollectors(string groupName, string indivName) { var target = Properties.Settings.Default.SaveLocation + "\\" + groupName + "\\" + indivName + "\\PrimaryTherapists.json"; if (File.Exists(@target)) { _mCollObj = JsonConvert.DeserializeObject <Therapists>(target); } return(new ObservableCollection <Therapist>(_mCollObj.PrimaryTherapists)); }
/// <summary> /// Parse JSON file if exists /// </summary> /// <param name="groupName"></param> /// <param name="indivName"></param> public void RefreshRepository(string groupName, string indivName) { var target = Properties.Settings.Default.SaveLocation + "\\" + groupName + "\\" + indivName + "\\Therapists.json"; if (File.Exists(@target)) { string mInput = File.ReadAllText(@target); Therapists items = JsonConvert.DeserializeObject <Therapists>(mInput); AllTherapists.Clear(); foreach (Therapist item in items.PrimaryTherapists) { AllTherapists.Add(item); } } }
public void AddTherapists(List <TherapistUser> therapists) => therapists.ForEach(t => Therapists.Add(t));
public void AddTherapist(Therapist therapist) => Therapists.Add(new TherapistUser() { Therapist = therapist, TherapistId = therapist.TherapistId, User = this, UserId = this.UserId });
public static bool Register(Therapists1 t) { Therapists therapist = Therapists1.Todal(t); return(Dal.TherapistsDal.Register(therapist)); }