0

So I create this list in two different locations. The first location creates it correctly its supposed to have 62 items in it like so. enter image description here

But for some reason when I add it to the second PostSoftware action result I get the following with the exact same code. enter image description here

The code is as follows

public ActionResult Software(TicketModel model)
        {
            ViewBag.Message = "Request software through the Tech Bar.";
            
            var snow = new clsServNowAuth();
            var tbl = clsServNowAuth.SoftwareTable();
            var tbl2 = clsServNowAuth.SoftwareTableID();
            tbl.Wait();
            tbl2.Wait();
            model.softwareList = tbl.Result;
            model.softwareListID = tbl2.Result;
            List<string> lstUserInfo = clsADInterface.GetInfo(model);
            List<string> softwareList = model.softwareList;

            if (String.IsNullOrEmpty(model.computerName) || String.IsNullOrEmpty(model.businessJustification))
            {
                // TODO
                return View(model);
            }
            
            return RedirectToAction("PostSoftware", model);
        }

        public ActionResult PostSoftware(TicketModel model)
        {
            List<string> softwareList = model.softwareList;
            //var test = model.selectedSoftwareList;
            List<string> softwareListID = new List<string>();
            foreach (var item in model.selectedSoftwareList)
            {
                int index = softwareList.FindIndex(a => a.Contains(item));
                softwareListID.Add(model.softwareListID[index]);
            }
            // submit software request
            clsServNowAuth.SoftwareRequest(model.computerName, model.businessJustification, softwareListID, model.lstUserInfo);
            return View(model);
        }
    }
E_net4
  • 27,810
  • 13
  • 101
  • 139
  • Probably need to show the code that builds the model in the html, and posts it back to the second endpoint. Looks like you are calling `ToString()` somewhere (directly or indirectly) instead of iterating the list. – Jonesopolis Jun 08 '22 at 14:06
  • `model` is of type `TicketModel` in your first snippet too? Could you add the first methods signature, please? – nilsK Jun 08 '22 at 14:07
  • @nilsK I fixed it so it shows the code right – MystifiedSky Jun 08 '22 at 14:35
  • I am not doing anything in the HTML with the models I think I need to define it as a list in the html too so it doesnt auto put as a string but not sure how to @Jonesopolis – MystifiedSky Jun 08 '22 at 14:35

0 Answers0