Ejemplo n.º 1
0
        public async Task <bool> UpdateScriplet([FromBody] UpdateRequest parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException("parameter");
            }

            return(await _service.UpdateSetAsync(parameter.Id, parameter.NameValuePairs));
        }
        public async Task <NodeItem> CreateNodeItem(string scripletId, [FromBody] NodeItemCreationRequest value)
        {
            //TODO: include exception management policy according to technical specifications
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            if (value.NodeItem == null)
            {
                throw new ArgumentNullException("value.NodeItem");
            }

            var data = await _service.GetAsync(scripletId);

            if (data == null)
            {
                return(null);
            }

            var scriplet   = _mapper.Map <Scriplet>(data);
            var nodeItem   = _mapper.Map <S.NodeItem>(value.NodeItem);
            var nodeItemId = scriplet.ItemCounter;

            nodeItem.Id       = nodeItemId;
            value.NodeItem.Id = nodeItemId;

            var result = await _service.UpdateSetAsync(scripletId,
                                                       new Dictionary <string, object>()
            {
                [$"Items.{nodeItemId}"] = nodeItem,
                ["ItemCounter"]         = nodeItemId + 1
            });

            return(result ? value.NodeItem : null);
        }