public HttpResponseMessage AddVoters(VotersDTO givenVoter) { try { using (logic) { VotersDTO addedVoter = logic.addVoter(givenVoter); return(Request.CreateResponse(HttpStatusCode.Created, addedVoter)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ErrorsManager.GetInnerMeesage(ex))); } }
public HttpResponseMessage UpdateVoters(VotersDTO givenVoter, int id) { try { using (logic) { givenVoter.id = id; VotersDTO updatedVoter = logic.UpdateVoter(givenVoter); if (updatedVoter == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } return(Request.CreateResponse(HttpStatusCode.OK, updatedVoter)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ErrorsManager.GetInnerMeesage(ex))); } }
public HttpResponseMessage GetAllVoters() { try { using (logic) { List <VotersDTO> allVoters = logic.GetAllVoters(); return(Request.CreateResponse(HttpStatusCode.OK, allVoters)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ErrorsManager.GetInnerMeesage(ex))); } }