public void HandlerShouldAddViewing() { // Arrange var command = new RequestViewingCommand { PropertyId = 1 }; // Act _handler.Handle(command); // Assert var property = _context.Properties.First(); Assert.IsNotEmpty(property.Viewings); }
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")); }