VacationItinerary.cs
//
// This code is part of GrapeCity Documents for Word samples.
// Copyright (c) GrapeCity, Inc. All rights reserved.
//
using System;
using System.IO;
using System.Drawing;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Linq;
using GrapeCity.Documents.Word;

namespace GcWordWeb.Samples
{
    // This data template sample generates a sample vacation itinerary.
    public class VacationItinerary
    {
        public GcWordDocument CreateDocx(int _ = 0)
        {
            // Sample data for the itinerary template:
            var data = new[]
            {
                new {
                    clientName = "Mark Louis",
                    clientPhoneNumber = "876-123-7546",
                    ItineraryStartDate = "01/12/2019",
                    ItineraryEndDate = "15/12/2019",
                    flightDetails = new {
                        arrivalDate = "01/12/2019",
                        arrivalAirlineName = "British Airways",
                        arrivalTime = "08:00 AM",
                        arrivalTerminal = "T1",
                        departureDate = "15/12/2019",
                        departureAirlineName = "British Airways",
                        departureArrivalTime = "10:00 PM",
                        departureArrivalTerminal = "T2"
                    },
                    hotelDetails = new {
                        checkinTime = "12:00 PM",
                        hotelName = "Awasi Patagonia",
                        hotelAddress = "12/13, Block Street",
                        hotelInclusion = "Cab Service",
                        checkOutTime = "11:00 AM"
                    },
                    activities = new [] {
                        new { activityDate ="03/12/2019", activityDestination = "Jungle", activity = "Jungle Safari", remarks = "Make sure to carry woolens"},
                        new { activityDate = "07/12/2019", activityDestination = "Spa Room", activity = "Spa Session", remarks = "Morning would be the best time"},
                        new { activityDate = "11/12/2019", activityDestination = "Gym Area", activity = "Yoga Session", remarks = "Wear a comfortable attire"}
                    }
                }
            };

            // Load the template DOCX, add the data source and process the template:
            var doc = new GcWordDocument();
            doc.Load(Path.Combine("Resources", "WordDocs", "Vacation_Itinerary_Template.docx"));
            doc.DataTemplate.DataSources.Add("ds", data);
            doc.DataTemplate.Process();

            // Done:
            return doc;
        }

        public static List<string[]> GetSampleParamsList()
        {
            return new List<string[]>()
            {
                new string[] { "@data-templates/Vacation Itinerary", "Generate a vacation itinerary from template", null },
                new string[] { "@use-data-tpl/Vacation Itinerary", "Generate a vacation itinerary from template", null },
            };
        }
    }
}