File size: 1,827 Bytes
e26fba6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using MovieTube.Web.Models;
using MovieFinder.Data;
using WebAPI.OutputCache;
using MovieTube.Web.Repository;
using MovieTube.Web.Attributes;
namespace MovieTube.Web.Controllers
{
[UserProfileFilter]
public class QueryController : ApiController
{
private readonly IMovieRepository repository ;
public QueryController()
{
this.repository = new MovieRepository();
}
[HttpGet]
//[CacheOutput(ClientTimeSpan = 3600, ServerTimeSpan = 3600)]
public ThumbNailVm List(string language, int? year, int? page, string term = "")
{
return repository.List(term, language, year, page);
}
[HttpGet]
//[CacheOutput(ClientTimeSpan = 3600, ServerTimeSpan = 3600)]
public List<SearchResult> Search(string term, string language, int year = 0, int count = 10)
{
return repository.QueryMovies(term, language, year, 0, count)
.Take(10)
.ToList()
.Select(x => new SearchResult
{
name = x.Title + " ( " + x.Language + ") - " + x.ReleasedYear,
id = x.Title
}).ToList();
}
[HttpGet]
//[CacheOutput(ClientTimeSpan = 3600, ServerTimeSpan = 3600)]
public MovieVm Movie(string id)
{
return repository.QueryMovie(id, true);
}
[HttpPost]
public void RemoveLink(string link)
{
repository.RemoveLink(link);
}
}
}
|