public async Task <IEnumerable <WorkerProfile> > FindInRadiusOfAddress(double radiusInKilometers, Address centerAddress) { MapPoint center = await addressToCoordinatesTranslator.Translate(centerAddress); var workers = await workerRepository.Get(); var tasks = workers.Select(async worker => new { worker, IsLivingInRadius = await LivesInRadiusOfCenter(radiusInKilometers, worker.Address, center) }); var workersWithIsLivingInRadius = await Task.WhenAll(tasks); return(workersWithIsLivingInRadius.Where(x => x.IsLivingInRadius).Select(x => x.worker)); }
public string FinishOrder(int id) { var order = _orderRepository.Get(id); var car = _carRepository.Get(order.CarId.Value); var worker = _workerRepository.Get(order.WorkerId.Value); car.WorkerId = null; car.Worker = null; car.IsAway = false; worker.Car = null; order.Finished = true; return($"Order with id {order.Id} was successfuly finished"); }
public string GetData(int confId, UserPublicModel currentUser) { var conf = _widgetConfRepository.GetWidgetConfById(confId); if (conf == null || conf.UserId != currentUser.Id) { return(null); } var widget = _widgetRepository.GetWidgetById(conf.WidgetId); if (widget == null) { return(null); } var service = _serviceRepository.GetServiceById(widget.ServiceId); if (service == null) { return(null); } var provider = _providerRepository.GetProviderById(service.ProvId); if (provider == null) { return(null); } var(route, method, form, token) = ParsConf(conf.Conf, provider); if (route == null || method == null) { return(null); } return(method switch { "get" => _workerRepository.Get(route, token), "post" => _workerRepository.Post(route, form, token), _ => null });
public GetWorkerDto GetWorker(int id) { return(_workerConverter.FromWorkerToGetWorkerDto(_workerRepository.Get(id))); }
public async Task <IActionResult> GetAllWorkers() { var allWorkers = await workerRepository.Get(GetReader()); return(Ok(allWorkers)); }
public List <Worker> Get() { return(_repository.Get() .ToList()); }
public WorkerViewModel Get(int id) { var worker = _workerRepository.Get(id); return(_mapper.Map <Worker, WorkerViewModel>(worker)); }