Ejemplo n.º 1
0
        public async Task<IHttpActionResult> CsvUpload()
        {
            if (!Request.Content.IsMimeMultipartContent())
                throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);

            var provider = new MultipartMemoryStreamProvider();
            await Request.Content.ReadAsMultipartAsync(provider);
            foreach (var file in provider.Contents)
            {
                //var filename = file.Headers.ContentDisposition.FileName.Trim('\"');
                string buffer = await file.ReadAsStringAsync();

                var parser = new CsvStatementParser();
                var entries = parser.Parse(buffer);

                if (entries != null && entries.Count > 0)
                    repository.BatchInsertOrUpdate(1, entries, true);
            }

            return Ok();
        }
Ejemplo n.º 2
0
 public void ParseTest()
 {
     var parser = new CsvStatementParser();
     var list = parser.Parse(Properties.Resources.UBankStatement);
     Assert.IsTrue(list.Count > 0);
 }