public IQueryable<Category> GetAll()
        {
            var context = new ForumContext();

            var categoriesEntities = context.Categories;
            return categoriesEntities.AsQueryable();
        }
Exemplo n.º 2
0
        public IQueryable<Post> GetAll()
        {
            var context = new ForumContext();

            var postsEntities = context.Posts;
            return postsEntities.AsQueryable();
        }
Exemplo n.º 3
0
        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;
        }