public void SetUp() { _context = Substitute.For <IOrangeBricksContext>(); _properties = Substitute.For <IDbSet <Models.Property> >(); _context.Properties.Returns(_properties); _handler = new BookAppointmentCommandHandler(_context); }
public ActionResult BookAppointment(BookAppointmentCommand command) { try { if (ModelState.IsValid) { var handler = new BookAppointmentCommandHandler(_context); command.BuyerUserId = User.Identity.GetUserId(); if (!handler.Handle(command)) { ModelState.AddModelError("", "You already booked an appointment."); } else { return(RedirectToAction("Index")); } } } catch (Exception ex) { ModelState.AddModelError("", "Adding appointment failed."); } return(RedirectToAction("Index")); }
public ActionResult BookAppointment(BookAppointmentCommand command) { var handler = new BookAppointmentCommandHandler(_context); command.BuyerUserId = User.Identity.GetUserId(); handler.Handle(command); return(RedirectToAction("Index")); }
public ActionResult BookAppointment(BookAppointmentCommand command) { command.BuyerUserId = UserId; var handler = new BookAppointmentCommandHandler(Context); handler.Handle(command); return(RedirectToAction("Index")); }
public void SetUp() { _context = Substitute.For <IOrangeBricksContext>(); _handler = new BookAppointmentCommandHandler(_context); var properties = new List <Models.Property> { new Models.Property { Id = 1, StreetName = "Smith Street", Description = "", IsListedForSale = true }, new Models.Property { Id = 2, StreetName = "Jones Street", Description = "", IsListedForSale = true } }; var mockSet = Substitute.For <IDbSet <Models.Property>, IQueryable <Models.Property> >() .Initialize(properties.AsQueryable()); _context.Properties.Returns(mockSet); _context.Appointments.Returns(Substitute.For <IDbSet <Appointment> >()); }