Example #1
0
        public Task <Unit> Handle(RegisterNewBlogCommand message, CancellationToken cancellationToken)
        {
            if (!message.IsValid())
            {
                NotifyValidationErrors(message);
                return(Unit.Task);
            }

            var blog = new Blog(message.Url);

            //if (_customerRepository.GetByEmail(customer.Email) != null)
            //{
            //    Bus.RaiseEvent(new DomainNotification(message.MessageType, "The customer e-mail has already been taken."));
            //    return Unit.Task;
            //}

            _blogRepository.Add2(blog);

            if (Commit())
            {
                Bus.RaiseEvent(new BlogRegisteredEvent(blog.BlogId, blog.Url));
            }
            return(Unit.Task);
        }