public static void Save(this TimeEntry model, IDataService dataService)
        {
            Chronos  chronos = null;
            FileInfo info    = model.EnsureFile(dataService);

            if (!dataService.TryRead <Chronos>(info.FullName, out chronos, out string message))
            {
                chronos = new Chronos().Default();
            }
            chronos.Items.Add(model);
            if (!dataService.TryWrite <Chronos>(chronos, out string writeerror, info.FullName))
            {
                MessageBox.Show(writeerror);
            }
        }
        public static FileInfo EnsureFile(this TimeEntry model, IDataService dataService)
        {
            DirectoryInfo directory = new DirectoryInfo(AppConstants.ChronosDirectory);

            if (!directory.Exists)
            {
                directory.Create();
            }

            FileInfo info = new FileInfo(Path.Combine(directory.FullName, model.Filename()));

            if (!info.Exists)
            {
                Chronos chronos = new Chronos().Default();
                if (!dataService.TryWrite(chronos, out string message, info.FullName))
                {
                    MessageBox.Show(message);
                }
            }
            return(info);
        }
 public static Chronos Default(this Chronos model)
 {
     model.CreatedAt = DateTime.Now;
     return(model);
 }