I have two list that come from form one contains people name and the other one city
Like this
public IActionResult Index([FromForm] List<string> people,[FromForm] List<string> city)
{
}
Now let's say that I have three people John, Sarah and tom
And i have four cities London, Paris, DC, Rome
So, if the user choose John and Sarah and London, Paris, DC for city
This means John have all three cities and also Sarah have all three cities
What I want is combine the two lists (people and city) together to get this result which for each person chosen they will have all cities chosen like the example I provided above
I tried using Dictionary but since it must have unique key it didn't work and tried also ZIP but it doesn't do what I want.
Is there a way I can achieve this !!
what I tried so far
public IActionResult Index([FromForm] List<string> people,[FromForm] List<string> city)
{
List<person> personInfo = =new List<person>();
var results =people.Zip(city).ToList();
for(int i=0;i<results.Count;i++)
{
personInfo.add(new person()
{
name=results[i].First,
city=results[i].Second
}
}
}