public void DeleteHBOperation(OneHB delHB)
        {
            try
            {
                string newJson = "";

                CheckFileExists(resourceFolderPath + HBFileName);

                using (StreamReader r = new StreamReader(resourceFolderPath + HBFileName))
                {
                    string       json  = r.ReadToEnd();
                    List <OneHB> today = JsonConvert.DeserializeObject <List <OneHB> >(json);
                    if (today == null)
                    {
                        return;
                    }
                    else
                    {
                        bool tryDell = today.Remove(today.Where(x => (x.Date.Year == delHB.Date.Year && x.Date.Year == delHB.Date.Year && x.Date.Year == delHB.Date.Year && x.FullName == delHB.FullName)).FirstOrDefault());
                    }
                    newJson = JsonConvert.SerializeObject(today);
                }

                File.WriteAllText(resourceFolderPath + HBFileName, newJson);
            }
            catch { }
        }
        public void AddHBOperation(OneHB newHB)
        {
            try
            {
                string newJson = "";

                CheckFileExists(resourceFolderPath + HBFileName);

                using (StreamReader r = new StreamReader(resourceFolderPath + HBFileName))
                {
                    string       json  = r.ReadToEnd();
                    List <OneHB> today = JsonConvert.DeserializeObject <List <OneHB> >(json);
                    if (today != null)
                    {
                        today.Add(newHB);
                    }
                    else
                    {
                        if (today == null)
                        {
                            today = new List <OneHB>();
                        }
                        today.Add(new OneHB()
                        {
                            Date     = newHB.Date,
                            FullName = newHB.FullName
                        });
                    }
                    newJson = JsonConvert.SerializeObject(today);
                }

                File.WriteAllText(resourceFolderPath + HBFileName, newJson);
            }
            catch {}
        }
        protected CalendarTabViewModel()
        {
            CurrentDate      = Resources.todayLabel + DateTime.Today.ToString("d");
            ShowTasksLabel   = Resources.showTasksLabel;
            TaskFlyoutIsOpen = false;
            HBFlyoutIsOpen   = false;
            TaskHeight       = 0;

            NewTask = new OneTask();

            SearchDate = DateTime.Today;
            DayTasks   = CalendarRepository.Instance.GetByDay(DateTime.Today).DailyTasks;

            try
            {
                SetRandomImage();
            }
            catch (Exception exc)
            {
                throw exc;
            }

            NewHB = new OneHB {
                Date = DateTime.Today, FullName = ""
            };

            SetNotificationTimer();
        }
 public void ExecuteAddHBCommand(object parametr)
 {
     CalendarRepository.Instance.AddHBOperation(NewHB);
     NewHB          = new OneHB();
     NewHB.Date     = DateTime.Today;
     DaysHB         = CalendarRepository.Instance.GetHBByDay(SearchDate);
     HBFlyoutIsOpen = false;
 }
 public void ExecuteDellHBCommand(object parametr)
 {
     CalendarRepository.Instance.DeleteHBOperation(SelectedHB);
     SelectedHB = new OneHB();
     DaysHB     = CalendarRepository.Instance.GetHBByDay(SearchDate);
 }