public ActionResult DownloadFile(string id)
 {
     if (!string.IsNullOrWhiteSpace(id))
     {
         var model = FileModel.GetById(id);
         if (model != null)
         {
             if (System.IO.File.Exists(model.Path))
             {
                 return(new FilePathResult(model.Path, model.MIME)
                 {
                     FileDownloadName = model.FileName
                 });
             }
         }
     }
     return(RedirectToAction("UploadList"));
 }
        protected override ValidationResult IsValid(object filesToValidate, ValidationContext validationContext)
        {
            var filemodel = validationContext.ObjectInstance as FileModel;

            if (filemodel != null)
            {
                var files = filesToValidate as IEnumerable <HttpPostedFileBase>;
                if (files == null)
                {
                    //Valid, mert már fel lett töltve?
                    var dbFileModel = FileModel.GetById(filemodel.Id);
                    if (dbFileModel.Status == FileModel.UploadStatus.Temp)
                    {
                        return(ValidationResult.Success);
                    }

                    return(NoFiles());
                }

                foreach (var postedFile in files)
                {
                    if (postedFile == null)
                    {
                        return(NoFiles());
                    }

                    if (postedFile.ContentLength > _maxlength)
                    {
                        return(new ValidationResult(string.Format("A {0} fájl nagyobb, mint {1}KB!", postedFile.FileName, _maxlength / 1024)));
                    }
                    //A kliensben nem bízunk.
                    if (!UsableFileTypes.Contains(postedFile.ContentType))
                    {
                        return(new ValidationResult("Ilyen fájltípus nem tölthető fel!"));
                    }
                }
            }
            return(ValidationResult.Success);
        }