//public void UpdateFileMeta(BufferFileMeta oldMeta, BufferFileMeta newMeta) //{ // string id = GetStringIdFromFilename(oldMeta); // var existingFile = _database.FileStorage.Find(id).FirstOrDefault(q => GetMetadataFromAttachment(q.Metadata).ParentId == oldMeta.ParentId); // if (existingFile == null) // { // _log.Warn($"Cannot change meta for {id}. File cannot be found"); // return; // } // existingFile.Metadata = GetMetadataFromAttachment(newMeta); //} public List <KeyValuePair <DateTime, string> > GetAttachmentNamesFromItem <T>(int id) { // TODO: New stuff var matches = new List <KeyValuePair <DateTime, string> >(); string prefix = GetStringIdFromFilename(new BufferFileMeta { AttachmentType = BufferFileMeta.AttachmentTypes.Attachment, ParentId = id, Listname = _helpers.GetListName <T>() }, true); var files = _database.FileStorage.Find(prefix); if (matches == null) { return(null); } foreach (var file in files) { if (GetMetadataFromAttachment(file.Metadata).ParentId == id) { matches.Add(new KeyValuePair <DateTime, string>(file.UploadDate, file.Filename)); } } return(matches); }
private BufferFileMeta GetMetaForFile <T>(BufferFileMeta.AttachmentTypes attachmentType, string filename, int parentId) { return(new BufferFileMeta { AttachmentType = attachmentType, Filename = filename, Listname = _helpers.GetListName <T>(), ParentId = parentId }); }