public Task <IEnumerable <RequestedWorker> > Handle(GetWorkers command, CancellationToken cancellationToken) { var workers = repo.GetAll().Where(w => w.Role == Role.Worker); var response = workers.Select(u => mapper.Map <RequestedWorker>(u)); return(Task.FromResult(response)); }
// GET: JobController/Edit/5 public ActionResult Edit(int id) { var request = new GetWorkers(); var response = mediator.Send(request).Result; var workers = response.Select(w => new Worker() { Id = w.Id, Name = w.Name }).ToList(); var getJob = new GetJob() { Id = id }; var j = mediator.Send(getJob).Result; var job = new Job() { Id = j.Id, Title = j.Title, Status = j.Status, AssigneeName = j.AssigneeName, AssigneeId = j.AssigneeId, Description = j.Description, FinalDescription = j.FinalDescription, Scheduled = j.Scheduled, VehicleId = j.VehicleId }; var status = new List <string>() { "Created", "InProgress", "Finished", "Canceled" }; var view = new JobAddEditViewModel() { Workers = workers, Job = job, Status = status }; return(View(view)); }
// GET: JobController/Create public ActionResult Create(int id) { var request = new GetWorkers(); var response = mediator.Send(request).Result; var workers = response.Select(w => new Worker() { Id = w.Id, Name = w.Name }).ToList(); var job = new Job() { VehicleId = id, Scheduled = DateTime.Today }; var view = new JobAddEditViewModel() { Workers = workers, Job = job }; return(View(view)); }