Ejemplo n.º 1
0
        public override string GetObjectServer(string jsonString)
        {
            ImportObject obj = JsonHelper.DeserializeJsonToObject <ImportObject>(jsonString);

            ServerResponseWithoutBody simpleRes = new ServerResponseWithoutBody();

            simpleRes.type = type;

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

                if (store.Import(obj.product, obj.cost, obj.comments, 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));
            }
        }
Ejemplo n.º 2
0
        public override string GenerateObjectClient()
        {
            ImportObject obj = new ImportObject();

            obj.type     = type;
            obj.user     = user;
            obj.product  = product;
            obj.cost     = cost;
            obj.comments = comments;

            string s = JsonHelper.SerializeObject(obj);

            return(s);
        }