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)));
 }
예제 #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);
 }
예제 #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);
 }
예제 #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);
        }
예제 #7
0
 private JobIdentifier GetAssignedJob(WorkerIdentifier workerId)
 => State.Assignments.Single(pair => pair.Value == workerId).Key;
예제 #8
0
 private void OnWorkerAdded(WorkerIdentifier workerId)
 => _workerPanels[workerId] = _workerPanelFactory.Create(workerId);
예제 #9
0
 public void AssignSomeWorkerToSomeJob_FailsWithUnknownWorker(WorkerIdentifier someWorker, Job someJob)
 {
     Act_AssignJob(someWorker, someJob.Id)
     .Assert_FailsWith(WorkshopError.UnknownWorker);
 }
예제 #10
0
 protected Maybe <WorkshopError> Act_UnassignWorker(WorkerIdentifier workerId)
 => _sut.HandleCommand(new WorkshopCommand.UnassignWorker(workerId));
예제 #11
0
 protected Maybe <WorkshopError> Act_AssignJob(WorkerIdentifier workerId, JobIdentifier jobId)
 => _sut.HandleCommand(new WorkshopCommand.AssignJob(jobId, workerId));
예제 #12
0
 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)
     );
예제 #14
0
 public void Setup(WorkerIdentifier worker)
 => _workerNameText.text = worker.ToString();
예제 #15
0
 public UnassignWorker(WorkerIdentifier workerId)
 {
     WorkerId = workerId;
 }
예제 #16
0
 public AssignJob(JobIdentifier jobId, WorkerIdentifier workerId)
 {
     JobId    = jobId;
     WorkerId = workerId;
 }