public IHttpActionResult Post(Hiker hiker) { using (HikerDbEntities ctx = new HikerDbEntities()) { ctx.Hiker.Add(hiker); ctx.Entry(hiker).State = (hiker.Id == 0) ? System.Data.Entity.EntityState.Added : System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); return(Ok(hiker)); } }
public IHttpActionResult Delete(long id) { using (HikerDbEntities ctx = new HikerDbEntities()) { var hiker = ctx.Hiker.Find(id); ctx.Hiker.Remove(hiker); ctx.SaveChanges(); return(Ok()); } }