public AssignOrUnassignJobToWorkerWhenJobSelected(WorkerIdentifier workerId, IJobSelectedObservable jobSelectedObservable, IEnqueueObservableCommand <WorkshopCommand, WorkshopError> workshopCommands, IDisplayJobListDropdownValidation displayValidation)
 {
     jobSelectedObservable
     .Select(maybeJobId => BuildJobSelectionCommand(maybeJobId, workerId))
     .SelectMany(command => workshopCommands.ObserveResult(command))
     .Subscribe(result => result.Switch(success => { }, failure => displayValidation.ShowError(failure.Error)));
 }
Beispiel #2
0
 public SetWorkButtonNotInteractableWhenWorkerAdded(WorkerIdentifier workerId, IObservable <WorkshopEvent> workshopEvents, IDisplayWorkButtonInteractable displayWorkButtonInteractable)
 {
     workshopEvents
     .OfType <WorkshopEvent, WorkshopEvent.WorkerAdded>()
     .Where(workerAdded => workerAdded.Worker.Id == workerId)
     .Subscribe(_ => displayWorkButtonInteractable.Interactable = false);
 }
Beispiel #3
0
 public UpdateWorkButtonInteractableWhenWorkerStatusUpdated(WorkerIdentifier workerId, IObservable <WorkshopEvent> workshopEvents, IDisplayWorkButtonInteractable displayWorkButtonInteractable)
 {
     workshopEvents
     .OfType <WorkshopEvent, WorkshopEvent.WorkerStatusUpdated>()
     .Where(workerStatusUpdated => workerStatusUpdated.WorkerId == workerId)
     .Select(workerStatusUpdated => workerStatusUpdated.NewStatus.Busy)
     .Subscribe(busy => displayWorkButtonInteractable.Interactable = !busy);
 }
Beispiel #4
0
        public AssignedJobReadModel(WorkerIdentifier workerId, IObservable <WorkshopEvent> workshopEvents)
        {
            workshopEvents
            .OfType <WorkshopEvent, WorkshopEvent.JobAssigned>()
            .Where(jobAssigned => jobAssigned.WorkerId == workerId)
            .Subscribe(jobAssigned => AssignedJob = jobAssigned.JobId.ToMaybe());

            workshopEvents
            .OfType <WorkshopEvent, WorkshopEvent.JobUnassigned>()
            .Where(jobUnassigned => jobUnassigned.WorkerId == workerId)
            .Subscribe(_ => AssignedJob = Maybe <JobIdentifier> .Nothing);
        }
        public UpdateSelectedJobWhenJobAssignedOrJobUnassignedToWorker(WorkerIdentifier workerId, IObservable <WorkshopEvent> workshopEvents, IDisplaySelectedJob displaySelectedJob)
        {
            var assigned = workshopEvents
                           .OfType <WorkshopEvent, WorkshopEvent.JobAssigned>()
                           .Where(jobAssigned => jobAssigned.WorkerId == workerId)
                           .Select(jobAssigned => jobAssigned.JobId.ToMaybe());

            var unassigned = workshopEvents
                             .OfType <WorkshopEvent, WorkshopEvent.JobUnassigned>()
                             .Where(jobUnassigned => jobUnassigned.WorkerId == workerId)
                             .Select(_ => Maybe <JobIdentifier> .Nothing);

            assigned.Merge(unassigned)
            .Subscribe(assignment => displaySelectedJob.SelectedJob = assignment);
        }
        public UpdateWorkButtonInteractableWhenWorkerAssignedOrUnassigned(WorkerIdentifier workerId, IObservable <WorkshopEvent> workshopEvents, IDisplayWorkButtonInteractable displayWorkButtonInteractable)
        {
            var assignments = workshopEvents
                              .OfType <WorkshopEvent, WorkshopEvent.JobAssigned>()
                              .Where(jobAssigned => jobAssigned.WorkerId == workerId)
                              .Select(_ => true);

            var unassignments = workshopEvents
                                .OfType <WorkshopEvent, WorkshopEvent.JobUnassigned>()
                                .Where(jobUnassigned => jobUnassigned.WorkerId == workerId)
                                .Select(_ => false);

            assignments.Merge(unassignments)
            .Subscribe(interactable => displayWorkButtonInteractable.Interactable = interactable);
        }
Beispiel #7
0
 private JobIdentifier GetAssignedJob(WorkerIdentifier workerId)
 => State.Assignments.Single(pair => pair.Value == workerId).Key;
Beispiel #8
0
 private void OnWorkerAdded(WorkerIdentifier workerId)
 => _workerPanels[workerId] = _workerPanelFactory.Create(workerId);
 public void AssignSomeWorkerToSomeJob_FailsWithUnknownWorker(WorkerIdentifier someWorker, Job someJob)
 {
     Act_AssignJob(someWorker, someJob.Id)
     .Assert_FailsWith(WorkshopError.UnknownWorker);
 }
 protected Maybe <WorkshopError> Act_UnassignWorker(WorkerIdentifier workerId)
 => _sut.HandleCommand(new WorkshopCommand.UnassignWorker(workerId));
 protected Maybe <WorkshopError> Act_AssignJob(WorkerIdentifier workerId, JobIdentifier jobId)
 => _sut.HandleCommand(new WorkshopCommand.AssignJob(jobId, workerId));
 public void UnassignSomeWorker_FailsWithUnknownWorker(WorkerIdentifier someWorker)
 {
     Act_UnassignWorker(someWorker)
     .Assert_FailsWith(WorkshopError.UnknownWorker);
 }
 private WorkshopCommand BuildJobSelectionCommand(Maybe <JobIdentifier> maybeJobId, WorkerIdentifier workerId)
 => maybeJobId.SelectOrElse <JobIdentifier, WorkshopCommand>(
     jobId => new WorkshopCommand.AssignJob(jobId, workerId),
     () => new WorkshopCommand.UnassignWorker(workerId)
     );
 public void Setup(WorkerIdentifier worker)
 => _workerNameText.text = worker.ToString();
Beispiel #15
0
 public UnassignWorker(WorkerIdentifier workerId)
 {
     WorkerId = workerId;
 }
Beispiel #16
0
 public AssignJob(JobIdentifier jobId, WorkerIdentifier workerId)
 {
     JobId    = jobId;
     WorkerId = workerId;
 }