public HttpResponseMessage PutCompany(int companyId, CompanyBudget companyBudget) { if (!ModelState.IsValid) { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } if (companyId!= companyBudget.CompanyId) { return Request.CreateResponse(HttpStatusCode.BadRequest); } try { companyBudgetDb.Update(x => x.CompanyId == companyBudget.CompanyId && x.Year==companyBudget.Year, companyBudget); } catch (DbUpdateConcurrencyException ex) { return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex); } return Request.CreateResponse(HttpStatusCode.OK); }
public HttpResponseMessage PostCompany(CompanyBudget companyBudget) { if (ModelState.IsValid) { companyBudgetDb.Insert(companyBudget); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, companyBudget); return response; } return Request.CreateResponse(HttpStatusCode.OK); }