public IQueryable<Category> GetAll() { var context = new ForumContext(); var categoriesEntities = context.Categories; return categoriesEntities.AsQueryable(); }
public IQueryable<Post> GetAll() { var context = new ForumContext(); var postsEntities = context.Posts; return postsEntities.AsQueryable(); }
public HttpResponseMessage PostCreate(Post post) { var responseMsg = this.PerformOperationAndHandleExceptions( () => { var context = new ForumContext(); using (context) { context.Posts.Add(post); context.SaveChanges(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, post); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = post.Id })); return response; } }); return responseMsg; }