Exemplo n.º 1
0
        public async Task <ActionResult> GetAsync(IFormFile file, [FromServices] IExcelConverterService service)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (file == null)
            {
                return(BadRequest(new string[] { "There is no file in 'file' parameter in body." }));
            }

            string temporaryFilePath = Path.GetTempFileName();

            if (file.Length > 0)
            {
                using (FileStream stream = new FileStream(temporaryFilePath, FileMode.Create))
                {
                    await file.CopyToAsync(stream);

                    return(Ok(service.ConvertExcelToDictionary(stream)));
                }
            }

            return(BadRequest(new string[] { "The provided file is zero-byte length." }));
        }
Exemplo n.º 2
0
 public DataController(INasaService nasaService, IExcelConverterService excelConverter)
 {
     this.nasaService    = nasaService;
     this.excelConverter = excelConverter;
 }
Exemplo n.º 3
0
 public HomeController(INasaService nasaService, IExcelConverterService excelConverter, IMapper mapper)
 {
     this.nasaService    = nasaService;
     this.excelConverter = excelConverter;
     this.mapper         = mapper;
 }