2012-09-07 16:17:39 +00:00
|
|
|
|
using MediaBrowser.Common.Net.Handlers;
|
2012-09-11 01:34:02 +00:00
|
|
|
|
using MediaBrowser.Controller.Entities;
|
2012-09-02 14:56:36 +00:00
|
|
|
|
using MediaBrowser.Model.DTO;
|
2012-09-08 14:52:13 +00:00
|
|
|
|
using System.ComponentModel.Composition;
|
|
|
|
|
using System.Net;
|
2012-09-07 16:17:39 +00:00
|
|
|
|
using System.Threading.Tasks;
|
2012-09-02 14:56:36 +00:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Api.HttpHandlers
|
|
|
|
|
{
|
2012-09-08 14:52:13 +00:00
|
|
|
|
[Export(typeof(BaseHandler))]
|
2012-09-08 01:33:49 +00:00
|
|
|
|
class UserHandler : BaseSerializationHandler<DTOUser>
|
2012-09-02 14:56:36 +00:00
|
|
|
|
{
|
2012-09-08 14:52:13 +00:00
|
|
|
|
public override bool HandlesRequest(HttpListenerRequest request)
|
|
|
|
|
{
|
|
|
|
|
return ApiService.IsApiUrlMatch("user", request);
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-02 14:56:36 +00:00
|
|
|
|
protected override Task<DTOUser> GetObjectToSerialize()
|
|
|
|
|
{
|
2012-09-08 01:33:49 +00:00
|
|
|
|
string id = QueryString["id"];
|
|
|
|
|
|
|
|
|
|
User user = string.IsNullOrEmpty(id) ? ApiService.GetDefaultUser(false) : ApiService.GetUserById(id, false); ;
|
2012-09-02 14:56:36 +00:00
|
|
|
|
|
|
|
|
|
DTOUser dto = ApiService.GetDTOUser(user);
|
|
|
|
|
|
|
|
|
|
return Task.FromResult<DTOUser>(dto);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|