Esempio n. 1
0
        private void changeProductInfoHandler(JObject msgObj, string message)
        {
            JsonResponse response;
            int          requestId = (int)msgObj["id"];
            int          storeId   = (int)msgObj["data"]["storeId"];
            int          productId = (int)msgObj["data"]["productId"];
            string       name      = (string)msgObj["data"]["name"];
            string       desc      = (string)msgObj["data"]["desc"];
            string       category  = (string)msgObj["data"]["category"];
            ///will probalby crush
            double price  = (double)msgObj["data"]["price"];
            int    amount = (int)msgObj["data"]["amount"];

            try
            {
                response = user.ChangeProductInfo(storeId, productId, name, desc, price, category, amount) ?
                           JsonResponse.generateActionSucces(requestId) : JsonResponse.generateActionError(requestId, "failed to change product info");
            }
            catch (WorkShopDbException dbExc)
            {
                response = JsonResponse.generateActionError(requestId, "DB is down please try again in few minutes\n" + dbExc.Message);
            }
            catch (Exception e)
            {
                response = JsonResponse.generateActionError(requestId, e.Message);
            }

            sendMyselfAMessage(JsonHandler.SerializeObject(response));
        }