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