public ActionResult RequestAppointment(RequestAppointmentCommand command) { //todo: come up with more elegant way of handling this command.BuyerUserId = User.Identity.GetUserId(); var handler = new RequestAppointmentCommandHandler(_context); handler.Handle(command); return(RedirectToAction("Index")); }
public void Process(JObject request) { if (request.TryGetValue("commandName", out var commandName)) { var command = commandName.ToString(); switch (command) { case "CreateCalendarDayCommand": if (request.TryGetValue("data", out var data1)) { var jData = data1 as JObject; if (jData.TryGetValue("day", out var day)) { var dayInt = int.Parse(day.ToString()); DayOfWeek dayOfWeek = (DayOfWeek)dayInt; var cmd = new CreateCalendarDayCommand(dayOfWeek); Send(cmd); } } break; case "RequestAppointmentCommand": if (request.TryGetValue("data", out var data)) { var jData = data as JObject; if (jData.TryGetValue("dayId", out var dayId) && jData.TryGetValue("timeslot", out var timeslot) && jData.TryGetValue("appointmentName", out var appointmentName)) { Guid id = new Guid(dayId.ToString()); int timeslotInt = int.Parse(timeslot.ToString()); string appt = appointmentName.ToString(); var cmd = new RequestAppointmentCommand(id, timeslotInt, appt); Send(cmd); } } break; } } }
public async Task <IActionResult> RequestAppointment( RequestAppointmentCommand command) => await this.Send(command);