Esempio n. 1
0
        public async Task <VmFileUploadAuthorization> Authorize(VmFileUploadAuthorize model)
        {
            if (model.Type == FileUploadType.None)
            {
                throw new ErrorHandlerMiddleware.HttpStatusCodeException(HttpStatusCode.BadRequest, "Type required");
            }
            if (string.IsNullOrWhiteSpace(model.Name))
            {
                throw new ErrorHandlerMiddleware.HttpStatusCodeException(HttpStatusCode.BadRequest, "Name required");
            }
            if (model.Size <= 0)
            {
                throw new ErrorHandlerMiddleware.HttpStatusCodeException(HttpStatusCode.BadRequest, "Size required");
            }
            if (model.LastModifiedDate == default(DateTime))
            {
                throw new ErrorHandlerMiddleware.HttpStatusCodeException(HttpStatusCode.BadRequest, "LastModifiedDate required");
            }

            var result = await _fileUploadService.Authorize(model.Type, model.Name, model.Size, model.LastModifiedDate);

            return(VmFileUploadAuthorization.Build(result));
        }