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"));
        }
        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"));
        }
Esempio n. 3
0
        public void SetUp()
        {
            // Setup context mocks
            _context = Substitute.For <IOrangeBricksContext>();

            // Setup propery mocks
            var properties = new List <Models.Property> {
                new Models.Property {
                    Id = 1, Description = "Small house", StreetName = "1 Somewhere", NumberOfBedrooms = 1, IsListedForSale = true, PropertyType = "House"
                }
            };

            var mockPropertySet = Substitute.For <IDbSet <Models.Property> >()
                                  .Initialize(properties.AsQueryable());

            _context.Properties.Returns(mockPropertySet);

            _handler = new RequestViewingCommandHandler(_context);
        }