public int Handle(CompleteOrderCommand command)
        {
            // command validation ommited
            var order = new Order(command.ProductId, command.Amount);

            _database.Orders.Add(order);
            _database.SaveChanges();

            var @event = new OrderCompletedEvent(order.Id, order.ProductId, order.Amount);

            _mediator.Publish(@event);

            return(order.Id);
        }
        public int Handle(AddProductCommand command)
        {
            // command validation ommited
            var product = new Product(command.Name, command.CategoryId);

            _database.Products.Add(product);
            _database.SaveChanges();

            var @event = new ProductAddedEvent(product.Id, product.Name, product.CategoryId);

            _mediator.Publish(@event);

            return(product.Id);
        }
        public int Handle(AddReviewCommand command)
        {
            // command validation
            var review = new Review(command.ProductId, command.UserId, command.Rating);

            _database.Reviews.Add(review);
            _database.SaveChanges();


            var @event = new ReviewAddedEvent(review.Id, review.UserId, review.ProductId, review.Rating);

            _mediator.Publish(@event);

            return(review.Id);
        }