Last active
March 19, 2018 05:43
-
-
Save VesselinVassilev/43d134220bfce38568025e536ea02c03 to your computer and use it in GitHub Desktop.
Sitefinity - Custom WebService
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpGet] | |
public HttpResponseMessage GetPromos() | |
{ | |
if (ClaimsManager.GetCurrentUserId() == Guid.Empty) | |
{ | |
throw new Exception("You need to authenticate first"); | |
} | |
var manager = DynamicModuleManager.GetManager(); | |
var promos = manager.GetLiveDataItemsForType(ScootConstants.CountryPromotion_DynamicType) | |
.ToListOf<PromoGroup>(); | |
return Request.CreateResponse(HttpStatusCode.OK, new { Result = ScootConstants.Success, Data = promos }); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void Application_Start(object sender, EventArgs e) | |
{ | |
SystemManager.ApplicationStart += SystemManager_ApplicationStart; | |
} | |
private void SystemManager_ApplicationStart(object sender, EventArgs e) | |
{ | |
RegisterRoutes(RouteTable.Routes); | |
} | |
private void RegisterRoutes(RouteCollection routes) | |
{ | |
routes.Ignore("{resource}.axd/{*pathInfo}"); | |
// register a custom route /ajax/ for custom webservices | |
routes.MapHttpRoute( | |
name: "DefaultApi", | |
routeTemplate: "ajax/{controller}/{action}/{id}", | |
defaults: new { id = RouteParameter.Optional } | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment