コード例 #1
0
 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)));
     }
 }
コード例 #2
0
 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)));
     }
 }
コード例 #3
0
 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)));
     }
 }