public static TripViewModel Create(this IModelFactory factory, Trip model)
 {
     var trip = new TripViewModel
     {
         Id = model.Id,
         Name = model.Name,
         Created = model.Created
     };
     return trip;
 }
 public static Trip Create(this IModelFactory factory, TripViewModel model)
 {
     var trip = new Trip
     {
         Id = model.Id,
         Name = model.Name,
         UserName = "******",
         Created = model.Created,
         Stops = new List<Stop>()
     };
     return trip;
 }
        public static XDocument ToXml(this IModelFactory factory, TripViewModel trip)
        {
            var oDoc = new XDocument();
            var oRoot = new XElement("root");
            oRoot.SetAttributeValue("id", trip.Id);
            oRoot.SetAttributeValue("name", trip.Name);

            var tableStops = new XElement("table", new XAttribute("id", "stops"));

            foreach (var stop in trip.Stops)
            {
                var oRow = new XElement("row");

                oRow.Add(new XElement("item", new XAttribute("id", "id"), new XAttribute("value", stop.Id)),
                    new XElement("item", new XAttribute("id", "name"), new XAttribute("value", stop.Name)),
                    new XElement("item", new XAttribute("id", "arrival"), new XAttribute("value", stop.Arrival.ToString("MM/dd/yyyy"))));

                tableStops.Add(oRow);
            }

            oRoot.Add(tableStops);
            oDoc.Add(oRoot);
            return oDoc;
        }