public void AttachFile(byte[] data, FileReference fileData, SCORMObject obj)
        {
            List<FileReference> files = new List<FileReference>();
            if (obj.Files != null)
            {
                files.AddRange(obj.Files);
            }

            var db = MongoDB.Driver.MongoDatabase.Create(_ConnectionString);
            var gfs = new MongoGridFS(db);
            var id = Guid.NewGuid().ToString();
            using (var file = gfs.OpenWrite(id))
            {
                file.Write(data, 0, data.Length);
                file.Flush();
            }
            var fileInfo = gfs.FindOne(id);
            gfs.SetContentType(fileInfo, fileData.ContentType);
            fileData.FileId = id;
            files.Add(fileData);
            obj.Files = files;
        }
 public void Delete(SCORMObject id)
 {
     _DB.Delete(id);
 }
 public void AttachFile(Stream data, FileReference fileData, SCORMObject obj)
 {
     var rawData = new byte[data.Length];
     data.Read(rawData, 0, rawData.Length);
     AttachFile(rawData, fileData, obj);
 }
 public void Save(SCORMObject obj)
 {
     obj.Category = obj.Category.ToLower();
     _DB.Save(obj);
     _DB.CreateIndex(y => new { y.Description, y.Title, y.Category }, "objectIndex", true, Norm.Protocol.Messages.IndexOption.Ascending);
 }