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")); }
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 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); }
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); }