Ejemplo n.º 1
0
        /// <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());
                }
            }
        }