Ejemplo n.º 1
0
        protected async Task InitTestDataAsync()
        {
            var tgFile = "Resources/sample-talkgroups.csv";

            using (var bulkImportService = new BulkImportService(DbContext))
            {
                var result = await bulkImportService.ImportTalkGroupsCsvAsync(tgFile);

                if (!result.IsSuccessful)
                {
                    throw new Exception("Failed to initialize test data.");
                }
            }
        }
Ejemplo n.º 2
0
        public async Task <TalkGroupImportResults> ImportTalkGroupsAsync()
        {
            var tempFilePath = Path.GetTempFileName();

            try
            {
                using (var fs = new FileStream(tempFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read, 2048, true))
                {
                    await HttpContext.Request.Body.CopyToAsync(fs);

                    using (var bulkImportService = new BulkImportService(DbContext))
                        return(await bulkImportService.ImportTalkGroupsCsvAsync(tempFilePath));
                }
            }
            finally
            {
                if (System.IO.File.Exists(tempFilePath))
                {
                    System.IO.File.Delete(tempFilePath);
                }
            }
        }