public HttpResponseMessage Delete(int id) { int check = new SessionHelper().checkSession(Constants.USERS, Constants.ACTION_DELETE); if (check > 0) { ProductsModel model = new ProductsModel(); bool resultQuery = model.delete(id); if (resultQuery) { JArray result = new JArray(); var data = model.GetAll(); result = JArray.FromObject(data); var exception = JObject.FromObject(new { err = Constants.PROCESS_OK, data = result }); return(Request.CreateResponse(HttpStatusCode.OK, exception)); } else { JObject exception = JObject.FromObject(new { err = Constants.PROCESS_FAILED, msg = Constants.DELETE_FAIL }); return(Request.CreateResponse(HttpStatusCode.OK, exception)); } } else { string message = (check == Constants.PERMISSION_LOGIN_CODE) ? Constants.PERMISSION_LOGIN_MSG : Constants.PERMISSION_DENIED_MSG; JObject exception = JObject.FromObject(new { err = check, msg = message }); return(Request.CreateResponse(HttpStatusCode.OK, exception)); } }