コード例 #1
0
        public HttpResponseMessage CreateEFTPOSCommand([FromBody]PATRequest commandRequest)
        {
            log.DebugEx(tr => tr.Set("POST ~/api/eftpos/commands", commandRequest));

            // Extract the eftpos command from the request
            if (commandRequest == null || commandRequest.EFTPOSCommand == null)
            {
                log.ErrorEx(tr => tr.Set("TenderRequest.EFTPOSCommand==NULL in POST ~/api/eftpos/commands."));
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "PATRequest.EFTPOSCommand==NULL");
            }

            try
            {
                var r = new PATResponse { EFTPOSCommand = _eftposRepository.CreateEFTPOSCommand(commandRequest.EFTPOSCommand) };
                log.DebugEx(tr => tr.Set("return", r));
                return Request.CreateResponse(HttpStatusCode.OK, r);
            }
            catch (InvalidRequestException ex)
            {
                log.ErrorEx(tr => tr.Set("InvalidRequestException in POST ~/api/eftpos/commands.", ex));
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex);
            }
            catch (ResourceNotFoundException ex)
            {
                log.ErrorEx(tr => tr.Set("InvalidRequestException in POST ~/api/eftpos/commands.", ex));
                return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex);
            }
        }
コード例 #2
0
        public HttpResponseMessage CreateTender([FromBody]PATRequest tenderRequest)
        {
            log.DebugEx(tr => tr.Set("POST ~/api/tenders", tenderRequest));

            // Extract the tender from the request
            if (tenderRequest == null || tenderRequest.Tender == null)
            {
                log.ErrorEx(tr => tr.Set("TenderRequest.Tender==NULL in POST ~/api/tenders."));
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "TenderRequest.Tender==NULL");
            }

            try
            {
                var r = new PATResponse { Tender = _tendersRepository.CreateTender(tenderRequest.Tender) };
                log.DebugEx(tr => tr.Set("return", r));
                return Request.CreateResponse(HttpStatusCode.OK, r);
            }
            catch (InvalidRequestException ex)
            {
                log.ErrorEx(tr => tr.Set("InvalidRequestException in POST ~/api/tenders.", ex));
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex);
            }
            catch (ResourceNotFoundException ex)
            {
                log.ErrorEx(tr => tr.Set("ResourceNotFoundException in POST ~/api/tenders.", ex));
                return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex);
            }
        }
コード例 #3
0
 public HttpResponseMessage GetTables()
 {
     log.DebugEx("GET ~/api/tables");
     try
     {
         var r = new PATResponse { Tables = _tablesRepository.GetTables() };
         log.DebugEx(tr => tr.Set("return", r));
         return Request.CreateResponse(HttpStatusCode.OK, r);
     }
     catch (InvalidRequestException ex)
     {
         log.ErrorEx(tr => tr.Set("InvalidRequestException in GET ~/api/tables.", ex));
         return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex);
     }
     catch (ResourceNotFoundException ex)
     {
         log.ErrorEx(tr => tr.Set("ResourceNotFoundException in GET ~/api/tables.", ex));
         return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex);
     }
 }