示例#1
0
        public async Task <IActionResult> UploadAndProcess(IFormFile file)
        {
            var content = new List <String>();

            if (file != null && file.Length > 0)
            {
                if (SystemConstants.AcceptedExtensions.Contains(Path.GetExtension(file.FileName).ToUpperInvariant()))
                {
                    using (var Reader = new System.IO.StreamReader(file.OpenReadStream()))
                    {
                        string inputLine = "";
                        while ((inputLine = await Reader.ReadLineAsync()) != null)
                        {
                            content.Add(inputLine);
                        }
                        Reader.Close();
                    }
                    //Upload
                    var res = await MdApi.PostPNLAsync(content);

                    return(PartialView("_PartialPassengerList", res));
                }
                else
                {
                    return(BadRequest(new { Result = false, Message = "please upload txt only" }));
                }
            }
            return(BadRequest(new { Result = false, Message = "Empty file" }));
        }