/// <inheritdoc /> public override IValidationModel BuildValidationModel(IElementValidatable targetElement) { MultipleFileUploadElementBlock uploadElementBlock = targetElement as MultipleFileUploadElementBlock; if (uploadElementBlock == null) { return(base.BuildValidationModel(targetElement)); } if (this._model == null) { MaxNumberOfFilesValidationModel sizeValidationModel = new MaxNumberOfFilesValidationModel(); sizeValidationModel.MaxNoOfFiles = uploadElementBlock.MaxNumberOfFiles; string str = string.Format(this._validationService.Service.GetValidatorMessage(this.GetType(), ""), uploadElementBlock.MaxNumberOfFiles); sizeValidationModel.Message = str; this._model = (IValidationModel)sizeValidationModel; } return(this._model); }
/// <inheritdoc /> public override IValidationModel BuildValidationModel(IElementValidatable targetElement) { MultipleFileUploadElementBlock uploadElementBlock = targetElement as MultipleFileUploadElementBlock; if (uploadElementBlock == null) { return(base.BuildValidationModel(targetElement)); } if (this._model == null) { var sizeValidationModel = new TotalMaxFileSizeValidationModel { TotalSizeInBytes = uploadElementBlock.TotalSizeInBytes }; string str = string.Format(this._validationService.Service.GetValidatorMessage(this.GetType(), ""), uploadElementBlock.TotalFileSize == 0 ? uploadElementBlock.TotalSizeInBytes / 1048576 : uploadElementBlock.TotalFileSize); sizeValidationModel.Message = str; this._model = (IValidationModel)sizeValidationModel; } return(this._model); }
/// <inheritdoc /> public override bool?Validate(IElementValidatable targetElement) { MultipleFileUploadElementBlock uploadElementBlock = targetElement as MultipleFileUploadElementBlock; if (uploadElementBlock == null) { return(true); } IEnumerable <HttpPostedFile> submittedValue = targetElement.GetSubmittedValue() as IEnumerable <HttpPostedFile>; if (submittedValue == null || submittedValue.Count() == 0) { return(true); } var flag = true; var numberOfFiles = submittedValue.Count(); if (numberOfFiles > uploadElementBlock.MaxNumberOfFiles) { flag = false; } return(flag); }
/// <inheritdoc /> public override bool?Validate(IElementValidatable targetElement) { MultipleFileUploadElementBlock uploadElementBlock = targetElement as MultipleFileUploadElementBlock; if (uploadElementBlock == null) { return(true); } IEnumerable <HttpPostedFile> submittedValue = targetElement.GetSubmittedValue() as IEnumerable <HttpPostedFile>; if (submittedValue == null || submittedValue.Count <HttpPostedFile>() == 0) { return(true); } var flag = true; var totalFileSizeBytes = submittedValue.Sum(x => x.ContentLength); if (totalFileSizeBytes > uploadElementBlock.TotalSizeInBytes) { flag = false; } return(flag); }