Пример #1
0
        // PUT api/companies/5
        public HttpResponseMessage Put(string id, [FromBody] UpdateCompanyRequest values)
        {
            if (!ModelState.IsValid)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.BadRequest)
                {
                    Content = new StringContent("The company data contains some invalid data. Please correct for errors and try again.")
                });
            }

            var parameters = _identityProvider.SetUserIdentity(values.Map().To <UpdateCompanyParameters>());

            parameters.CompanyKey = id;

            var result = _companyService.UpdateCompany(parameters);

            result.EnsureSuccessWithHttpResponseException(HttpVerbs.Put);

            return(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = Get(id).ToJSONContent()
            });
        }