Ejemplo n.º 1
0
        public async Task <IActionResult> Import()
        {
            var file   = Request.Form.Files.FirstOrDefault();
            var result = await _bizRevoke.InsertFromFileAsync(file);

            return(ToResponse(result));
        }
Ejemplo n.º 2
0
        public async Task <JsonResult> Import()
        {
            var file = Request.Files[0];

            if (file == null)
            {
                return(ToJsonResponse(false, "Dữ liệu không hợp lệ"));
            }
            Stream stream = file.InputStream;

            stream.Position = 0;
            using (var fileStream = new MemoryStream())
            {
                await stream.CopyToAsync(fileStream);

                var results = await _bizRevokeDebt.InsertFromFileAsync(fileStream, GlobalData.User.IDUser);

                return(ToJsonResponse(results.IsSuccess, results.Message, results.Data));
            }
        }