Esempio n. 1
0
        public HttpResponseMessage Post([FromBody] Models.ModelContact value)
        {
            if (value == null)
            {
                return(new HttpResponseMessage
                {
                    StatusCode = HttpStatusCode.BadRequest
                });
            }

            var contactId = contactRepository.Add(value);

            var result = new { Id = contactId, HasCandy = true };

            var newJson = JsonConvert.SerializeObject(result);

            var postContent = new StringContent(newJson, System.Text.Encoding.UTF8, "application/json");

            return(new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.Created,
                Content = postContent
            });
        }
Esempio n. 2
0
 public void Put(int id, [FromBody] Models.ModelContact value)
 {
     contactRepository.UpdateById(id, value);
 }