Пример #1
0
        // POST api/<controller>
        public HttpResponseMessage Post([FromBody] Household value)
        {
            if (value == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Invalid Household"));
            }

            if (string.IsNullOrEmpty(value?.HousingType))
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Housing Type cannot be blank"));
            }

            //create new household
            string result;
            int    id = _households.CreateHousehold(value, out result);

            value.ID = id;
            if (id == 0)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, result));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.Created, value));
            }
        }