Beispiel #1
0
 /// <summary>
 /// Create a new FileStore object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="directory">Initial value of the Directory property.</param>
 /// <param name="mimeType">Initial value of the MimeType property.</param>
 /// <param name="originalName">Initial value of the OriginalName property.</param>
 /// <param name="contentLength">Initial value of the ContentLength property.</param>
 /// <param name="extension">Initial value of the Extension property.</param>
 public static FileStore CreateFileStore(global::System.Int32 id, global::System.String directory, global::System.String mimeType, global::System.String originalName, global::System.Int32 contentLength, global::System.String extension)
 {
     FileStore fileStore = new FileStore();
     fileStore.Id = id;
     fileStore.Directory = directory;
     fileStore.MimeType = mimeType;
     fileStore.OriginalName = originalName;
     fileStore.ContentLength = contentLength;
     fileStore.Extension = extension;
     return fileStore;
 }
Beispiel #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the FileStores EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToFileStores(FileStore fileStore)
 {
     base.AddObject("FileStores", fileStore);
 }
Beispiel #3
0
        private FileStore SaveFile(HttpPostedFileBase file, string folderPath)
        {
            try
            {
                var fs = new FileStore
                             {
                                 Extension = new FileInfo(file.FileName).Extension,
                                 MimeType = file.ContentType,
                                 Directory = folderPath,
                                 ContentLength = file.ContentLength,
                                 OriginalName = file.FileName
                             };
                _db.FileStores.AddObject(fs);
                _db.SaveChanges();

                file.SaveAs(fs.FilePath);

                return fs;
            }
            catch
            {
                return null;
            }
        }