Example #1
0
        public Task HandleAsync(InventoryItemRenamed message)
        {
            var item = InMemoryDatabase.List.Find(x => x.Id == message.Id);

            item.Name = message.NewName;
            return(Task.FromResult(0));
        }
Example #2
0
        public async Task HandleHandlesInventoryItemRenamed()
        {
            var repositoryMock = new Mock <IReadModelRepository <InventoryItemDetailsDto, Guid> >();
            var hubMock        = new Mock <InventoryHub>();

            var inventoryItemRenamedEvent = new InventoryItemRenamed(_itemId, _newItemName)
            {
                Version   = _version,
                TimeStamp = _timeStamp
            };

            hubMock.Setup(x => x.SendUpdateInventoryItemDetailMessage(
                              _itemId, inventoryItemRenamedEvent))
            .Returns(Task.CompletedTask)
            .Verifiable();
            repositoryMock.Setup(x => x.AddOrUpdate(It.Is <InventoryItemDetailsDto>
                                                        (m => m.Name == _newItemName &&
                                                        m.Version == _version &&
                                                        m.Id == _itemId &&
                                                        m.Timestamp == _timeStamp)))
            .Returns(Task.CompletedTask)
            .Verifiable();
            repositoryMock.Setup(x => x.GetById(_itemId))
            .ReturnsAsync(_searchResponseMock.Object);

            var target = GetTarget(repositoryMock, hubMock);

            await target.Handle(inventoryItemRenamedEvent, new CancellationToken(false));

            repositoryMock.Verify();
            hubMock.Verify();
        }
        public void Handle(InventoryItemRenamed message)
        {
            InventoryItemDetailsDto d = GetDetailsItem(message.Id);

            d.Name    = message.NewName;
            d.Version = message.Version;
        }
        public Task Handle(InventoryItemRenamed message)
        {
            var item = InMemoryDatabase.List.Find(x => x.Id == message.Id);

            item.Name = message.NewName;
            return(Task.CompletedTask);
        }
Example #5
0
        public void Handle(InventoryItemRenamed @event)
        {
            var details = GetDetailsItem(@event.Id);

            details.Name    = @event.NewName;
            details.Version = @event.Version;
        }
        public void Handle(InventoryItemRenamed @event)
        {
            InventoryItemDto d = _readDocumentStore.Documents["InventoryItem"][@event.Id];

            d.Name    = @event.NewName;
            d.Version = @event.Version;
        }
Example #7
0
        public void Handle(InventoryItemRenamed message)
        {
            InventoryItemDetailsDto dto;

            if (ReadModelFacade.UseSqlDatabase)
            {
                using (var datastore = new SqlDatabase())
                {
                    if (datastore.Details.TryGetValue(message.Id, out dto))
                    {
                        dto.Name    = message.NewName;
                        dto.Version = message.Version;
                        datastore.InventoryItemDetailsDtoStore.Update(dto);
                    }
                }
            }
            else
            {
                if (InMemoryDatabase.Details.TryGetValue(message.Id, out dto))
                {
                    dto.Name    = message.NewName;
                    dto.Version = message.Version;
                }
            }
        }
Example #8
0
        public void Handle(InventoryItemRenamed @event)
        {
            var inventoryItem = _readDocumentStore.Documents["Inventory"][@event.Id];

            inventoryItem.Name    = @event.NewName;
            inventoryItem.Version = @event.Version;
        }
        public Task HandleAsync(InventoryItemRenamed message)
        {
            InventoryItemDetailsDto d = GetDetailsItem(message.Id);

            d.Name    = message.NewName;
            d.Version = message.Version;
            return(Task.FromResult(0));
        }
Example #10
0
        public Task Handle(InventoryItemRenamed message, CancellationToken token)
        {
            var d = GetDetailsItem(message.Id);

            d.Name    = message.NewName;
            d.Version = message.Version;
            return(Task.CompletedTask);
        }
Example #11
0
        public void Handle(InventoryItemRenamed message)
        {
            this.InventoryItemChanged(message);

            var list = _readModel.GetInventoryItems();

            Hub.Clients.All.inventoryItemsListUpdated(list);
        }
