Exemplo n.º 1
0
        public async Task <IActionResult> Import(ImportVM formFile)
        {
            TempData["url"] = "bankacount";
            // upload
            var filePath = Path.GetTempFileName();

            using (var stream = new FileStream(filePath, FileMode.Create))
            {
                await formFile.Myfile.CopyToAsync(stream);
            }

            var list = ExcelComunication.DataTableToBankAccount(ExcelComunication.ExcelToDataTable(filePath));

            _context.BankAccount.AddRange(list);
            await _context.SaveChangesAsync();

            await _context.Database.ExecuteSqlCommandAsync("modify_banks_transaction");

            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Import(ImportVM formFile)
        {
            var batch = _context.OriginalListing.OrderByDescending(v => v.Batch).Where(c => c.Year == formFile.Year).FirstOrDefault()?.Batch ?? 0;

            batch++;
            // upload
            var filePath = Path.GetTempFileName();

            using (var stream = new FileStream(filePath, FileMode.Create))
            {
                await formFile.Myfile.CopyToAsync(stream);
            }

            var list = ExcelComunication.DataTableTooriginal_listing(ExcelComunication.ExcelToDataTable(filePath), formFile.Year, batch);

            _context.OriginalListing.AddRange(list);
            await _context.SaveChangesAsync();

            await _context.Database.ExecuteSqlCommandAsync("init_transaction");

            return(RedirectToAction("Index"));
        }