public IHttpActionResult CreateChannel(ChannelBindingModel channelData)
        {
            if (channelData == null)
            {
                return BadRequest("Missing channel data.");
            }

            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (db.Channels.All().Any(c => c.Name == channelData.Name))
            {
                return this.Content(HttpStatusCode.Conflict,
                    new { Message = "Duplicated channel name: " + channelData.Name } );
            }

            var channel = new Channel() { Name = channelData.Name };
            db.Channels.Add(channel);
            db.SaveChanges();

            return this.CreatedAtRoute(
                "DefaultApi", 
                new { controller = "channels", id = channel.Id },
                new { channel.Id, channel.Name });
        }
        public IHttpActionResult EditChannel(int id, ChannelBindingModel channelData)
        {
            if (channelData == null)
            {
                return BadRequest("Missing channel data.");
            }

            var channel = db.Channels.Find(id);
            if (channel == null)
            {
                return NotFound();
            }

            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (db.Channels.All().Any(c => c.Name == channelData.Name && c.Id != id))
            {
                return this.Content(HttpStatusCode.Conflict,
                    new { Message = "Duplicated channel name: " + channelData.Name });
            }

            channel.Name = channelData.Name;
            db.Channels.Update(channel);
            db.SaveChanges();

            return this.Ok(
                new
                {
                    Message = "Channel #" + id + " edited successfully."
                }
            );
        }