using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using AutoMapper;
using Qusion.Cms.Classifications.Core;
using Qusion.Cms.Core;
using Qusion.Cms.Core.Domain;
using Qusion.Cms.Core.Exceptions;
using Qusion.Cms.Core.Security;
using Qusion.Cms.Modules.Karte.Core;
using Qusion.Cms.Modules.Karte;
using Qusion.Cms.Users.Core;
using Qusion.Cms.Users.Domain;
using Qusion.Cms.Web.Http;
using Qusion.WebApp.Areas.cms.Filters;
using Qusion.WebApp.Areas.cms.Models.Karte;
using Qusion.Framework.Configuration;
using Qusion.WebApp.Areas.cms.Helpers;

namespace Qusion.WebApp.Areas.cms.Controllers
{
   // [Authorize]
    public class KartaLaktasiController : ApiController
    {
       
        private readonly KartaService _kartaService;


        public KartaLaktasiController(KartaService KartaService)
        {
            _kartaService = KartaService;

        }



        [HttpGet]
        public KartaModel Get(Guid id)
        {
            Karta Karta = _kartaService.GetById(id);
            return Mapper.Map<Karta, KartaModel>(Karta);
        }

        [HttpGet]
        public PageResult<KartaListModel> Query([FromUri] KartaQueryInput input)
        {
           
            KartaQuery query = Mapper.Map(input, KartaQuery.Default) ?? KartaQuery.Default;
            IEnumerable<Karta> karte = _kartaService.Search(query);
            IList<KartaListModel> model = Mapper.Map<IList<Karta>, IList<KartaListModel>>(karte.ToList());

            return new PageResult<KartaListModel>
                       {
                           Items = model,
                           Count = query.Paging.TotalCount
                       };
        }

       
    }
}