Ejemplo n.º 1
0
        public async Task <MultipleOperationsResult> UploadFilesAsync(HttpContent content, HttpContext httpContext)
        {
            _userUploadsPath = new Lazy <string>(() => _directoryInfoProvider.GetUserUploadsPath(httpContext));

            var provider = new MultipartMemoryStreamProvider();

            await content.ReadAsMultipartAsync(provider);

            var uploadOperationResult = new MultipleOperationsResult();

            provider.Contents.ForEach(async fileHttpContent =>
            {
                var res = await TryProcesFileAsync(fileHttpContent);
                uploadOperationResult.AddFileResult(res);
            });

            return(uploadOperationResult);
        }
Ejemplo n.º 2
0
        private bool SetInitialTempData(ICollection <MetroStation> data)
        {
            if (data.Count != 0)
            {
                return(false);
            }

            var directory = _directoryInfoProvider.GetUserUploadsPath(HttpContext.Current);
            var fileName  = _directoryInfoProvider.GetTestSeedDataFileName();
            var path      = string.Format("{0}{1}", directory, fileName);

            var parseResults         = _textFileParser.TryParseFile(path);
            var successfulOperations = parseResults.SuccessfulOperations;
            var stations             = successfulOperations.Select(x => ((StationParsingResult)x).Entity);

            _metroStationStorage.AddRange(stations);

            return(true);
        }