using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using AjaxDestinations.Models;

namespace AjaxDestinations
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "PackagesService" in code, svc and config file together.
    public class PackagesService : IPackagesService
    {
        private gcutourswmEntities db = new gcutourswmEntities();

        public List<String> Locations()
        {
            var locations = (from p in db.Packages
                             select p.location).Distinct().ToList();

            return locations;
        }

        public List<DateTime?> TourDates(String location)
        {
            var tourDates = (from t in db.Tours
                             where t.Package.location == location
                             select t.departuredate).ToList();

            //var utcTourDates = new List<DateTime>();
            //foreach (DateTime? d in tourDates)                  // convert to Utc dates so that serialised value contains ticks only, not local offset
            //{
            //    if (d != null) utcTourDates.Add(DateTime.SpecifyKind(d.Value, DateTimeKind.Utc));
            //}

            return tourDates;
        }
    }
}
