/// <summary>
        /// Returns the list of <see cref="Leds"/> which are member of the <see cref="Group"/> having the specified <see cref="Group.Id"/>.
        /// The methods throws a <see cref="ResourceNotFoundException"/> if the underlying <see cref="Group"/> does not exist.
        /// </summary>
        /// <param name="id"><see cref="Group.Id"/></param>
        /// <returns><see cref="GroupLeds"/> containing the <see cref="Leds"/> being member of the <see cref="Group"/></returns>
        public GroupLeds GetGroupLeds(int id)
        {
            IGroupDataSet gds = _groupStorage.GetGroup(id);

            if (gds != null)
            {
                GroupLeds gLeds = new GroupLeds();
                gLeds.GroupId = gds.Id;
                foreach (string ledId in gds.Leds)
                {
                    ILedDataSet lds = _ledStorage.GetLed(ledId);
                    if (lds != null)
                    {
                        Led led = new Led();
                        led.ControllerId = lds.ControllerId;
                        led.LedNumber    = lds.LedNumber;
                        led.RgbValue     = lds.RgbValue;
                        gLeds.Leds.Add(led);
                    }
                }
                return(gLeds);
            }
            else
            {
                throw new ResourceNotFoundException(ResourceNotFoundException.MSG_GROUP_NOT_FOUND.Replace("{VALUE}", id + ""));
            }
        }
        public void GetLedsOfGroup(HttpContext context, string groupId)
        {
            int       id        = ApiBase.ParseId(groupId);
            GroupLeds groupLeds = _groupHandler.GetGroupLeds(id);
            string    json      = JsonSerializer.SerializeJson(groupLeds);

            context.Response.Payload.Write(json);
            context.Response.Status = HttpStatus.OK;
        }
 /// <summary>
 /// Overwrites the list of <see cref="Leds"/> of the <see cref="Group"/> having the passed ID with the passed LED list.
 /// Note that the specified LEDs must exist, otherwise non-existing LEDs will not be added.
 /// The methods throws a <see cref="ResourceNotFoundException"/> if the underlying <see cref="Group"/> does not exist.
 /// </summary>
 /// <param name="id"><see cref="Group.Id"/></param>
 /// <param name="groupLeds">list with LEDs</param>
 public void SetLedsOfGroup(int id, GroupLeds groupLeds)
 {
     if (_groupStorage.HasGroup(id))
     {
         IList <string> ledIds = new List <string>();
         foreach (Led led in groupLeds.Leds)
         {
             string ledId = led.ControllerId + ":" + led.LedNumber;
             if (_ledStorage.HasLed(ledId))
             {
                 ledIds.Add(ledId);
             }
         }
         _groupStorage.SetLeds(id, ledIds);
     }
     else
     {
         throw new ResourceNotFoundException(ResourceNotFoundException.MSG_GROUP_NOT_FOUND.Replace("{VALUE}", id + ""));
     }
 }
        public void SetLedsOfGroup(HttpContext context, string groupId)
        {
            if (context.Request.Payload.Length > 0)
            {
                string    json      = context.Request.Payload.ReadAll();
                GroupLeds groupLeds = JsonSerializer.DeserializeJson <GroupLeds>(json);

                int id = ApiBase.ParseId(groupId);
                if (groupLeds == null)
                {
                    throw new BadRequestException(BadRequestException.MSG_INVALID_PAYLOAD);
                }
                _groupHandler.SetLedsOfGroup(id, groupLeds);

                GroupLeds response    = _groupHandler.GetGroupLeds(id);
                string    jsonRespone = JsonSerializer.SerializeJson(groupLeds);
                context.Response.Payload.Write(jsonRespone);
                context.Response.Status = HttpStatus.OK;
            }
            else
            {
                throw new BadRequestException(BadRequestException.MSG_PAYLOAD_EXPECTED);
            }
        }