public async Task <ListResponse <DeviceSummary> > GetDevicesInStatusAsync(DeviceRepository deviceRepo, string status, ListRequest listRequest, EntityHeader org, EntityHeader user)
        {
            await AuthorizeOrgAccessAsync(user, org, typeof(Device), Actions.Read, "DeviceInState");


            if (!Enum.TryParse <DeviceStates>(status, true, out var newState))
            {
                /* We aren't using newState as parsed by the enum, we are just validating it */
                return(ListResponse <DeviceSummary> .FromErrors(Resources.ErrorCodes.SetStatus_InvalidOption.ToErrorMessage()));
            }
            //We will be comparing against the id, the id will always be lower case
            status = status.ToLower();

            //TODO: Need to extend manager for security on this getting device w/ status

            var repo = GetRepo(deviceRepo);

            return(await repo.GetDevicesInStatusAsync(deviceRepo, status, listRequest));
        }
示例#2
0
        public async Task <ListResponse <DeviceSummary> > GetDevicesInStatusAsync(DeviceRepository deviceRepo, string status, ListRequest listRequest, EntityHeader org, EntityHeader user)
        {
            if (!Enum.TryParse <DeviceStates>(status, true, out DeviceStates newState))
            {
                /* We aren't using newState as parsed by the enum, we are just validating it */
                return(ListResponse <DeviceSummary> .FromErrors(Resources.ErrorCodes.SetStatus_InvalidOption.ToErrorMessage()));
            }
            //We will be comparing against the id, the id will always be lower case
            status = status.ToLower();

            //TODO: Need to extend manager for security on this getting device w/ status
            if (deviceRepo.RepositoryType.Value == RepositoryTypes.Local)
            {
                return(await _deviceConnectorService.GetDevicesInStatusAsync(deviceRepo.Instance.Id, status, listRequest, org, user));
            }
            else
            {
                return(await _deviceRepo.GetDevicesInStatusAsync(deviceRepo, status, listRequest));
            }
        }