private List <SetChannelPropertyGrouping> GroupChannelsForMultipleSensorsAndOneChannel(ChannelParameter[] channelParameters, IGrouping <int, Channel> channelGroup)
        {
            //3c, 3cf, 5cf

            var list = new List <SetChannelPropertyGrouping>();

            foreach (var task in GetSetChannelPropertyTasks(channelGroup.DistinctBy(c => new { c.Id, c.SensorId }).ToList(), channelParameters))
            {
                var sensorIds = task.Channels.Select(c => c.SensorId).ToArray();

                var tempParameters = new SetChannelPropertyParameters(sensorIds, channelGroup.Key, task.Parameters);

                //5cf
                if (NeedFactors(tempParameters, task.Parameters))
                {
                    //3cf
                    list.AddRange(GetFactorParameters(tempParameters, task.Channels));
                }
                else
                {
                    //3c
                    list.Add(new SetChannelPropertyGrouping(tempParameters, task.Channels));
                }
            }

            return(list);
        }
        private List <SetChannelPropertyGrouping> GroupChannelsForOneSensorAndChannel(ChannelParameter[] channelParameters, IGrouping <int, Channel> sensorsChannels, IGrouping <int, Channel> channelGroup)
        {
            //1c, 1cf, 5cf

            //At this point, regardless of whether or not all factor properties are null or not (if we even need factors at all) we're going to be executing a single request
            var list = new List <SetChannelPropertyGrouping>();

            foreach (var task in GetSetChannelPropertyTasks(channelGroup.DistinctBy(c => new { c.Id, c.SensorId }).ToList(), channelParameters))
            {
                var parameters = new SetChannelPropertyParameters(new[] { sensorsChannels.Key }, channelGroup.Key, task.Parameters);

                //5cf. If we don't need factors, we're equal to 1c
                if (NeedFactors(parameters, task.Parameters))
                {
                    //Apply the factors to the parameters

                    //We could have the same sensor twice with multiple factors; only accept the first one
                    var factor = task.Channels.GroupBy(c => c.Factor).First();

                    AddFactorProperties(parameters, parameters, factor);
                }

                //One channel on one sensor
                list.Add(new SetChannelPropertyGrouping(parameters, sensorsChannels.ToReadOnly()));
            }

            return(list);
        }