Exemplo n.º 1
0
        public HttpResponseMessage UpdateMonthlyStats(int statID, MonthlyStats monthlyStat)
        {
            var updatedMonthlyStat = MonthlyStatsServices.UpdateMonthlyStat(statID, monthlyStat);

            var response = Request.CreateResponse(HttpStatusCode.OK, updatedMonthlyStat, Configuration.Formatters.JsonFormatter);

            response.Headers.Add("API-Version", apiVersion);
            response.Headers.Add("Response-Type", "JSON");
            response.Headers.Add("MonthlyStats-URL", Request.RequestUri.AbsoluteUri);

            if (updatedMonthlyStat == null)
            {
                var notFoundResponse = Request.CreateResponse(HttpStatusCode.NotFound,
                                                              "(404) Monthly Stats Not Found",
                                                              Configuration.Formatters.JsonFormatter);

                notFoundResponse.Headers.Add("API-Version", apiVersion);

                return(notFoundResponse);
            }
            else
            {
                return(response);
            }
        }