using System.Collections.Generic; using System.Net; using System.Net.Http; using System.Web.Http; using DotNetNuke.Security; using DotNetNuke.Web.Api; using <%= fullNamespace %>.Components; namespace <%= fullNamespace %>.Services { public partial class ExampleController { /// /// Use to test a successful response /// /// /// /// GET: http://dnndev.me/DesktopModules/MVC/<%= fullNamespace %>/API/Event/Ping /// [AllowAnonymous] [HttpGet] public HttpResponseMessage Ping() { var response = new ServiceResponse() { Content = "Success" }; return Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson()); } /// /// Use to test a failed response /// /// /// /// GET: http://dnndev.me/DesktopModules/MVC/<%= fullNamespace %>/API/Event/PingError /// [AllowAnonymous] [HttpGet] public HttpResponseMessage PingError() { var errors = new List(); errors.Add(new ServiceError() { Code = "NULL", Description = "NullReferenceException stack trace" }); var response = new ServiceResponse() { Errors = errors }; return Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson()); } /// /// Use to test a failed response /// /// /// /// GET: http://dnndev.me/DesktopModules/MVC/<%= fullNamespace %>/API/Event/PingException /// [AllowAnonymous] [HttpGet] public HttpResponseMessage PingException() { return Request.CreateResponse(HttpStatusCode.InternalServerError); } /// /// Use to test a failed response /// /// /// /// GET: http://dnndev.me/DesktopModules/MVC/<%= fullNamespace %>/API/Event/PingNotFound /// [AllowAnonymous] [HttpGet] public HttpResponseMessage PingNotFound() { return Request.CreateResponse(HttpStatusCode.NotFound); } /// /// Use to test for security credentials /// /// /// /// GET: http://dnndev.me/DesktopModules/MVC/<%= fullNamespace %>/API/Event/PingSecurityCheck /// [DnnModuleAuthorize(AccessLevel = SecurityAccessLevel.Edit)] [ValidateAntiForgeryToken] [HttpGet] public HttpResponseMessage PingSecurityCheck() { // this response should only be reached if the user is allowed to edit the module // otherwise, they'll be automatically met with a 401 unauthorized error var response = new ServiceResponse() { Content = "Success" }; return Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson()); } } }