﻿using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
using LocalLingua.Data.DomainModels;
using LocalLingua.Logic.Trip;
using LocalLingua.Web.Infrastructure.Models;

namespace LocalLingua.Web.Controllers.api
{
    public class TripsApiController : BaseApiController<TripsApiController>
    {
        private readonly ITripsService _tripsService;

        public TripsApiController(ITripsService tripsService)
        {
            _tripsService = tripsService;
        }

        public async Task<IEnumerable<Trip>> Get()
        {
            return await _tripsService.Get();
        }

        public async Task<IEnumerable<Trip>> Get(string cityName)
        {
            return await _tripsService.Get(cityName);
        }

        public async Task<IEnumerable<Trip>> GetByCountry(string countryName, bool someBoolDunno = false)
        {
            return await _tripsService.GetByCountry(countryName);
        }

        public async Task<IEnumerable<Trip>> GetForDashboard(string token)
        {
            return await _tripsService.GetForDashboard(token);
        }

        //[JwtAuthenticationFilter]
        public async Task<HttpResponseContainer> Post(Trip trip)
        {
            return new HttpResponseContainer
            {
                Code = HttpStatusCode.OK,
                Data = await _tripsService.AddOrUpdate(trip)
            };
        }

        //[JwtAuthenticationFilter]
        public async Task<HttpResponseContainer> Put(Trip trip)
        {
            return new HttpResponseContainer
            {
                Code = HttpStatusCode.OK,
                Data = await _tripsService.AddOrUpdate(trip)
            };
        }

        //[JwtAuthenticationFilter]
        public async Task<HttpResponseContainer> Delete(int id, string token)
        {
            return new HttpResponseContainer
            {
                Code = HttpStatusCode.OK,
                Data = await _tripsService.Delete(id)
            };
        }
    }
}
