Ejemplo n.º 1
0
        public async Task <ActionResult <PatResponse> > CreateTender([FromBody] PatRequest tenderRequest)
        {
            await Task.CompletedTask; // remove when async calls are added

            // Extract the tender from the request
            if (tenderRequest == null || tenderRequest.Tender == null)
            {
                log.LogError("TenderRequest.Tender==NULL in POST ~/api/tenders.");
                return(BadRequest());
            }

            try
            {
                return(Created("", new PatResponse {
                    Tender = tenderRepository.CreateTender(tenderRequest.Tender)
                }));
            }
            catch (InvalidRequestException ex)
            {
                log.LogError("InvalidRequestException in POST ~/api/tenders.", ex);
                return(BadRequest());
            }
            catch (ResourceNotFoundException ex)
            {
                log.LogError("ResourceNotFoundException in POST ~/api/tenders.", ex);
                return(NotFound());
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> UpdateTender([FromRoute] string id, [FromBody] PatRequest tenderRequest)
        {
            await Task.CompletedTask; // remove when async calls are added

            // Extract the tender from the request
            if (tenderRequest == null || tenderRequest.Tender == null)
            {
                log.LogError("TenderRequest.Tender==NULL in PUT ~/api/tenders.");
                return(BadRequest());
            }

            // Validate the tender id
            if (!tenderRequest.Tender.Id.Equals(id))
            {
                log.LogError("tenderRequest.Tender.Id != param id in PUT ~/api/tenders.");
                return(BadRequest());
            }

            try
            {
                return(Ok(new PatResponse {
                    Tender = tenderRepository.UpdateTender(tenderRequest.Tender)
                }));
            }
            catch (InvalidRequestException ex)
            {
                log.LogError("InvalidRequestException in PUT ~/api/tenders.", ex);
                return(BadRequest());
            }
            catch (ResourceNotFoundException ex)
            {
                log.LogError("ResourceNotFoundException in PUT ~/api/tenders.", ex);
                return(NotFound());
            }
        }
Ejemplo n.º 3
0
        public async Task <ActionResult <PatResponse> > CreateEftposCommand([FromBody] PatRequest commandRequest)
        {
            await Task.CompletedTask; // remove when async calls are added

            // Extract the eftpos command from the request
            if (commandRequest == null || commandRequest.EftposCommand == null)
            {
                return(BadRequest("PATRequest.EftposCommand==NULL"));
            }

            try
            {
                return(Ok(new PatResponse {
                    EftposCommand = eftposRepository.CreateEftposCommand(commandRequest.EftposCommand)
                }));
            }
            catch (InvalidRequestException ex)
            {
                log.LogError("InvalidRequestException in POST ~/api/eftpos/commands.", ex);
                return(BadRequest());
            }
            catch (ResourceNotFoundException ex)
            {
                log.LogError("InvalidRequestException in POST ~/api/eftpos/commands.", ex);
                return(NotFound());
            }
        }