public void Start() { //Configure Bus var rabbitConfiguration = new RabbitConfiguration(); rabbitConfiguration.Configure("MainClientAppService"); //Configure where the commands sent by this service are forwarded to. Transport.RouteToEndpoint(typeof(MakeAppointment), BookingServiceConstants.ServiceName); var bus = new Publisher(); //User Input do { Console.WriteLine("Enter a date with format (dd/mm/yyyy): "); var ddMMyyyy = Convert.ToString(Console.ReadLine()); var splitedValues = ddMMyyyy.Split('/'); var makeAppointmentCommand = new MakeAppointment { Date = new DateTime(int.Parse(splitedValues[2]), int.Parse(splitedValues[1]), int.Parse(splitedValues[0])) }; Console.WriteLine("What is your Name?"); makeAppointmentCommand.Name = Convert.ToString(Console.ReadLine()); bus.Send(makeAppointmentCommand); Thread.Sleep(5000); } while (true); }
public void TestMakeAppointment() { //Setup // var connStr = @"Server=192.168.88.79\SQLEXPRESS;Database=appointments;User Id=chinook;Password=pr0t3ct3d"; var connStr = @"Data Source=.\SQLEXPRESS;Database=appointments;User Id=chinook;Password=pr0t3ct3d"; IMessageSender sender = new SqlMessageSender(connStr, "dbo.messages"); ITextSerializer serializer = new JsonTextSerializer(); // IEventStore eventStore = new SqlEventStore(connStr, "dbo.events"); // // IEventBus eventBus = new EventBus(sender, serializer); // IMetadataProvider metaProvider = new StandardMetadataProvider(); IReadModelStorage <AppointmentReadModel> readModelStorage = new InMemeoryStorage <AppointmentReadModel>(); // // IEventSourcedRepository<AppointmentAggregate> repo = new // EventSourcedRepository<AppointmentAggregate>(eventStore, eventBus, serializer, metaProvider); // ICommandDispatcher cmdDispatcher = new CommandDispatcher(); // cmdDispatcher.Register(new AppointmentCommandHandler(repo)); // // IEventDispatcher evtDispatcher = new EventDispatcher(); // evtDispatcher.Register(new AppointmentEventHandler(readModelStorage)); // // IMessageReceiver cmdReceiver = new SqlMessageReceiver(connStr, "dbo.commands"); // // IMessageReceiver evtReceiver = new SqlMessageReceiver(connStr, "dbo.events"); // // CommandProcessor commandProcessor = new CommandProcessor(cmdReceiver, serializer, cmdDispatcher); // EventPorcessor eventProcessor = new EventPorcessor(evtReceiver, serializer, evtDispatcher); // // // commandProcessor.Start(); // // eventProcessor.Start(); ICommandBus commandBus = new CommandBus(sender, serializer); //Test var command = new MakeAppointment(); command.Appointment = new Appointment(); command.Appointment.Body = "Dental appointment"; command.Appointment.Subject = "Dental"; command.Appointment.Start = DateTimeOffset.MinValue; command.Appointment.End = DateTimeOffset.MaxValue; command.Appointment.Organizer = "Jeff Jin"; var cmdTask = commandBus.Publish(new [] { command }); cmdTask.Wait(); // var task = readModelStorage.GetAll(0, 10); // task.Wait(); // // Thread.Sleep(3000); // // //Verify // Assert.AreEqual(1, task.Result.Count()); }
public IHttpActionResult BookAppointment(HttpRequestMessage request, [FromBody] TurnDetailsDTO appointment) { String access_token = request.Headers.Authorization.ToString(); int custId = Token.GetCustIdFromToken(access_token); appointment.CustId = custId; try { return(Ok(MakeAppointment.BookAppointment(appointment))); } catch { return(BadRequest()); } }
public IHttpActionResult GetDaysToService(string serviceId, string day = null) { try { if (day == null) { return(Ok(MakeAppointment.GetOptionalDaysPerService(int.Parse(serviceId)))); } else { return(Ok(MakeAppointment.GetOptionalHoursPerDay(int.Parse(serviceId), (DateTime.Parse(day))))); } } catch (Exception ex) { return(BadRequest(ex.Message)); } }