I've added this method to my web api controller:
[HttpPost]
public bool CreateTrening(int routineId)
{
try
{
var userId = User.Identity.GetUserId();
TreningService.CheckIfLastTrenigWasCompleted(userId);
TreningService.CreateTreningForUser(userId, routineId);
return true;
}
catch (Exception ex)
{
return false;
}
}
And I've added another route to my WebApiConfig file, so it looks like this now:
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "CustomApi",
routeTemplate: "{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
But when I try to call my method:
/EditWorkout/CreateTrening/1
I get this error:
{"Message":"No HTTP resource was found that matches the request URI '/EditWorkout/CreateTrening/1'.","MessageDetail":"No action was found on the controller 'EditWorkout' that matches the request."}
How can I call my method which is in WebApi controller ?