public ActionResult RequestViewing(RequestViewingCommand command)
        {
            // Set the BuyerUserId before calling the command handler
            command.BuyerUserId = User.Identity.GetUserId();

            var handler = new RequestViewingCommandHandler(_context);

            handler.Handle(command);

            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public ActionResult RequestViewing(RequestViewingCommand command)
        {
            var handler = new RequestViewingCommandHandler(_context);

            if (string.IsNullOrEmpty(command.ViewingTime))
            {
                command.ViewingTime = "09:00";
            }

            command.RequestedUserId = User.Identity.GetUserId();

            handler.Handle(command);

            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
        public void HandlerShouldAddViewing()
        {
            // Arrange
            var command = new RequestViewingCommand
            {
                PropertyId = 1
            };

            // Act
            _handler.Handle(command);

            // Assert
            var property = _context.Properties.First();

            Assert.IsNotEmpty(property.Viewings);
        }
Exemplo n.º 4
0
        public void HandlerShouldAddViewingWithCorrectBuyerUserId()
        {
            // Arrange
            var command = new RequestViewingCommand
            {
                PropertyId  = 1,
                BuyerUserId = "123"
            };

            // Act
            _handler.Handle(command);

            // Assert
            var property = _context.Properties.First();

            Assert.IsNotEmpty(property.Viewings);

            var viewing = property.Viewings.First();

            Assert.AreEqual("123", viewing.BuyerUserId);
        }
Exemplo n.º 5
0
        public void HandlerShouldAddViewingWithCorrectViewingAtValue()
        {
            // Arrange
            var command = new RequestViewingCommand
            {
                PropertyId = 1,
                ViewingAt  = new DateTime(2017, 1, 1, 9, 0, 0)
            };

            // Act
            _handler.Handle(command);

            // Assert
            var property = _context.Properties.First();

            Assert.IsNotEmpty(property.Viewings);

            var viewing = property.Viewings.First();

            Assert.AreEqual(new DateTime(2017, 1, 1, 9, 0, 0), viewing.ViewingAt);
        }