﻿namespace AirlineSystem.Web.Areas.Flight.Controllers
{
    using System.Linq;
    using System.Web.Mvc;

    using AirlineSystem.Data;
    using AirlineSystem.Web.Areas.Flight.Models;
    using AirlineSystem.Web.Controllers;

    using AutoMapper;
    using AutoMapper.QueryableExtensions;

    public class ProfileDetailsController : BaseController
    {
        public ProfileDetailsController(IAirlineSystemData data) : base(data)
        {
        }

        // GET: Flight/ProfileDetails
        [HttpGet]
        public ActionResult Index()
        {
            return this.View();
        }

        [HttpGet]
        public ActionResult ViewDetails()
        {
            var tickets = this.Data.Tickets
                .All()
                .Where(t => t.UserId == this.CurrentUser.Id)
                .AsQueryable()
                .Project()
                .To<TicketViewModel>()
                .ToList();

            return this.View(tickets);
        }
    }
}