示例#1
0
        public override string GenerateObjectClient()
        {
            SellProductObject obj = new SellProductObject();

            obj.type     = type;
            obj.user     = user;
            obj.comments = comments;

            obj.products = products;
            obj.cost     = cost;
            obj.customer = customer;
            obj.taxed    = taxed;

            string s = JsonHelper.SerializeObject(obj);

            return(s);
        }
示例#2
0
        public override string GetObjectServer(string jsonString)
        {
            SellProductObject obj = JsonHelper.DeserializeJsonToObject <SellProductObject>(jsonString);

            ServerResponseWithoutBody simpleRes = new ServerResponseWithoutBody();

            simpleRes.type = type;

            try
            {
                if (!GetAuthorised(obj.user))
                {
                    simpleRes.state = networkState.SERVER_FAIL_AUTHORISING;
                    return(JsonHelper.SerializeObject(simpleRes));
                }

                if (serverMainHandler.GetSingleton().sold(serverMainHandler.GetSingleton().GetStore(),
                                                          obj.products,
                                                          obj.cost,
                                                          obj.customer,
                                                          obj.taxed,
                                                          obj.user.userName))
                {
                    simpleRes.state = networkState.SERVER_SUCCESS;
                }
                else
                {
                    simpleRes.state = networkState.SERVER_FAIL_OPERATION;
                }

                return(JsonHelper.SerializeObject(simpleRes));
            }
            catch (Exception ex)
            {
                simpleRes.state = networkState.SERVER_FAIL_UNKNOWN;
                return(JsonHelper.SerializeObject(simpleRes));
            }
        }