예제 #1
0
        public void Set(ICallRequest request)
        {
            var modelParams = request.ParseParams <MyModel>();

            // Check if the Message property was changed
            if (modelParams.Message != null && modelParams.Message != myModel.Message)
            {
                // Update the model
                myModel.Message = modelParams.Message;
                // Send a change event with updated fields
                request.ChangeEvent(new Dictionary <string, object> {
                    { "message", myModel.Message }
                });
            }
            request.Ok();
        }
예제 #2
0
        public void Set(ICallRequest request)
        {
            Book bookParams = request.ParseParams <Book>();
            var  changed    = new Dictionary <string, object>(2);

            // Check if the title property was provided
            if (bookParams.Title != null)
            {
                changed["title"] = bookParams.Title.Trim();
            }

            // Check if the author property was provided
            if (bookParams.Author != null)
            {
                changed["author"] = bookParams.Author.Trim();
            }

            // Send a change event with updated fields
            request.ChangeEvent(changed);

            // Send success response
            request.Ok();
        }
예제 #3
0
        public void Set(ICallRequest req)
        {
            Customer customerParams = req.ParseParams <Customer>();

            // Preprocess call params
            customerParams.TrimAll();

            // Validate call params
            if (customerParams.HasError(out string errorMsg))
            {
                req.InvalidParams(errorMsg);
                return;
            }

            // Populate dictionary with updated fields
            var changed = new Dictionary <string, object>(3);

            if (customerParams.Name != null)
            {
                changed["name"] = customerParams.Name;
            }
            if (customerParams.Email != null)
            {
                changed["email"] = customerParams.Email;
            }
            if (customerParams.Country != null)
            {
                changed["country"] = customerParams.Country;
            }

            // Send a change event with updated fields
            req.ChangeEvent(changed);

            // Send success response
            req.Ok();
        }