Ejemplo n.º 1
0
        public HttpResponseMessage Add()
        {
            try
            {
                System.IO.StreamReader reader = new System.IO.StreamReader(HttpContext.Request.Body);
                string requestFromPost        = reader.ReadToEnd();
                var    metric = JsonConvert.DeserializeObject <MetricViewModel>(requestFromPost);

                // Calling update
                var response = _repository.AddNewMetric(metric);

                if (response)
                {
                    return(new HttpResponseMessage(HttpStatusCode.OK));
                }
                else
                {
                    return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
                }
            }
            catch (Exception)
            {
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
        }