コード例 #1
0
        public async Task <Wish> AddWish(string message)
        {
            var wishToAdd = new Wish
            {
                Content = message
            };

            await _wishRepository.Add(wishToAdd);

            return(new Wish());
        }
コード例 #2
0
        public Task <bool> Handle(RegisterNewWishCommand message, CancellationToken cancellationToken)
        {
            if (!message.IsValid())
            {
                NotifyValidationErrors(message);
                return(Task.FromResult(false));
            }

            var wish = new Wish(Guid.NewGuid(), message.UserId);

            _wishRepository.Add(wish);

            if (Commit())
            {
                Bus.RaiseEvent(new WishRegisteredEvent(wish.Id, wish.UserId));
            }

            return(Task.FromResult(true));
        }