public async Task <ImportResponse> ImportCsv() { if (!Request.Content.IsMimeMultipartContent()) { throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType); } ImportResponse response = new ImportResponse(); var provider = new MultipartMemoryStreamProvider(); await Request.Content.ReadAsMultipartAsync(provider); var file = provider.Contents.FirstOrDefault(); if (file != null) { response.Filename = file.Headers.ContentDisposition.FileName.Trim('\"'); string csv = await file.ReadAsStringAsync(); var csvService = new CsvService(ApplicationContext); response = csvService.ImportCsv(csv); } return(response); }