Ejemplo n.º 1
0
        public HttpResponseMessage AddWaterValueBySerialNumber(string serialNumber, [FromBody] WaterValue wv)
        {
            if (wv == null)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            var response = Request.CreateResponse <WaterValue>(HttpStatusCode.Created, wv);

            try
            {
                var updated = m_houseRepository.AddWaterValueBySerialNum(serialNumber, wv);
                if (updated == null)
                {
                    throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound));
                }
            }
            catch (DbEntityValidationException ex)
            {
                response.Content = new StringContent(GetErrorLog(ex));
            }

            response.Headers.Location = GetHouseLocation(m_houseRepository.FindWmBySerialNum(serialNumber).WMHouse.HouseId);
            return(response);
        }