public List<string> SplitCompanyIDs(ActivateViewModel aModel) { List<string> companyIDList = new List<string>(); if (aModel.CompanyID != null) { // Checks for new line and if file has a new line then replace \n\r and add a comma and split list items to a list if (aModel.CompanyID.Contains("\n")) { companyIDList = aModel.CompanyID.Replace("\r\n", ",").Split(',').ToList(); } else { companyIDList = aModel.CompanyID.Split(',').ToList(); var test = ""; } foreach (var item in companyIDList) { Console.WriteLine(item.ToString()); Console.WriteLine(companyIDList[0]); ; } } return companyIDList; }
public IActionResult UploadCompanyID(ActivateViewModel aModel, string fileText) { string textAreaCompanyID = Request.Form["CompanyID"]; ViewBag.CompanyIDTextArea = fileText; return RedirectToAction("Activate", "App"); }
public IActionResult UploadFile(ActivateViewModel aModel2) { using (System.IO.StreamReader reader = new System.IO.StreamReader(Request.Form.Files[0].OpenReadStream())) { string textArea = Request.Form["AxpTemplate"]; var content = reader.ReadToEnd(); var fileText = content.ToString(); return RedirectToAction("Activate", "App", new { fileText = fileText }); } }
//[HttpPost] public IActionResult Activate (ActivateViewModel aModel, string fileText) { List<string> companyIdList = new List<string>(); CompanyIDSplitterController splitter = new CompanyIDSplitterController(); companyIdList = splitter.SplitCompanyIDs(aModel); //ViewBag.CompanyID = companyIdList; ViewBag.AxpTemplateArea = fileText; return View(); //return View(); }