I have to display the list of AvailabilityOutbound and AvailabilityReturn having multiple records i.e AvailabilityFlight of each in index page of asp.net mvc. The structure for the model classes and controller method is below. I didn't get any idea how to proceed next. The below class is generated via XML response from SOAP asmx service and then mapped to C# Classes.
[XmlRoot(ElementName = "AvailabilityOutbound")]
public class AvailabilityOutbound
{
[XmlElement(ElementName = "AvailabilityFlight")]
public List<AvailabilityFlight> AvailabilityFlight { get; set; }
}
[XmlRoot(ElementName = "AvailabilityReturn")]
public class AvailabilityReturn
{
[XmlElement(ElementName = "AvailabilityFlight")]
public List<AvailabilityFlight> AvailabilityFlight { get; set; }
}
[XmlRoot(ElementName = "Availability")]
public class Availability
{
[XmlElement(ElementName = "AvailabilityOutbound")]
public AvailabilityOutbound AvailabilityOutbound { get; set; }
[XmlElement(ElementName = "AvailabilityReturn")]
public AvailabilityReturn AvailabilityReturn { get; set; }
}
[XmlRoot(ElementName = "AvailabilityFlight")]
public class AvailabilityFlight
{
[XmlElement(ElementName = "airline_rcd")]
public string Airline_rcd { get; set; }
[XmlElement(ElementName = "flight_number")]
public string Flight_number { get; set; }
[XmlElement(ElementName = "booking_class_rcd")]
public string Booking_class_rcd { get; set; }
[XmlElement(ElementName = "boarding_class_rcd")]
public string Boarding_class_rcd { get; set; }
}
The controller method where data need to be displayed is:
public ActionResult Index(string xmlResult)
{
var ser = new XmlSerializer(typeof(Availability));
using (var sr = new StringReader(xmlResult))
{
var obj = (Availability)ser.Deserialize(sr);
return //
}
//no idea how can i map the records to view
return View();
}
and the view as:
@model IEnumerable<Project.Models.AvailabilityFlight>
I need guidance on passing the list to view and displaying the records in index view with few sample code snippets for view and index method.
AvailabilityFlightinAvailabilityOutboundorAvailabilityReturnininAvailabilityin view?