private static string ConvertToXml(ReservationData reservationData) { StringWriter textWriter = new StringWriter(); XmlSerializer x = new XmlSerializer(reservationData.GetType()); x.Serialize(textWriter, reservationData); return(textWriter.ToString()); }
public string ReturnReservation(String format, String login) { format = format.ToLower(); ReservationData reservationData = new ReservationData(login); if (format == "xml") { return(ConvertToXml(reservationData)); } else { return(ConvertToJson(reservationData)); } }
private static string ConvertToJson(ReservationData reservationData) { string returnJson = JsonConvert.SerializeObject(reservationData); return(returnJson); }