Beispiel #1
0
        public void DeleteFile(File file)
        {
            foreach (var courseTerm in file.CourseTerms)
            {
                courseTerm.Syllabus = null;
            }

            dc.CourseTermFiles.DeleteAllOnSubmit(file.CourseTermFiles);

            dc.Files.DeleteOnSubmit(file);

            dc.SubmitChanges();
        }
Beispiel #2
0
        public static AssessTrack.Models.File GetFile(string filename, HttpRequestBase Request)
        {
            if (Request.Files[filename] == null || Request.Files[filename].ContentLength == 0)
            {
                return null;
            }
            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);

            AssessTrack.Models.File file = new AssessTrack.Models.File();

            file.Data = new System.Data.Linq.Binary(fileData);
            file.Mimetype = mimeType;
            file.OwnerID = UserHelpers.GetCurrentUserID();
            file.Name = fileName;

            return file;
        }
Beispiel #3
0
 public void SaveFile(File file)
 {
     dc.Files.InsertOnSubmit(file);
     //dc.SubmitChanges();
 }