public HttpResponseMessage Logout(int userId) { if (Request.Method == HttpMethod.Options) { return(new HttpResponseMessage(HttpStatusCode.OK)); } WebServiceResult retVal = new WebServiceResult() { Message = "OK", Result = "" }; UserBusinessLayer bl = new UserBusinessLayer(); try { if (!bl.CheckSession(new Guid(Utils.GetSessionId()))) { retVal.Message = "Session error"; retVal.Result = "Invalid session"; } else { retVal = bl.Logout(userId); } var status = HttpStatusCode.OK; if (retVal.Message != "OK") { status = HttpStatusCode.InternalServerError; } return(new HttpResponseMessage(status) { Content = new StringContent(JsonConvert.SerializeObject(retVal), Encoding.UTF8, "application/json") }); } catch (Exception ex) { return(new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent(JsonConvert.SerializeObject(ex), Encoding.UTF8, "application/json") }); } }