Example #1
0
        public static void UpdateFile(string filename, HttpRequestBase Request, AssessTrack.Models.File file)
        {
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }
            if (Request.Files[filename] == null || Request.Files[filename].ContentLength == 0)
            {
                return;
            }
            string mimeType = Request.Files[filename].ContentType;
            Stream fileStream = Request.Files[filename].InputStream;
            string fileName = Path.GetFileName(Request.Files[filename].FileName);
            int fileLength = Request.Files[filename].ContentLength;
            byte[] fileData = new byte[fileLength];
            fileStream.Read(fileData, 0, fileLength);

            file.Data = new System.Data.Linq.Binary(fileData);
            file.Mimetype = mimeType;
            file.OwnerID = UserHelpers.GetCurrentUserID();
            file.Name = fileName;
        }
Example #2
0
 public static void SaveFile(AssessTrackDataRepository repo, AssessTrack.Models.File file)
 {
     if (file == null)
         return;
     repo.SaveFile(file);
 }