I have a stored proc in SQL called "person_connections_delete". I have written a controller to call the stored proc however, this error message keeps coming up
"message": "No HTTP resource was found that matches the request URI 'http://localhost:3024/api/personconnections/delete'.", "messageDetail": "No action was found on the controller 'PersonConnections' that matches the request."
Here is the stored proc. I'm passing three parameters into the stored proc for the delete.
ALTER PROC [dbo].[person_connections_delete]
@PersonId INT,
@FriendId INT,
@Status INT
AS
/*
DECLARE
@_personId INT = 1,
@_friendId INT = 200,
@_status INT = 1
EXEC person_connections_delete
@_personId,
@_friendId,
@_status
*/
BEGIN
DELETE
person_connections
WHERE
PersonId = @PersonId and FriendId = @FriendId
IF (@Status = 1)
DELETE
person_connections
WHERE
PersonId = @FriendId and FriendId = @PersonId
END
The service and controller. in C#:
public void Delete(int personId, int friendId, int status)
{
_dataProvider.ExecuteNonQuery(
"person_connections_delete",
inputParamMapper: delegate (SqlParameterCollection paramCol)
{
paramCol.AddWithValue("@PersonId", personId);
paramCol.AddWithValue("@FriendId", friendId);
paramCol.AddWithValue("@Status", status);
}
);
}
[AllowAnonymous]
[RoutePrefix("api/personconnections")]
public class PersonConnectionsController : ApiController
{
private IPersonConnectionsService _personConnectionsService;
[HttpDelete]
[Route("delete")]
public HttpResponseMessage Delete(int personId, int friendId, int status)
{
try {
if (ModelState.IsValid) {
ItemResponse<PersonConnectionsDeleteDomain> resp = new ItemResponse<PersonConnectionsDeleteDomain>();
_personConnectionsService.Delete(personId, friendId, status);
return Request.CreateResponse(HttpStatusCode.OK, resp);
} else {
return Request.CreateResponse(HttpStatusCode.NotModified, ModelState);
}
} catch (Exception ex) {
return Request.CreateResponse(HttpStatusCode.BadRequest, ex);
}
}
}