コード例 #1
0
        public GetGatewaysOutput GetAllWithDeviceInfo()
        {
            var output = new GetGatewaysOutput();

            // Include Device Data
            var gateways = (from g in _gatewayRepo.FindAll(i => i.Devices)
                            select new GatewayDetailDto
            {
                SerialNumber = g.SerialNumber,
                Name = g.Name,
                Id = g.Id,
                IPv4 = g.IPv4,
                Devices = (from d in g.Devices
                           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(),
            }).ToList();

            output.Items.AddRange(gateways);

            output.StatusCode    = HttpStatusCode.OK;
            output.StatusMessage = "Items retrieved successfully";

            return(output);
        }
コード例 #2
0
        public IHttpActionResult GetAllGateways()
        {
            var output = new GetGatewaysOutput();

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

            return(Ok(output));
        }