Ejemplo n.º 1
0
 //public HttpResponseMessage Post([ModelBinder(typeof(UserModelBinder))] User username)
 //public HttpResponseMessage Post([FromBody] String username)
 //public HttpResponseMessage Post([ValueProvider(typeof(HeaderValueFactory))] String username)
 public HttpResponseMessage Post(Post post, [FromUri]User user)
 {
     HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);
     response.Content = new StringContent("aaa");
     return response;
     //...
 }
Ejemplo n.º 2
0
 public void Update(Post post)
 {
     Post oldPost = _posts.Single(p => p.Id == post.Id);
     oldPost.Title = post.Title;
     oldPost.Date = post.Date;
     oldPost.Body = post.Body;
 }
Ejemplo n.º 3
0
 public HttpResponseMessage Put(int id, Post post)
 {
     post.Id = id;
     _repository.Update(post);
     HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, post);
     string uri = Url.Link("DefaultApi", new { id = post.Id });
     response.Headers.Location = new Uri(uri);
     return response;
 }
Ejemplo n.º 4
0
        public bool BindModel(HttpActionContext actionContext, ModelBindingContext bindingContext)
        {
            Post model = new Post();
            string key = bindingContext.ModelName;
            ValueProviderResult val = bindingContext.ValueProvider.GetValue(key);

            bindingContext.Model = model;

            return true;
        }
Ejemplo n.º 5
0
        //public HttpResponseMessage Post([ModelBinder(typeof(UserModelBinder))]Post post)
        public HttpResponseMessage Post(Post post)
        {
            _repository.Create(post);
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created);
            response.StatusCode = HttpStatusCode.Created;
            string uri = Url.Link("DefaultApi", new { id = post.Id });
            response.Headers.Location = new Uri(uri);

            return response;
        }
Ejemplo n.º 6
0
 public void Create(Post post)
 {
     post.Id = _posts.Count() + 1;
     _posts.Add(post);
 }