public IHttpActionResult PostDrillholeSamplesView(DrillholeSamplesView drillholeSamplesView) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } repository.Add(drillholeSamplesView); try { repository.SaveChanges(); } catch (DbUpdateException) { if (DrillholeSamplesViewExists(drillholeSamplesView.HOLEID)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = drillholeSamplesView.HOLEID }, drillholeSamplesView)); }
public IHttpActionResult PutDrillholeSamplesView(string id, DrillholeSamplesView drillholeSamplesView) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != drillholeSamplesView.HOLEID) { return(BadRequest()); } repository.Put(drillholeSamplesView); try { repository.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!DrillholeSamplesViewExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetDrillholeSamplesView(string id) { DrillholeSamplesView drillholeSamplesView = repository.Find(id); if (drillholeSamplesView == null) { return(NotFound()); } return(Ok(drillholeSamplesView)); }
public IHttpActionResult DeleteDrillholeSamplesView(string id) { DrillholeSamplesView drillholeSamplesView = repository.Find(id); if (drillholeSamplesView == null) { return(NotFound()); } repository.Delete(drillholeSamplesView); repository.SaveChanges(); return(Ok(drillholeSamplesView)); }