Exemplo n.º 1
0
        public static Boolean DeleteFileData(RayimContext context, int fileId)
        {
            FileMetaData dbFileData = context.FileMetaDatas.FirstOrDefault(x => x.Id == fileId);

            if (dbFileData != null)
            {
                if (!string.IsNullOrEmpty(dbFileData.FilePath))
                {
                    IOFileService.DeleteFile(dbFileData.FilePath);
                }
                context.FileMetaDatas.Remove(dbFileData);
                context.SaveChanges();
            }
            return(dbFileData != null);
        }
Exemplo n.º 2
0
 private static void ProcessOldData(RayimContext context, FileMetaDataModel model, string fileData)
 {
     if (model.Id > 0)
     {
         FileMetaData dbFileData = context.FileMetaDatas.FirstOrDefault(x => x.Id == model.Id) ?? new FileMetaData();
         if (!string.IsNullOrEmpty(fileData) && !string.IsNullOrEmpty(dbFileData.FilePath))
         {
             IOFileService.DeleteFile(dbFileData.FilePath);
         }
         if (string.IsNullOrEmpty(fileData))
         {
             model.FilePath = dbFileData.FilePath;
         }
     }
 }