public IHttpActionResult PostView_Companies(View_Companies view_Companies) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.View_Companies.Add(view_Companies); try { db.SaveChanges(); } catch (DbUpdateException) { if (View_CompaniesExists(view_Companies.Id)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = view_Companies.Id }, view_Companies); }
public IHttpActionResult PutView_Companies(int id, View_Companies view_Companies) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != view_Companies.Id) { return BadRequest(); } db.Entry(view_Companies).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!View_CompaniesExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }