private async Task InsertAsync(xItem command)
        {
            _logger.LogInformation($"Creating item: {command.Item}");

            await _service.AddAsync(
                command.Id,
                command.Item,
                command.Status,
                command.Count
                );

            var xItem = await _service.GetAsync(command.Item);

            // NOTE: these two methods should be refactored into one using rabbitmq exchange with fanout,
            // currently implemented only as rabbitmq direct msg queue
            await _busClient.PublishAsync(new ItemCreated1(
                                              xItem.Id,
                                              xItem.Item,
                                              xItem.Status,
                                              xItem.Count
                                              ));

            await _busClient.PublishAsync(new ItemCreated2(
                                              xItem.Id,
                                              xItem.Item,
                                              xItem.Status,
                                              xItem.Count
                                              ));
        }
        public async Task <IActionResult> Post(string bucketName,
                                               [FromBody] ItemDTO itemDto)
        {
            await _itemService.AddAsync(bucketName, itemDto.Key, itemDto.Value);

            return(Created(
                       BUCKET + SLASH + PARAM_BUCKET_NAME + SLASH + ITEM + SLASH + itemDto.Key,
                       null
                       ));
        }
示例#3
0
        public async Task <IActionResult> Post(ItemRequest request)
        {
            try
            {
                var item = await _itemService.AddAsync(request);

                return(Ok(item));
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
示例#4
0
        //Action
        public async Task AddAsync(Item item)
        {
            try
            {
                //Some business logic
                await itemService.AddAsync(item);

                //Dispatching payload
                //dispatcher.Dispatch(new Payload<ActionTypes>(ActionTypes.UpsertItem, item));
                App.Dispatcher.Dispatch(Payload <ActionTypes> .From(ActionTypes.UpsertItem, item));
            }
            catch (System.Exception ex)
            {
                App.Dispatcher.Dispatch(Payload <ActionTypes> .From(ActionTypes.Failure, ex.Message));
            }
        }
示例#5
0
        public async Task <IActionResult> Post(string bucketName, [FromBody] ItemDTO item)
        {
            await _itemService.AddAsync(bucketName, item.Key, item.Value);

            return(Created($"buckets/{bucketName}/items/{item.Key}", null));
        }
        public async Task <ActionResult <Item> > PostItem(Item item)
        {
            await _itemService.AddAsync(item);

            return(CreatedAtAction("GetItem", new { id = item.ItemId }, item));
        }