public List <vQualityIndicatorType> GetQualityIndicatorTypes([FromUri] int waterPlantId, [FromUri] int treatmentStepTypeId) { try { var treatmentStepOnWwtp = _dbAccessor.GetTreatmentSteps().Where(x => x.waterPlantId == waterPlantId && x.treatmentStepTypeId == treatmentStepTypeId).Select(x => x.treatmentStepId).FirstOrDefault(); var qualityIndicators = _dbAccessor.GetQualityIndicators().Where(x => x.treatmentStepId != null && x.treatmentStepId == treatmentStepOnWwtp).GroupBy(x => x.indicatorTypeId); var qualityIndicatorGrouping = qualityIndicators.ToList(); var qualityIndicatorTypeIds = new List <int>(); foreach (var qualityIndicator in qualityIndicatorGrouping) { qualityIndicatorTypeIds.Add(qualityIndicator.Key); } var qualityIndicatorTypes = _dbAccessor.GetQualityIndicatorTypes() .Where(x => qualityIndicatorTypeIds.Contains(x.indicatorTypeId)); return(qualityIndicatorTypes.ToList()); } catch (Exception e) { throw new HttpException((int)HttpStatusCode.BadRequest, $"Data could not be retreived. Reason: {e.Message}"); } }
public bool QualityIndicatorEntryExists(DateTime dateTime, string indicatorType, int treatmentStepId) { return(_dbViewAccessor.GetQualityIndicators().Any(x => x.timeStamp == dateTime && x.indicatorName == indicatorType && x.treatmentStepId == treatmentStepId)); }