// GET api/module public IEnumerable<Models.Module> Get() { using (var content = new xAppContext()) { return content.Modules.OrderBy(m => m.Name).OrderBy(m => m.Application); } }
// GET api/module/5 public Module Get(int id) { using (var content = new xAppContext()) { return content.Modules.FirstOrDefault(m => m.Id == id); } }
// PUT api/module/5 public void Put(int id, [FromBody]Module value) { using (var content = new xAppContext()) { var set = content.CreateObjectSet<Module>(); set.Attach(value); content.SaveChanges(); } }
// POST api/module public Module Post([FromBody]Module value) { using (var content = new xAppContext()) { var set = content.CreateObjectSet<Module>(); set.Attach(value); content.SaveChanges(); return value; } }
// DELETE api/module/5 public void Delete(int id) { using (var content = new xAppContext()) { var item = content.Modules.FirstOrDefault(m => m.Id == id); if (item != null) { content.Modules.Detach(item); content.SaveChanges(); } } }