private void searchProductsHandler(JObject msgObj, string message) { JsonResponse response; int requestId = (int)msgObj["id"]; string name = (string)msgObj["data"]["name"]; string category = (string)msgObj["data"]["category"]; string keyword = (string)msgObj["data"]["keyword"]; string stringStartPrice = (string)msgObj["data"]["startPrice"]; string stringEndPrice = (string)msgObj["data"]["endPrice"]; string stringProductRank = (string)msgObj["data"]["productRank"]; string stringStoreRank = (string)msgObj["data"]["storeRank"]; double startPrice = (stringStartPrice == "") ? -1 : Convert.ToDouble(stringStartPrice); double endPrice = (stringEndPrice == "") ? -1 : Convert.ToDouble(stringEndPrice); int productRank = (stringProductRank == "") ? -1 : Convert.ToInt32(stringProductRank); int storeRank = (stringStoreRank == "") ? -1 : Convert.ToInt32(stringStoreRank); try { String data_ans = JsonHandler.SerializeObject(user.SearchProducts(name, category, keyword, startPrice, endPrice, productRank, storeRank)); response = JsonResponse.generateDataSuccess(requestId, data_ans); } catch (WorkShopDbException dbExc) { response = JsonResponse.generateDataFailure(requestId, "DB is down please try again in few minutes\n" + dbExc.Message); } catch (Exception e) { response = JsonResponse.generateDataFailure(requestId, e.Message); } sendMyselfAMessage(JsonHandler.SerializeObject(response)); }