public async Task <List <ServiceAgreement> > IsBreached() { foreach (var tag in _tags) { var constrains = await _repository.GetAllAsync(); var constrain = constrains.ToList().Where(constrain => constrain.Tags.Any(t => t.Id == tag.Id)).FirstOrDefault(); if (constrain != null) { ServiceAgreement configuration = new ServiceAgreement(); configuration.DeviceId = _station.DeviceId; configuration.TagId = tag.Id; configuration.IsActive = tag.IsActive; configuration.UpdateAt = tag.UpdateAt; configuration.CreateDate = tag.CreateDate; configuration.Humidity = (tag.Humidity >= constrain.HumidityMin && tag.Humidity <= constrain.HumidityMax) ? true : false; configuration.Pressure = (tag.Pressure >= constrain.PressureMin && tag.Pressure <= constrain.PressureMax) ? true : false; configuration.Temperature = (tag.Temperature >= constrain.TemperatureMin && tag.Temperature <= constrain.TemperatureMax) ? true : false; this._collection.Add(configuration); } } return(this._collection); }
public async Task <IActionResult> GetAllRoutes() { var routes = await _repository.GetAllAsync(); if (routes != null) { return(Ok(_mapper.Map <IEnumerable <RouteReadDto> >(routes))); } return(NotFound()); }
public async Task <IActionResult> GetAllConstrains() { var constrains = await _repository.GetAllAsync(); if (constrains != null) { return(Ok(_mapper.Map <IEnumerable <AgreementReadDto> >(constrains))); } return(NotFound()); }
public async Task <IActionResult> GetRoutesByDeviceId(string id) { var routes = await _repository.GetAllAsync(); if (routes != null) { return(Ok(_mapper.Map <IEnumerable <RouteReadDto> >( routes.Where(x => x.Devices != null) .Where(x => x.Devices.Contains(id))))); } return(NotFound()); }
public async Task <IActionResult> GetConstraintsByDeviceId(string id) { var constrains = await _repository.GetAllAsync(); if (constrains != null) { var stations = await _repositoryRuuviStation.GetAllAsync(); stations = stations.FindAll(doc => doc.DeviceId == id).ToList(); var tags = stations .SelectMany(x => x.Tags) .Select(x => x.Id) .Distinct(); var constrainTable = tags.ToDictionary(k => k.ToLower(), v => constrains.Where(x => x.Tags.Any(y => y.Id == v)) .Select(x => _mapper.Map <AgreementReadDto>(x))); return(Ok(constrainTable)); } return(NotFound()); }
public async Task <List <ServiceGeometric> > IsBreached() { var constrains = await _repository.GetAllAsync(); var filterConstrains = constrains.ToList().Where(constrain => constrain.Devices.Any(d => d == _station.DeviceId)).ToList(); foreach (var constrain in filterConstrains) { foreach (var boundary in constrain.Points) { ServiceGeometric configuration = new ServiceGeometric(); configuration.DeviceId = _station.DeviceId; configuration.ConstrainName = constrain.Name; configuration.Boundary = IntersectsWith(_station.Location, boundary); configuration.UpdateAt = constrain.UpdatedAt; configuration.CreateAt = constrain.CreatedAt; this._collection.Add(configuration); } } return(_collection); }
private async Task <List <Notification> > GetAllObjectsAsync() { var stations = await _repository.GetAllAsync(); return(stations.GroupBy(doc => new { doc.DeviceId }, (key, group) => group.First()).ToList()); // Groups By DeviceId }