Example #12
0
        public async Task HandleAsync(InventoryItemRenamed message)
        {
            Console.WriteLine("InventoryItemRenamed: " + message.Id);
            var item = await this.repository.GetByIdAsync(message.Id);

            item.Version         = message.OriginalVersion;
            item.LastUpdatedAt   = message.Timestamp;
            item.LastUpdatedById = message.OperatorId;

            item.Name = message.NewName;

            await this.repository.UpdateAsync(item);

            await this.repository.UnitOfWork.CommitAsync();
        }
Example #13
0
        /// <summary>
        /// Handles the specified message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="token">The token.</param>
        /// <returns>A <see cref="Task" />.</returns>
        public async Task Handle(InventoryItemRenamed message, CancellationToken token)
        {
            var itemQuery = await _database.GetById(message.Id);

            if (itemQuery.Documents.Any())
            {
                var item = itemQuery.Documents.Single();
                item.Name      = message.NewName;
                item.Version   = message.Version;
                item.Timestamp = message.TimeStamp.DateTime;
                await _database.AddOrUpdate(item);
            }

            // notify hub
            await _hub.SendUpdateInventoryListMessage();
        }
Example #14
0
        public void Handle(InventoryItemRenamed message)
        {
            InventoryItemListDto dto;

            if (ReadModelFacade.UseSqlDatabase)
            {
                using (var datastore = new SqlDatabase())
                {
                    dto      = datastore.List.Single(x => x.Id == message.Id);
                    dto.Name = message.NewName;
                    datastore.InventoryItemListDtoStore.Update(dto);
                }
            }
            else
            {
                dto      = InMemoryDatabase.List.Single(x => x.Id == message.Id);
                dto.Name = message.NewName;
            }
        }
        private void UpdateSummaryItem(InventoryItemRenamed @event)
        {
            // Define Query
            ISingleResultQuery <InventoryItemSummaryQueryStrategy, InventoryItemSummaryEntity> query = QueryFactory.CreateNewSingleResultQuery <InventoryItemSummaryQueryStrategy, InventoryItemSummaryEntity>();

            query.QueryStrategy.WithRsn(@event.Rsn);

            // Retrieve Data, but remember if no items exist, the value is null
            query = InventoryItemSummaryRepository.Retrieve(query, false);
            InventoryItemSummaryEntity inventoryItem = query.Result;

            // As a previous event will have created this instance we should throw an exception if it is not found.
            if (inventoryItem == null)
            {
                throw new NullReferenceException(string.Format("No entity was found by the id '{0}'", @event.Rsn));
            }

            inventoryItem.Name = @event.NewName;

            // Again, this MUST be an update as commented above.
            InventoryItemSummaryRepository.Update(inventoryItem);
        }
 partial void OnHandle(InventoryItemRenamed @event)
 {
     UpdateDetailedItem(@event);
     UpdateSummaryItem(@event);
 }
 protected void ApplyChange(InventoryItemRenamed @event)
 {
     Name = @event.NewName;
     OnApplied(@event);
 }
 public void Handle(InventoryItemRenamed message)
 {
     _repository.Update(message.AggregateId, Update <InventoryItemListDto> .Set(d => d.Name, message.NewName));
 }
Example #19
0
        public void Handle(InventoryItemRenamed message)
        {
            var a = _repository.FindOne <InventoryItemDetailsDto>(message.AggregateId);

            _repository.Update(message.AggregateId, Update <InventoryItemDetailsDto> .Set(d => d.Name, message.NewName).Set(d => d.Version, message.Version));
        }
Example #20
0
        public void Handle(InventoryItemRenamed message)
        {
            var item = InMemoryDatabase.List.Find(x => x.Id == message.Id);

            item.Name = message.NewName;
        }
Example #21
0
        public void Handle(InventoryItemRenamed message)
        {
            var item = BullShitDatabase.list.Find(x => x.Id == message.Id);

            item.Name = message.NewName;
        }
Example #22
0
        public void Handle(InventoryItemRenamed @event)
        {
            var item = BullshitDatabase.List.Find(x => x.Id == @event.Id);

            item.Name = @event.NewName;
        }
Example #23
0
 public void Apply(InventoryItemRenamed @event)
 {
     Name = @event.Name;
 }
Example #24
0
 private void Apply(InventoryItemRenamed e)
 {
     _name = e.NewName;
 }
Example #25
0
 public void Handle(InventoryItemRenamed obj)
 {
     List.First(f => f.Id == obj.Id).Name = obj.NewName;
 }