private static bool IsVideo(FileExtraData extraData)
 {
     // check if the file is a video
     return extraData.FileType.StartsWith("video");
 }
        private bool SaveFile(string filePath, string filename, FileExtraData data)
        {
            var file = new FileModel
            {
                Title = data.Title,
                Author = data.Author,
                Email = data.Email,
                Location = data.Location,
                FreeTags = data.FreeTags,
                Created = DateTime.Now,
                File = System.IO.File.ReadAllBytes(filePath),
                FileName = filename,
                FileType = data.FileType,
                Contest = _cuDataContext.Attributes.FirstOrDefault(a => a.Id == data.ContestId)
            };

            // check to resize the images
            if (IsImage(data))
            {
                file.ImageThumbnail = ResizeImage(filePath, ImageType.Thumbnail);
                file.ImageList = ResizeImage(filePath, ImageType.List);
                file.ImageDetail = ResizeImage(filePath, ImageType.Detail);
            }

            // add the new file
            _cuDataContext.Files.Add(file);

            // save
            return _cuDataContext.SaveChanges() != 0;
        }
 private static bool IsImage(FileExtraData extraData)
 {
     // check if the file is an image
     return extraData.FileType.StartsWith("image");
 }