예제 #1
0
        // GET: Entry/Details/5
        public async Task <IActionResult> Details(Guid?id)
        {
            if (!id.HasValue)
            {
                return(NotFound());
            }
            Entry entry = await _repository.GetAsync(id.Value);

            Guid deviceId = entry.Device.Id;

            ViewData[GarduinoConstants.DeviceId] = deviceId;
            return(View(entry));
        }
예제 #2
0
        public async Task <MeasureQueryDto> Handle(GetMeasureQueryRequest request, CancellationToken cancellationToken)
        {
            var measure = await _measureRepository.GetAsync(request.MeasureId);

            var measureDto = MeasureMapper.Map(measure);

            return(measureDto);
        }
예제 #3
0
        public async Task <IActionResult> GetMeasureFromDate([FromRoute] Guid deviceId, [FromRoute] DateTime dateTime)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Device dev = await GetDeviceAsync(deviceId);

            if (dev == null)
            {
                return(NotFound("Device not found"));
            }
            var measure = await _repository.GetAsync(dateTime, dev);

            if (measure is null)
            {
                return(NotFound());
            }
            return(Ok(measure));
        }
예제 #4
0
        public async Task <MeasureDto> GetAsync(string name)
        {
            var measure = await _measureRepository.GetAsync(name);

            return(_mapper.Map <Measure, MeasureDto>(measure));
        }