public async Task <ActionResult> MarkCompleteTransaction([FromBody] TQRequestObjectForComplete tQRequestObjectForComplete)
        {
            try
            {
                var activeTQKey = RouteData.Values["activeTransactionQueueKey"].ToString().Trim();

                if (string.IsNullOrEmpty(activeTQKey) || !Regex.IsMatch(activeTQKey, @"^[0-9a-fA-F]{24}$"))
                {
                    BusinessResponse objBadRequest = new BusinessResponse()
                    {
                        IsSuccess = false, Message = "ActiveTransactionQueueKey is not valid.", StatusCode = 400
                    };
                    _logger.LogError(objBadRequest.Message);
                    return(BadRequest(objBadRequest));
                }

                int activeActorKey;
                Int32.TryParse(RouteData.Values["actorKey"].ToString(), out activeActorKey);
                if (activeActorKey <= 0)
                {
                    _logger.LogError("Please provide valid actorKey");
                    return(BadRequest(new ErrorResponse("Please provide valid actorKey", (int)HttpStatusCode.BadRequest,
                                                        ResponsePayloadType.BusinessException)));
                }

                if (!ModelState.IsValid)
                {
                    _logger.LogError("Model is not Valid");
                    return(BadRequest(new ErrorResponse(new ModelStateRequestValidationAdaptor(ModelState).ToString(), (int)HttpStatusCode.BadRequest, ResponsePayloadType.BusinessException)));
                }

                BusinessResponse response = _transactionQueueBussiness.MarkCompleteTransaction(activeTQKey, activeActorKey, tQRequestObjectForComplete);
                if (response.IsSuccess == false)
                {
                    _logger.LogError(response.Message);
                    return(BadRequest(new ErrorResponse(response.Message, (int)HttpStatusCode.BadRequest, ResponsePayloadType.BusinessException)));
                }
                else
                {
                    _logger.LogInformation(response.Message);
                    return(Ok(response.Message));
                }
            }catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(StatusCode(500));
            }
        }
Exemple #2
0
        public BusinessResponse MarkCompleteTransaction(string activeTransactionQueueKey, int actorKey, TQRequestObjectForComplete tQRequestObjectForComplete)
        {
            bool f10Override = false;
            var  message     = new BusinessResponse();

            if (string.IsNullOrEmpty(activeTransactionQueueKey.Trim()))
            {
                message = new BusinessResponse()
                {
                    IsSuccess = false, Message = "Please provide active transaction queue key."
                };
                return(message);
            }
            if (actorKey <= 0)
            {
                message = new BusinessResponse()
                {
                    IsSuccess = false, Message = "Please provide valid actorKey."
                };
                return(message);
            }
            if (tQRequestObjectForComplete == null)
            {
                message = new BusinessResponse()
                {
                    IsSuccess = false, Message = "Model is not Valid."
                };
                return(message);
            }
            var chkTransactionIsActive = _transactionQueueRepository.CheckTransactionIsActive(activeTransactionQueueKey);

            if (chkTransactionIsActive == null)
            {
                message = new BusinessResponse()
                {
                    IsSuccess = false, Message = "Given transaction is no longer active."
                };
                return(message);
            }

            var activeISA = this.GetActiveISA(actorKey).GetAwaiter().GetResult();

            if (activeISA.Count > 0)
            {
                if (!activeISA.Contains(chkTransactionIsActive.IsaId))
                {
                    message = new BusinessResponse()
                    {
                        IsSuccess = false, Message = "Active ISA is no longer controlled by current user."
                    };
                    return(message);
                }
            }
            else
            {
                message = new BusinessResponse()
                {
                    IsSuccess = false, Message = "No active ISA found for current user"
                };
                return(message);
            }

            if (string.IsNullOrEmpty(tQRequestObjectForComplete.scanCode))
            {
                message = new BusinessResponse()
                {
                    IsSuccess = false, Message = "NO SCAN VALUE PROVIDED"
                };
                return(message);
            }
            if (tQRequestObjectForComplete.scanCode.ToLower() == F10_Scan_code.ToString().ToLower())
            {
                f10Override = true;
                // To Do check current user is authrorize for overriding the scan process
            }
            if (string.IsNullOrEmpty(tQRequestObjectForComplete.workFlowStep.ToString()))
            {
                var statusUpdate = _transactionQueueRepository.UpdateTQStatus(activeTransactionQueueKey,
                                                                              TransactionQueueStatus.Active.ToString(), TransactionQueueStatus.Pending.ToString());
            }

            // Active ISA Check TO DO

            if (tQRequestObjectForComplete.tqType.ToString().ToLower() == TransactionQueueType.Pick.ToString().ToLower())
            {
                if (tQRequestObjectForComplete.workFlowStep.ToString().ToLower() == WorkFlowStep.PICK_BIN.ToString().ToLower())
                {
                    // TO DO Actual Scan BIN
                }

                if (tQRequestObjectForComplete.workFlowStep.ToString().ToLower() == WorkFlowStep.PICK_ITEM.ToString().ToLower())
                {
                    // TO DO Actual Scan ITEM
                }
                if (tQRequestObjectForComplete.workFlowStep.ToString().ToLower() == WorkFlowStep.PICK_LABEL.ToString().ToLower())
                {
                    //To DO check Authorization
                    // TO Do Verify Quantity
                    if (f10Override)
                    {
                        var result = _transactionQueueRepository.MarkComplete(activeTransactionQueueKey);
                        if (result)
                        {
                            message = new BusinessResponse()
                            {
                                IsSuccess = true, Message = "Transaction Completed"
                            };
                            return(message);
                        }
                        else
                        {
                            message = new BusinessResponse()
                            {
                                IsSuccess = false, Message = "Transaction Not Completed"
                            };
                            return(message);
                        }
                    }
                }
                // TO DO Contion for other use cases.
            }
            message = new BusinessResponse()
            {
                IsSuccess = false, Message = "No condition meet"
            };

            return(message);
        }