示例#1
0
        public async void TestSetItemValuesAsync()
        {
            SetItemValues   req;
            Request         req2;
            RecombeeBinding resp;

            // it 'does not fail with existing entity and property'
            req = new SetItemValues("entity_id", new Dictionary <string, object>()
            {
                { "int_property", 5 }
            });
            resp = await client.SendAsync(req);

            // it 'does not fail with non-ASCII string'
            req = new SetItemValues("entity_id", new Dictionary <string, object>()
            {
                { "str_property", "šřžذ的‎" }
            });
            resp = await client.SendAsync(req);

            // it 'sets multiple properties'
            req = new SetItemValues("entity_id", new Dictionary <string, object>()
            {
                { "int_property", 5 }, { "str_property", "test" }
            });
            resp = await client.SendAsync(req);

            // it 'does not fail with !cascadeCreate'
            req = new SetItemValues("new_entity", new Dictionary <string, object>()
            {
                { "int_property", 5 }, { "str_property", "test" }, { "!cascadeCreate", true }
            });
            resp = await client.SendAsync(req);

            // it 'does not fail with cascadeCreate optional parameter'
            req = new SetItemValues("new_entity2", new Dictionary <string, object>()
            {
                { "int_property", 5 }, { "str_property", "test" }
            }, cascadeCreate: true);
            resp = await client.SendAsync(req);

            // it 'fails with nonexisting entity'
            req = new SetItemValues("nonexisting", new Dictionary <string, object>()
            {
                { "int_property", 5 }
            });
            try
            {
                await client.SendAsync(req);

                Assert.True(false, "No exception thrown");
            }
            catch (ResponseException ex)
            {
                Assert.Equal(404, (int)ex.StatusCode);
            }
        }
示例#2
0
        /// <summary>
        /// Updates given product <paramref name="productPage"/> in Recombee database.
        /// </summary>
        /// <param name="productPage">Product to update.</param>
        public void UpdateProduct(SKUTreeNode productPage)
        {
            var updateRequest = new SetItemValues(
                productPage.DocumentGUID.ToString(),
                ProductMapper.Map(productPage),
                true);

            try
            {
                client.Send(updateRequest);
            }
            catch (Exception ex)
            {
                Service.Resolve <IEventLogService>().LogException("RecombeeAdminModule", "ON_PRODUCT_CREATED", ex);
            }
        }