public List <ITrackingRecordEntity> GetAllRecords()
        {
            var trackingRecordEntities = new List <ITrackingRecordEntity>();
            var allFilesName           = DirectoryManager.GetAllFilesName(FolderPath);

            foreach (var fileName in allFilesName)
            {
                trackingRecordEntities.AddRange(TextFileTrackingRecordCreator.CreateFromFile(fileName));
            }

            return(trackingRecordEntities);
        }
        public void Delete(int id)
        {
            var trackingRecordEntity     = GetAllRecords().FirstOrDefault(te => te.Id == id);
            var textTrackingRecordEntity = trackingRecordEntity as TextTrackingRecordEntity;

            if (textTrackingRecordEntity != null)
            {
                var fileName = textTrackingRecordEntity.FileNameWithPath;

                var trackingRecordEntitiesFromFile  = TextFileTrackingRecordCreator.CreateFromFile(fileName);
                var trackingRecordEntityToBeUpdated = trackingRecordEntitiesFromFile.FirstOrDefault(tre => tre.Id == id);
                trackingRecordEntitiesFromFile.Remove(trackingRecordEntityToBeUpdated);

                TextFileTrackingRecordFileManager.UpdateContentOfFile(fileName, trackingRecordEntitiesFromFile);
            }
        }
        public void Update(ITrackingRecordEntity recordEntity)
        {
            var trackingRecordEntities   = GetAllRecords();
            var trackingRecordEntity     = trackingRecordEntities.FirstOrDefault(te => te.Id == recordEntity.Id);
            var textTrackingRecordEntity = trackingRecordEntity as TextTrackingRecordEntity;

            if (textTrackingRecordEntity != null)
            {
                var fileNameWithPath = textTrackingRecordEntity.FileNameWithPath;

                var trackingRecordEntitiesFromFile  = TextFileTrackingRecordCreator.CreateFromFile(fileNameWithPath);
                var trackingRecordEntityToBeUpdated = trackingRecordEntitiesFromFile.FirstOrDefault(tre => tre.Id == recordEntity.Id);
                trackingRecordEntitiesFromFile.Remove(trackingRecordEntityToBeUpdated);
                trackingRecordEntitiesFromFile.Add(recordEntity);

                TextFileTrackingRecordFileManager.UpdateContentOfFile(fileNameWithPath, trackingRecordEntitiesFromFile);
            }
        }