public GetDevicesOutput GetDevicesByGateway([FromUri] int gatewayId)
        {
            var response = new GetDevicesOutput();

            try
            {
                response = _service.GetAllByGateway(gatewayId);
            }
            catch (Exception e)
            {
                Helpers.ExceptionHelper.ThrowException(e);
            }

            return(response);
        }
        public IHttpActionResult GetAllDevices()
        {
            var output = new GetDevicesOutput();

            try
            {
                output = _service.GetAllWithGatewayInfo();
            }
            catch (Exception e)
            {
                return(Ok(new { error = e.Message }));
            }

            return(Ok(output));
        }
Example #3
0
        public GetDevicesOutput GetAllWithGatewayInfo()
        {
            var output = new GetDevicesOutput();

            // Include Gateway Data
            var dtos = (from d in _deviceRepo.FindAll(i => i.Gateway)
                        select new DeviceDetailDto
            {
                DateCreated = d.DateCreated,
                GatewayId = d.GatewayId,
                GatewayName = d.Gateway.Name,
                Id = d.Id,
                Status = d.Status,
                UID = d.UID,
                Vendor = d.Vendor,
            }).ToList();

            output.Items.AddRange(dtos);

            return(output);
        }
Example #4
0
        public GetDevicesOutput GetAllByGateway(int gatewayId)
        {
            var output = new GetDevicesOutput();

            // Filter by Gateway and include Gateway data
            var dtos = (from d in _deviceRepo.FindAll(i => i.Gateway)
                        where d.GatewayId == gatewayId
                        select new DeviceDetailDto
            {
                DateCreated = d.DateCreated,
                GatewayId = d.GatewayId,
                GatewayName = d.Gateway.Name,
                Id = d.Id,
                Status = d.Status,
                UID = d.UID,
                Vendor = d.Vendor,
            }).ToList();

            output.Items.AddRange(dtos);

            return(output);
        }