public IHttpActionResult DeleteSample(string id) { _sampleCRUD = new SampleCRUD(sampleList); try { _sampleCRUD.DeleteSample(id); return(Ok()); } catch (Exception ex) { // Here we need log the error properly throw ex; } }
public IHttpActionResult GetSampleById(string id) { _sampleCRUD = new SampleCRUD(sampleList); try { var result = _sampleCRUD.GetSampleById(id); if (result != null) { return(Ok(result)); } return(NotFound()); } catch (Exception ex) { // Here we need log the error properly throw ex; } }
public IHttpActionResult UpdateSample(string id, [FromBody] Sample sampleData) { _sampleCRUD = new SampleCRUD(sampleList); try { if (sampleData == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _sampleCRUD.UpdateSample(id, sampleData); return(Created(new Uri($"api/v1/mySampleApp/{sampleData.Id}", UriKind.RelativeOrAbsolute), sampleData)); } catch (Exception ex) { // Here we need log the error properly throw ex; } }