示例#1
0
        public async Task <IActionResult> UploadCsv([FromQuery] EntryType entryType)
        {
            var form = HttpContext.Request.Form;

            if (form.Files.Any())
            {
                var file = form.Files.First();

                var formDict = form.ToDictionary(g => g.Key, g => g.Value.ToString());

                using var fileStream = file.OpenReadStream();

                var email         = User.GetEmail();
                var refuelEntries = await _carLogic.ImportCsv(email, fileStream, formDict, entryType);

                if (refuelEntries == null)
                {
                    return(NotFound());
                }
                return(Ok(refuelEntries));
            }
            return(BadRequest());
        }