public static IFileBlobManager CreateEdit(uint blobID)
        {
            using (var db = DB.GetContext())
            {
                FileBlobManager manager = new FileBlobManager();
                manager.ActiveModel           = FileBlobRepository.GetBlob(db, blobID);
                manager.CreationInfo.DriverID = manager.ActiveModel.DriverID;

                return(manager);
            }
        }
        public CheckResult PreviewFile(FileBlobViewModel model)
        {
            CheckResult res = new CheckResult(model);

            using (var db = DB.GetContext())
            {
                var file = FileBlobRepository.GetBlob(db, model.BlobID);
                if (file == null)
                {
                    res.AddError("No such file!", string.Empty);
                    return(res);
                }

                string directory = Path.Combine(Environment.CurrentDirectory, "files");
                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }

                string fileName = Path.Combine(directory, ExtensionMethods.SafeFileName(file.BlobName) + file.BlobExtension);
                if (File.Exists(fileName))
                {
                    try
                    {
                        File.Delete(fileName);
                    }
                    catch (Exception ex)
                    {
                        return(new CheckResult(ex));
                    }
                }

                try
                {
                    File.WriteAllBytes(fileName, file.BlobData);
                    ProcessStartInfo info = new ProcessStartInfo(fileName);
                    info.UseShellExecute = true;
                    Process.Start(info);
                    return(res);
                }
                catch (Exception ex)
                {
                    return(new CheckResult(ex));
                }
            }
        }