public IHttpActionResult Put(int id, Channel channel) { Channel existing = Context.Channels.FirstOrDefault(i => i.Id == id); if (existing == null) { return NotFound(); } else { existing.Name = channel.Name; Context.SaveChanges(); return Ok(existing); } }
public IHttpActionResult Post(Channel channel) { Channel chan = new Channel(channel.Name, channel.Category, new ChatLog(channel.Id)); Context.Channels.Add(channel); Context.SaveChanges(); return Created(this.Request.RequestUri.AbsolutePath + "/" + channel.Id, channel); }