using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WebSamples.Services.Interfaces;
using WebSamples.Entities;
using WebSamples.Repositories.Interfaces;
using WebSamples.Repositories;
using WebSamples.Repositories.Translators;
using WebSamples.Entities.Interfaces;

namespace WebSamples.Services
{
    public class GeoCityService : IGeoCityService
    {
        #region Private fields

        IGeoCityRepository repository = new GeoCityRepository();

        #endregion

        #region Exposed methods
        
        public IList<IGeoCity> GetAllCities()
        {
            return this.repository.GetAllCities()
                                  .Select(c => GeoCityTranslator.ToServiceEntity(c)).ToList();
        }

        public IList<IGeoCity> GetCitiesNearBy(double latitude, double longitude, int radius)
        {
            return this.repository.GetCitiesNearBy(latitude, longitude, radius)
                                  .Select(c => GeoCityTranslator.ToServiceEntity(c)).ToList();
        }

        public IList<IGeoCity> GetCitiesBounded(double topLeftLat, double topLeftLong,
                                                double botRightLat, double botRightLong)
        {
            return this.repository.GetCitiesBounded(topLeftLat, topLeftLong,
                                                    botRightLat, botRightLong)
                                  .Select(c => GeoCityTranslator.ToServiceEntity(c)).ToList();
        }

        #endregion
    }
}
