using System;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.Collections.Generic;

namespace WebSamples.Services
{
    [ServiceContract(Namespace = "")]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class GeoCityExpositionService
    {
        #region Private Fields

        GeoCityService geoCityService = new GeoCityService();

        #endregion

        [OperationContract]
        public List<ExposedEntities.ExposedGeoCity> GetAllNearbyCities(double lat, double lng, int radius)
        {
            return this.geoCityService.GetCitiesNearBy(lat, lng, radius)
                       .Select(c => ExposedEntities.Translators.ExposedGeoCityTranslator.ToExpositionEntity(c))
                       .ToList();
        }

        [OperationContract]
        public List<ExposedEntities.ExposedGeoCity> GetCitiesBounded(double topLeftLat, double topLeftLong, 
                                                                     double botRightLat, double botRightLong)
        {
            return this.geoCityService.GetCitiesBounded(topLeftLat, topLeftLong,
                                                        botRightLat, botRightLong)
                       .Select(c => ExposedEntities.Translators.ExposedGeoCityTranslator.ToExpositionEntity(c))
                       .ToList();
        }

    }
}
