// DELETE: api/user/5 public IHttpActionResult Delete(int id, HttpRequestMessage request) { if (_log.IsDebugEnabled) { _log.DebugFormat("Executing call in debug mode"); } var headers = request.Headers; //Check the request object to see if they passed a userId if (headers.Contains("userid")) { var user = headers.GetValues("userid").First(); _log.InfoFormat("Handling DELETE request from user: {0}", user); if (!ModelState.IsValid) { return(BadRequest("Invalid data.")); } try { RoleActions roleActions = new RoleActions(); roleActions.Deactivate(id, user); return(Ok()); } catch (Exception e) { _log.Error("An error occurred while DeActivating Role.", e); return(InternalServerError(e)); } } return(BadRequest("Header value <userid> not found.")); }