public IHttpActionResult CompanyCreate([FromBody] EnterpriseCreateModel model) { long?id = 0; try { if (!ModelState.IsValid) { return(BadRequest("The model is not valid")); } var service = new PumoxService(); id = service.CompanyCreate(model).Result; if (id == null) { return(InternalServerError()); } return(Json(id)); } catch (HttpException ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message))); } }
public IHttpActionResult EnterpriseGetAll() { try { var service = new PumoxService(); var result = service.EnterpriseGetAll().Result; return(ResponseMessage(Request.CreateResponse(HttpStatusCode.OK, result))); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message))); } }
public IHttpActionResult EnterpriseGet(int id) { try { var service = new PumoxService(); var enterpriseModel = service.EnterpriseGet(id).Result; if (enterpriseModel == null) { return(NotFound()); } return(ResponseMessage(Request.CreateResponse(HttpStatusCode.OK, service.EnterpriseGet(id).Result))); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message))); } }
public IHttpActionResult EnterpriseDelete(long id) { try { var service = new PumoxService(); var deleted = service.EnterpriseDelete(id).Result; if (!deleted) { return(NotFound()); } return(ResponseMessage(Request.CreateResponse(HttpStatusCode.OK, "Enterprise has been deleted"))); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message))); } }
public IHttpActionResult EnterpriseUpdate(long id, [FromBody] EnterpriseUpdateModel model) { try { if (!ModelState.IsValid) { return(BadRequest("The model is not valid")); } var service = new PumoxService(); var enterpriseId = service.EnterpriseUpdate(id, model).Result; if (enterpriseId == null) { return(NotFound()); } return(ResponseMessage(Request.CreateResponse(HttpStatusCode.OK, enterpriseId))); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message))); } }