using System;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using DotNetNuke.Entities.Users;
using DotNetNuke.Security;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Web.Api;
using <%= fullNamespace %>.Components;
namespace <%= fullNamespace %>.Services
{
public partial class <%= extensionName %>Controller
{
///
/// Get an event
///
///
///
/// GET: http://dnndev.me/DesktopModules/MVC/<%= namespace %>/<%= extensionName %>/API/Event/GetCurrentUser
///
[DnnModuleAuthorize(AccessLevel = SecurityAccessLevel.View)]
[HttpGet]
public HttpResponseMessage GetCurrentUser()
{
try
{
var currentUser = UserInfo;
var response = new ServiceResponse {Content = UserInfo};
if (currentUser == null)
{
ServiceResponseHelper.AddNoneFoundError("currentUser", ref response);
}
return Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson());
}
catch (Exception ex)
{
Exceptions.LogException(ex);
return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE);
}
}
///
/// Get an event
///
///
///
/// GET: http://dnndev.me/DesktopModules/MVC/<%= namespace %>/<%= extensionName %>/API/Event/GetCurrentUserId
///
[DnnModuleAuthorize(AccessLevel = SecurityAccessLevel.View)]
[HttpGet]
public HttpResponseMessage GetCurrentUserId()
{
try
{
var currentUserId = UserInfo.UserID;
var response = new ServiceResponse { Content = currentUserId };
return Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson());
}
catch (Exception ex)
{
Exceptions.LogException(ex);
return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE);
}
}
}
}