public HttpResponseMessage CreateEFTPOSCommand([FromBody] PATRequest commandRequest) { if (!_clientValidator.Validate(Request.GetClientCertificate(), Request.Headers.Authorization, out string message)) { return(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, new UnauthorizedAccessException(message))); } 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)); } }
public HttpResponseMessage CreateTender([FromBody] PATRequest tenderRequest) { if (!_clientValidator.Validate(Request.GetClientCertificate(), Request.Headers.Authorization, out string message)) { return(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, new UnauthorizedAccessException(message))); } 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.Created, 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)); } }
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)); } }
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)); } }
private void _device_OnPayAtTableRequest(PATRequest request) { // Success ConfirmaitonOK //Thread.Sleep(8 * 1000); if (request.RequestType == PATRequestType.TableList) { var test = request.TableId; _device.PayAtTableResponse() .WithXMLPath("C:\\Users\\steven.tan\\Desktop\\PAY@TABLE SAMPLE RESPONSE\\tablelistsample.xml") .Execute(); } else if (request.RequestType == PATRequestType.Ticket) { _device.PayAtTableResponse() .WithPayAtTableResponseType(PATResponseType.CONF_OK) .WithAmount(123.45M) .WithPaymentMode(PATPaymentMode.NO_ADDITIONAL) .Execute(); } else if (request.RequestType == PATRequestType.SplitSaleReport) { _device.PayAtTableResponse() .WithPayAtTableResponseType(PATResponseType.CONF_OK) .WithAmount(123.45M) .WithPaymentMode(PATPaymentMode.NO_ADDITIONAL) .Execute(); } else if (request.RequestType == PATRequestType.TableReceipt) { _device.PayAtTableResponse() .WithXMLPath("C:\\Users\\steven.tan\\Desktop\\PAY@TABLE SAMPLE RESPONSE\\receiptrequestsample.xml") .Execute(); } else if (request.RequestType == PATRequestType.TransactionOutcome) { _device.PayAtTableResponse() .WithPayAtTableResponseType(PATResponseType.CONF_OK) .WithAmount(123.45M) .WithPaymentMode(PATPaymentMode.NO_ADDITIONAL) .Execute(); } else if (request.RequestType == PATRequestType.TableLock) { _device.PayAtTableResponse() .WithPayAtTableResponseType(PATResponseType.CONF_OK) .WithAmount(123M) .WithPaymentMode(PATPaymentMode.NO_ADDITIONAL) .Execute(); } }
public HttpResponseMessage UpdateTender(string id, [FromBody] PATRequest tenderRequest) { log.DebugEx(tr => tr.Set("PUT ~/api/tenders", tenderRequest)); // Extract the tender from the request if (tenderRequest == null || tenderRequest.Tender == null) { log.ErrorEx(tr => tr.Set("TenderRequest.Tender==NULL in PUT ~/api/tenders.")); return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "TenderRequest.Tender==NULL")); } // Validate the tender id if (!tenderRequest.Tender.Id.Equals(id)) { log.ErrorEx(tr => tr.Set("tenderRequest.Tender.Id != param id in PUT ~/api/tenders.")); return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "tenderRequest.Tender.Id != param id")); } try { var r = new PATResponse { Tender = _tendersRepository.UpdateTender(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 PUT ~/api/tenders.", ex)); return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } catch (ResourceNotFoundException ex) { log.ErrorEx(tr => tr.Set("ResourceNotFoundException in PUT ~/api/tenders.", ex)); return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex)); } }